Visit kit.svelte.dev to read the documentation
diff --git a/references/svelte-example/src/routes/api/trigger/+server.ts b/references/svelte-example/src/routes/api/trigger/+server.ts new file mode 100644 index 00000000000..bfe2c729495 --- /dev/null +++ b/references/svelte-example/src/routes/api/trigger/+server.ts @@ -0,0 +1,12 @@ +import { createSvelteRoute } from '@trigger.dev/sveltekit'; + +import { client } from '$trigger'; + +// // Replace this with your own jobs +import '$jobs/example'; + +// Create the Svelte route handler using the createSvelteRoute function +const svelteRoute = createSvelteRoute(client); + +// Define your API route handler +export const POST = svelteRoute.POST; diff --git a/references/svelte-example/src/trigger.ts b/references/svelte-example/src/trigger.ts new file mode 100644 index 00000000000..acea0c199dd --- /dev/null +++ b/references/svelte-example/src/trigger.ts @@ -0,0 +1,7 @@ +import { TriggerClient } from '@trigger.dev/sdk'; +import { TRIGGER_API_KEY } from '$env/static/private'; + +export const client = new TriggerClient({ + id: 'sveltekit-example', + apiKey: TRIGGER_API_KEY, +}); diff --git a/references/svelte-example/static/favicon.png b/references/svelte-example/static/favicon.png new file mode 100644 index 00000000000..825b9e65af7 Binary files /dev/null and b/references/svelte-example/static/favicon.png differ diff --git a/references/svelte-example/svelte.config.js b/references/svelte-example/svelte.config.js new file mode 100644 index 00000000000..e7e16ba2d8e --- /dev/null +++ b/references/svelte-example/svelte.config.js @@ -0,0 +1,28 @@ +import adapter from '@sveltejs/adapter-auto'; +import { vitePreprocess } from '@sveltejs/kit/vite'; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + // Consult https://kit.svelte.dev/docs/integrations#preprocessors + // for more information about preprocessors + preprocess: vitePreprocess(), + + kit: { + // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. + // If your environment is not supported or you settled on a specific environment, switch out the adapter. + // See https://kit.svelte.dev/docs/adapters for more information about adapters. + adapter: adapter(), + alias: { + $trigger: 'src/trigger', + '$jobs/*': 'src/jobs/*', + '@trigger.dev/sveltekit': '../../packages/sveltekit/src/index', + '@trigger.dev/sveltekit/*': '../../packages/sveltekit/src/*', + '@trigger.dev/sdk': '../../packages/trigger-sdk/src/index', + '@trigger.dev/sdk/*': '../../packages/trigger-sdk/src/*', + '@trigger.dev/core': '../../packages/core/src/index', + '@trigger.dev/core/*': '../../packages/core/src/*' + } + } +}; + +export default config; diff --git a/references/svelte-example/tsconfig.json b/references/svelte-example/tsconfig.json new file mode 100644 index 00000000000..7299ebd243f --- /dev/null +++ b/references/svelte-example/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "lib": ["DOM", "DOM.Iterable", "ES2019"], + "isolatedModules": true, + "esModuleInterop": true, + "ignoreDeprecations": "5.0", + "moduleResolution": "node", + "resolveJsonModule": true, + "target": "ES2019", + "strict": true, + "allowJs": true, + "forceConsistentCasingInFileNames": true, + "baseUrl": ".", + "paths": { + "$lib": ["src/lib"], + "$lib/*": ["src/lib/*"], + "$trigger": ["src/trigger"], + "$jobs/*": ["src/jobs/*"] + } + }, + "include": ["src/**/*", "src/node_modules", ".svelte-kit/ambient.d.ts"], // see last element + + "exclude": ["node_modules"] +} diff --git a/references/svelte-example/vite.config.ts b/references/svelte-example/vite.config.ts new file mode 100644 index 00000000000..bbf8c7da43f --- /dev/null +++ b/references/svelte-example/vite.config.ts @@ -0,0 +1,6 @@ +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [sveltekit()] +});