@openworkers/adapter-sveltekit 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,8 +17,8 @@ import adapter from '@openworkers/adapter-sveltekit';
17
17
  export default {
18
18
  kit: {
19
19
  adapter: adapter({
20
- out: 'dist', // Output directory (default: 'dist')
21
- functions: false // Generate mini-workers for API routes (default: false)
20
+ out: 'dist', // Output directory (default: 'dist')
21
+ functions: false // Generate mini-workers for API routes (default: false)
22
22
  })
23
23
  }
24
24
  };
@@ -26,10 +26,10 @@ export default {
26
26
 
27
27
  ## Options
28
28
 
29
- | Option | Type | Default | Description |
30
- |--------|------|---------|-------------|
31
- | `out` | `string` | `'dist'` | Output directory for the build |
32
- | `functions` | `boolean` | `false` | Generate separate mini-workers for each API route |
29
+ | Option | Type | Default | Description |
30
+ | ----------- | --------- | -------- | ------------------------------------------------- |
31
+ | `out` | `string` | `'dist'` | Output directory for the build |
32
+ | `functions` | `boolean` | `false` | Generate separate mini-workers for each API route |
33
33
 
34
34
  ## Output
35
35
 
@@ -90,6 +90,44 @@ declare global {
90
90
  export {};
91
91
  ```
92
92
 
93
+ ## Deployment
94
+
95
+ Build your SvelteKit app, then deploy it with the [OpenWorkers CLI](https://github.com/openworkers/openworkers-cli):
96
+
97
+ ```bash
98
+ # Build
99
+ bun run build
100
+
101
+ # Deploy
102
+ ow workers upload my-app ./dist
103
+ ```
104
+
105
+ For a first deployment, you'll need to set up the worker and its assets binding:
106
+
107
+ ```bash
108
+ # Create the worker
109
+ ow workers create my-app -d "My SvelteKit App"
110
+
111
+ # Create a storage bucket for static assets
112
+ ow storage create my-storage
113
+
114
+ # Create an environment and bind the storage as ASSETS
115
+ ow env create my-app-env
116
+ ow env bind my-app-env ASSETS my-storage --type assets
117
+
118
+ # Link the environment to the worker
119
+ ow workers link my-app my-app-env
120
+ # Build and upload
121
+ bun run build
122
+ ow workers upload my-app ./dist
123
+ ```
124
+
125
+ ## Examples
126
+
127
+ - [world-time-app](https://github.com/max-lt/world-time-app) — SSR-rendered clocks with server-side positioned hands
128
+ - [httpbin](https://github.com/max-lt/httpbin) — HTTP request testing tool
129
+ - [rock-paper-scissors](https://github.com/max-lt/rock-paper-scissors) — Provably fair Rock Paper Scissors game
130
+
93
131
  ## License
94
132
 
95
133
  MIT
@@ -52,6 +52,12 @@ var worker = {
52
52
  }
53
53
  return response;
54
54
  } catch (error) {
55
+ if (error?.status && error?.body) {
56
+ return new Response(JSON.stringify(error.body), {
57
+ status: error.status,
58
+ headers: { "Content-Type": "application/json" }
59
+ });
60
+ }
55
61
  console.error(`[Function] Error in ${method} handler:`, error);
56
62
  return new Response(JSON.stringify({ error: "Internal Server Error" }), {
57
63
  status: 500,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openworkers/adapter-sveltekit",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "SvelteKit adapter for OpenWorkers",
5
5
  "keywords": [
6
6
  "adapter",