https://github.com/shellicar/svelte-adapter-azure-functions
A SvelteKit adapter that builds your app into an Azure Function.
https://github.com/shellicar/svelte-adapter-azure-functions
Last synced: 5 months ago
JSON representation
A SvelteKit adapter that builds your app into an Azure Function.
- Host: GitHub
- URL: https://github.com/shellicar/svelte-adapter-azure-functions
- Owner: shellicar
- License: mit
- Created: 2024-12-26T22:39:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-10-24T10:02:17.000Z (8 months ago)
- Last Synced: 2025-10-24T12:08:50.145Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 265 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @shellicar/svelte-adapter-azure-functions
[](https://npmjs.com/package/@shellicar/svelte-adapter-azure-functions)
[](https://github.com/shellicar/svelte-adapter-azure-functions/actions/workflows/node.js.yml)
[][azure-functions]
[][sveltekit]
[][typescript]
[][biome]
A [SvelteKit adapter](https://kit.svelte.dev/docs/adapters) that builds your app into an Azure Function.
## @shellicar TypeScript Ecosystem
### Core Libraries
- [`@shellicar/core-config`](https://github.com/shellicar/core-config) - A library for securely handling sensitive configuration values like connection strings, URLs, and secrets.
- [`@shellicar/core-di`](https://github.com/shellicar/core-di) - A basic dependency injection library.
### Reference Architectures
- [`@shellicar/reference-foundation`](https://github.com/shellicar/reference-foundation) - A comprehensive starter repository. Illustrates individual concepts.
- [`@shellicar/reference-enterprise`](https://github.com/shellicar/reference-enterprise) - A comprehensive starter repository. Can be used as the basis for creating a new Azure application workload.
### Build Tools
- [`@shellicar/build-clean`](https://github.com/shellicar/build-clean) - Build plugin that automatically cleans unused files from output directories.
- [`@shellicar/build-version`](https://github.com/shellicar/build-version) - Build plugin that calculates and exposes version information through a virtual module import.
- [`@shellicar/build-graphql`](https://github.com/shellicar/build-graphql) - Build plugin that loads GraphQL files and makes them available through a virtual module import.
### Framework Adapters
- [`@shellicar/svelte-adapter-azure-functions`](https://github.com/shellicar/svelte-adapter-azure-functions) - A [SvelteKit adapter](https://kit.svelte.dev/docs/adapters) that builds your app into an Azure Function.
- [`@shellicar/cosmos-query-builder`](https://github.com/shellicar/cosmos-query-builder) - Helper class for type safe advanced queries for Cosmos DB (Sql Core).
### Logging & Monitoring
- [`@shellicar/winston-azure-application-insights`](https://github.com/shellicar/winston-azure-application-insights) - An [Azure Application Insights](https://azure.microsoft.com/en-us/services/application-insights/) transport for [Winston](https://github.com/winstonjs/winston) logging library.
- [`@shellicar/pino-applicationinsights-transport`](https://github.com/shellicar/pino-applicationinsights-transport) - [Azure Application Insights](https://azure.microsoft.com/en-us/services/application-insights) transport for [pino](https://github.com/pinojs/pino)
## Motivation
Looking at the available SvelteKit adapters, there's one for Node.js and a community adapter for Azure Static Web Apps. I wanted to deploy to Azure Functions, so I created this adapter.
## Implementation
The adapter generates a single Azure Function:
```typescript
app.http('server', {
handler,
route: '{*url}',
methods: ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT']
});
```
## Usage
```bash
pnpm add -D @shellicar/svelte-adapter-azure-functions
```
In `svelte.config.js`:
```js
import adapter from '@shellicar/svelte-adapter-azure-functions';
export default {
kit: {
adapter: adapter()
}
};
```
## Configuration
### esbuildOptions
```js
adapter({
esbuildOptions: {
minify: false
}
})
```
Default options in [defaults.ts](./src/defaults.ts):
```typescript
export const defaults = {
bundle: true,
platform: 'node',
target: 'node20',
format: 'esm',
// ...see defaults.ts for full options
};
```
### Function authLevel
The trigger uses the following code, and the authLevel can be changed using the `SERVER_AUTH_LEVEL` environment variable.
```ts
import { app } from '@azure/functions';
import { handler } from './handler';
const getAuthLevel = (level: string | undefined) => {
switch(level) {
case 'function':
return 'function';
case 'admin':
return 'admin';
case 'anonymous':
return 'anonymous';
}
return 'anonymous';
};
app.http('server', {
handler,
authLevel: getAuthLevel(process.env.SERVER_AUTH_LEVEL),
route: '{*url}',
methods: ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT'],
});
```
## Credits
* [svelte-adapter-azure-swa](https://github.com/geoffrich/svelte-adapter-azure-swa)
* [esbuild-azure-functions](https://github.com/beyerleinf/esbuild-azure-functions)
[azure-functions]: https://learn.microsoft.com/azure/azure-functions/functions-reference-node?tabs=typescript%2Cwindows%2Cazure-cli&pivots=nodejs-model-v4
[sveltekit]: https://kit.svelte.dev
[typescript]: https://www.typescriptlang.org
[biome]: https://biomejs.dev