@edgestore/server 1.0.0-next.3 → 1.0.0-next.5

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.
Files changed (115) hide show
  1. package/README.md +2 -8
  2. package/agent-docs/README.md +20 -0
  3. package/agent-docs/astro.md +147 -0
  4. package/agent-docs/backend-client.md +284 -0
  5. package/agent-docs/configuration.md +300 -0
  6. package/agent-docs/express.md +124 -0
  7. package/agent-docs/fastify.md +123 -0
  8. package/agent-docs/hono.md +131 -0
  9. package/agent-docs/next.md +82 -0
  10. package/agent-docs/provider-azure-blob.md +85 -0
  11. package/agent-docs/provider-custom.md +281 -0
  12. package/agent-docs/provider-edgestore.md +53 -0
  13. package/agent-docs/provider-s3.md +270 -0
  14. package/agent-docs/remix.md +117 -0
  15. package/agent-docs/tanstack-start.md +99 -0
  16. package/agent-docs/troubleshooting.md +83 -0
  17. package/dist/adapters/astro/index.d.ts +2 -2
  18. package/dist/adapters/astro/index.d.ts.map +1 -1
  19. package/dist/adapters/astro/index.js +1 -2
  20. package/dist/adapters/dispatcher.d.ts +2 -3
  21. package/dist/adapters/dispatcher.d.ts.map +1 -1
  22. package/dist/adapters/dispatcher.js +17 -22
  23. package/dist/adapters/express/index.d.ts +2 -2
  24. package/dist/adapters/express/index.d.ts.map +1 -1
  25. package/dist/adapters/express/index.js +1 -5
  26. package/dist/adapters/fastify/index.d.ts +2 -2
  27. package/dist/adapters/fastify/index.d.ts.map +1 -1
  28. package/dist/adapters/fastify/index.js +1 -5
  29. package/dist/adapters/hono/index.d.ts +2 -2
  30. package/dist/adapters/hono/index.d.ts.map +1 -1
  31. package/dist/adapters/hono/index.js +1 -2
  32. package/dist/adapters/next/app/index.d.ts +2 -2
  33. package/dist/adapters/next/app/index.d.ts.map +1 -1
  34. package/dist/adapters/next/app/index.js +1 -2
  35. package/dist/adapters/next/pages/index.d.ts +2 -2
  36. package/dist/adapters/next/pages/index.d.ts.map +1 -1
  37. package/dist/adapters/next/pages/index.js +1 -5
  38. package/dist/adapters/remix/index.d.ts +2 -2
  39. package/dist/adapters/remix/index.d.ts.map +1 -1
  40. package/dist/adapters/remix/index.js +1 -2
  41. package/dist/adapters/shared.d.ts +45 -67
  42. package/dist/adapters/shared.d.ts.map +1 -1
  43. package/dist/adapters/shared.js +60 -97
  44. package/dist/adapters/start/index.d.ts +2 -2
  45. package/dist/adapters/start/index.d.ts.map +1 -1
  46. package/dist/adapters/start/index.js +1 -2
  47. package/dist/core/client/bucketClient.d.ts +0 -1
  48. package/dist/core/client/bucketClient.d.ts.map +1 -1
  49. package/dist/core/client/bucketClient.js +6 -28
  50. package/dist/core/client/index.d.ts +29 -26
  51. package/dist/core/client/index.d.ts.map +1 -1
  52. package/dist/core/client/index.js +2 -3
  53. package/dist/core/index.d.ts +2 -20
  54. package/dist/core/index.d.ts.map +1 -1
  55. package/dist/core/index.js +2 -13
  56. package/dist/core/provider.d.ts +11 -1
  57. package/dist/core/provider.d.ts.map +1 -1
  58. package/dist/core/provider.js +21 -1
  59. package/dist/core/router.d.ts +25 -0
  60. package/dist/core/router.d.ts.map +1 -0
  61. package/dist/core/router.js +49 -0
  62. package/dist/core/routerRules.d.ts +1 -1
  63. package/dist/index.d.ts +2 -2
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +1 -2
  66. package/dist/providers/azure-blob/index.d.ts +7 -0
  67. package/dist/providers/azure-blob/index.d.ts.map +1 -1
  68. package/dist/providers/azure-blob/index.js +7 -0
  69. package/dist/providers/edgestore/index.d.ts +10 -11
  70. package/dist/providers/edgestore/index.d.ts.map +1 -1
  71. package/dist/providers/edgestore/index.js +26 -15
  72. package/dist/providers/s3/backendUpload.d.ts +13 -0
  73. package/dist/providers/s3/backendUpload.d.ts.map +1 -0
  74. package/dist/providers/s3/backendUpload.js +97 -0
  75. package/dist/providers/s3/index.d.ts +57 -93
  76. package/dist/providers/s3/index.d.ts.map +1 -1
  77. package/dist/providers/s3/index.js +241 -90
  78. package/dist/providers/s3/keys.d.ts +10 -0
  79. package/dist/providers/s3/keys.d.ts.map +1 -0
  80. package/dist/providers/s3/keys.js +40 -0
  81. package/dist/providers/s3/multipart.d.ts +25 -0
  82. package/dist/providers/s3/multipart.d.ts.map +1 -0
  83. package/dist/providers/s3/multipart.js +132 -0
  84. package/dist/providers/s3/objectHeaders.d.ts +4 -0
  85. package/dist/providers/s3/objectHeaders.d.ts.map +1 -0
  86. package/dist/providers/s3/objectHeaders.js +22 -0
  87. package/dist/providers/s3/options.d.ts +107 -0
  88. package/dist/providers/s3/options.d.ts.map +1 -0
  89. package/dist/version.d.ts +1 -1
  90. package/package.json +7 -5
  91. package/src/adapters/astro/index.ts +3 -4
  92. package/src/adapters/dispatcher.ts +21 -30
  93. package/src/adapters/express/index.ts +3 -9
  94. package/src/adapters/fastify/index.ts +3 -9
  95. package/src/adapters/hono/index.ts +3 -4
  96. package/src/adapters/next/app/index.ts +3 -4
  97. package/src/adapters/next/pages/index.ts +3 -9
  98. package/src/adapters/remix/index.ts +3 -4
  99. package/src/adapters/shared.ts +90 -163
  100. package/src/adapters/start/index.ts +3 -4
  101. package/src/core/client/bucketClient.ts +10 -41
  102. package/src/core/client/index.ts +32 -48
  103. package/src/core/index.ts +2 -36
  104. package/src/core/provider.ts +28 -5
  105. package/src/core/router.ts +97 -0
  106. package/src/index.ts +1 -3
  107. package/src/providers/azure-blob/index.ts +2 -0
  108. package/src/providers/edgestore/index.ts +28 -14
  109. package/src/providers/s3/backendUpload.ts +117 -0
  110. package/src/providers/s3/index.ts +302 -223
  111. package/src/providers/s3/keys.ts +59 -0
  112. package/src/providers/s3/multipart.ts +196 -0
  113. package/src/providers/s3/objectHeaders.ts +23 -0
  114. package/src/providers/s3/options.ts +125 -0
  115. package/src/version.ts +1 -1
@@ -0,0 +1,270 @@
1
+ # S3
2
+
3
+ Source: https://next.edgestore.dev/docs/providers/s3
4
+
5
+ The S3 provider supports direct browser uploads, automatic multipart uploads,
6
+ backend uploads, signed downloads, object lookup, and deletion. Your application
7
+ owns the bucket's IAM, CORS, read permissions, and lifecycle configuration.
8
+
9
+ ## Setup
10
+
11
+ Install the optional AWS dependencies:
12
+
13
+ Packages to install (use the application’s package manager):
14
+
15
+ ```text
16
+ @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
17
+ ```
18
+
19
+ Configure the provider on your router:
20
+
21
+ Example: title="src/server/edgestore.ts"
22
+
23
+ ```ts
24
+ import { initEdgeStore } from '@edgestore/server';
25
+ import { s3 } from '@edgestore/server/providers/s3';
26
+
27
+ const es = initEdgeStore.create();
28
+ export const router = es.router({
29
+ documents: es.fileBucket().accessControl('private'),
30
+ }).provider(s3({
31
+ region: 'us-east-1',
32
+ bucketName: 'my-storage-bucket',
33
+ }));
34
+
35
+ export type EdgeStoreRouter = typeof router;
36
+ ```
37
+
38
+ Pass `router` to your framework adapter as its `router` option.
39
+ Set `EDGE_STORE_JWT_SECRET` to a stable random secret, for example one generated
40
+ with `openssl rand -base64 32`. All application instances must share it.
41
+
42
+ Credentials use the AWS SDK's default provider chain, including environment
43
+ variables, shared config, and instance/task roles. You can also pass
44
+ `credentials` with an AWS credentials object or provider function.
45
+
46
+ | Option | Default / environment variable |
47
+ | ---------------------------- | ---------------------------------------------------------------------------------------- |
48
+ | `bucketName` | `ES_AWS_BUCKET_NAME` |
49
+ | `region` | `ES_AWS_REGION`, then AWS SDK region resolution |
50
+ | `endpoint` | `ES_AWS_ENDPOINT` |
51
+ | `forcePathStyle` | `ES_AWS_FORCE_PATH_STYLE === 'true'` |
52
+ | `baseUrl` | `EDGE_STORE_BASE_URL`, otherwise the storage URL |
53
+ | `uploadUrlExpiresIn` | 3600 seconds |
54
+ | `signedUrlExpiresIn` | 3600 seconds |
55
+ | `multipart.thresholdBytes` | 100 MiB |
56
+ | `multipart.partSizeBytes` | 16 MiB; minimum 5 MiB |
57
+ | `multipart.sessionExpiresIn` | 86400 seconds |
58
+ | `jwtSecret` | Multipart signing override; otherwise `EDGE_STORE_JWT_SECRET` or `EDGE_STORE_SECRET_KEY` |
59
+
60
+ Setting `jwtSecret` does not replace the required environment secret.
61
+ Signed URL lifetimes must be between 1 and 604800 seconds; temporary AWS
62
+ credentials can expire sooner.
63
+
64
+ ## Paths and filenames
65
+
66
+ The default key is the logical router bucket, an optional `_public` segment,
67
+ router path values, and a generated UUID plus extension:
68
+
69
+ ```text
70
+ documents/acme/generated-id.pdf
71
+ avatars/_public/user-123/generated-id.webp
72
+ ```
73
+
74
+ Use the router's `.path(...)` for context/input-derived folders. Use
75
+ `options: { manualFileName: file.name }` on a browser upload to preserve the
76
+ original filename. A repeated key overwrites the existing object (or creates a
77
+ new version if bucket versioning is enabled). Generated names avoid accidental
78
+ collisions; use manual names only when overwrite behavior is intentional.
79
+
80
+ For custom layouts, the async `path` callback can rewrite everything beneath the
81
+ logical bucket prefix:
82
+
83
+ ```ts
84
+ s3({
85
+ path: ({ defaultPath }) => defaultPath.replace(/^_public\//, ''),
86
+ });
87
+ ```
88
+
89
+ The callback receives `edgestoreBucketName`, `fileInfo` (including router path
90
+ values and metadata), and `defaultPath`. It cannot remove the logical bucket
91
+ prefix or use `.` / `..` path segments. For example, it can produce
92
+ `documents/acme/invoices/report.pdf`, but cannot place that file outside
93
+ `documents/`.
94
+
95
+ S3 uploads return a `key`. Save it in your database for backend lookup,
96
+ deletion, and signed URL creation, which accept `{ key }` or `{ url }`. Key
97
+ references continue to work when you change CDN domains. URL references must
98
+ match the currently configured `baseUrl`.
99
+
100
+ ## Large files and cancellation
101
+
102
+ Keep using the normal React `upload({ file, onProgressChange, signal })` call.
103
+ Files above the threshold automatically use multipart uploads with retries.
104
+ Use `AbortController` to cancel an upload.
105
+
106
+ ```ts
107
+ s3({
108
+ multipart: {
109
+ thresholdBytes: 100 * 1024 * 1024,
110
+ partSizeBytes: 16 * 1024 * 1024,
111
+ },
112
+ });
113
+ ```
114
+
115
+ The browser requests part URLs as it reaches each part and refreshes a rejected
116
+ URL once, so `uploadUrlExpiresIn` only needs to cover one part transfer. A
117
+ multipart session can request URLs, complete, or abort until
118
+ `multipart.sessionExpiresIn` passes. Uploads do not resume across page reloads.
119
+
120
+ Backend uploads send up to four parts at a time through your S3 client, so the
121
+ client's retry and transport settings apply.
122
+
123
+ Configure an S3 lifecycle rule to clean up incomplete uploads left by browser
124
+ shutdowns, network loss, or failed cancellation:
125
+
126
+ ```json
127
+ {
128
+ "Rules": [{
129
+ "ID": "abort-incomplete-uploads",
130
+ "Status": "Enabled",
131
+ "Filter": { "Prefix": "" },
132
+ "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 1 }
133
+ }]
134
+ }
135
+ ```
136
+
137
+ Merge this rule into your existing lifecycle configuration.
138
+
139
+ ## Private downloads
140
+
141
+ Keep the physical bucket private and use `.accessControl('private')`. Your
142
+ backend must authorize the caller before issuing a signed URL:
143
+
144
+ ```ts
145
+ // After checking that the current user can read this database file record:
146
+ const download = await router.client.documents.createSignedUrl({
147
+ url: { key: storedFileKey },
148
+ expiresIn: 300,
149
+ });
150
+ // Send download.signedUrl to the browser.
151
+ ```
152
+
153
+ The backend client is privileged; it does not authenticate application users for
154
+ you. Cookie-based access-control schemas are unsupported and rejected at adapter
155
+ initialization. A logical bucket's public/private setting does not configure S3
156
+ permissions. `_public` is a naming convention that you can use in infrastructure
157
+ rules. For example, an S3 policy can grant public reads to
158
+ `avatars/_public/*`, or a CloudFront behavior can allow public viewing of that
159
+ path while other behaviors require signed access. The prefix alone grants no
160
+ access. With CloudFront origin access control, the S3 bucket can remain private.
161
+ If you customize the path, update your access rules to match.
162
+
163
+ Add `.autoSignedUrls({ expiresIn: 300 })` to a private router bucket to receive a
164
+ signed read URL with upload results. Save the key or canonical URL, not the
165
+ expiring signed URL. Request a fresh signed URL when needed; the client does not
166
+ refresh private download URLs automatically. Browser upload read URLs begin
167
+ expiring when the upload is requested, so allow enough time for the transfer.
168
+
169
+ For public files, configure public reads or a CDN separately. `baseUrl` changes
170
+ canonical file URLs, but signed downloads still use the S3 endpoint; it does not
171
+ create CloudFront signed URLs.
172
+
173
+ ## Backend uploads and object settings
174
+
175
+ Use the same configured router for generated files and background jobs:
176
+
177
+ ```ts
178
+ const uploaded = await router.client.documents.upload({
179
+ content: {
180
+ blob: new Blob([pdfBytes], { type: 'application/pdf' }),
181
+ extension: 'pdf',
182
+ },
183
+ options: { manualFileName: 'report.pdf' },
184
+ });
185
+ ```
186
+
187
+ Backend uploads use the same path, object settings, and multipart configuration.
188
+ They accept Blob, text, or URL content. Streaming sources are not supported.
189
+
190
+ Use `objectOptions` for cache policy, download filenames, metadata, tags, storage
191
+ class, and S3/KMS encryption settings. It accepts a static object or an async
192
+ callback with the same arguments as `path`:
193
+
194
+ ```ts
195
+ s3({
196
+ objectOptions: ({ fileInfo }) => ({
197
+ CacheControl: 'private, max-age=60',
198
+ ContentDisposition: 'attachment',
199
+ Metadata: { category: fileInfo.metadata.category ?? 'general' },
200
+ }),
201
+ });
202
+ ```
203
+
204
+ `ContentType` comes from the file's MIME type. File contents are not inspected.
205
+
206
+ For custom AWS retry/transport behavior, pass `client: new S3Client(...)`.
207
+ For browser uploads, configure that client with
208
+ `requestChecksumCalculation: 'WHEN_REQUIRED'`.
209
+ When injecting a client with a custom endpoint, also set `baseUrl` explicitly.
210
+
211
+ ## IAM and CORS
212
+
213
+ A baseline application role policy is below. Replace the bucket name and narrow
214
+ object prefixes to your logical buckets where appropriate. KMS encryption needs
215
+ additional key permissions.
216
+
217
+ ```json
218
+ {
219
+ "Version": "2012-10-17",
220
+ "Statement": [{
221
+ "Effect": "Allow",
222
+ "Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:AbortMultipartUpload"],
223
+ "Resource": "arn:aws:s3:::my-storage-bucket/*"
224
+ }]
225
+ }
226
+ ```
227
+
228
+ Configure bucket CORS for your actual application origins. Exposing `ETag` is
229
+ required for browser multipart completion:
230
+
231
+ ```json
232
+ [{
233
+ "AllowedOrigins": ["http://localhost:3000", "https://app.example.com"],
234
+ "AllowedMethods": ["PUT", "GET", "HEAD"],
235
+ "AllowedHeaders": ["*"],
236
+ "ExposeHeaders": ["ETag"],
237
+ "MaxAgeSeconds": 3600
238
+ }]
239
+ ```
240
+
241
+ ## S3-compatible services
242
+
243
+ For local MinIO:
244
+
245
+ ```ts
246
+ s3({
247
+ bucketName: 'edgestore',
248
+ region: 'us-east-1',
249
+ endpoint: 'http://localhost:9000',
250
+ forcePathStyle: true,
251
+ });
252
+ ```
253
+
254
+ The endpoint must be reachable from both the application server and browser.
255
+ Set `baseUrl` explicitly for custom domains or virtual-hosted endpoint layouts.
256
+ S3-compatible services may differ in support for KMS, storage classes, tags,
257
+ checksums, and lifecycle policies; only enable settings your service supports.
258
+
259
+ ## Limitations
260
+
261
+ * `temporary` and `replaceTargetUrl` are rejected. Track application-owned files
262
+ in your database and delete old files after successful replacement.
263
+ * Confirmation, listing/filtering, restore, and provider-generated thumbnails are
264
+ unsupported. Thumbnail options do not generate thumbnails.
265
+ * Router path/metadata values are returned at upload time but are not persisted
266
+ as an EdgeStore index. `get()` returns key, URL, size, and S3 timestamps. Persist
267
+ application metadata in your database or explicitly set S3 `Metadata`.
268
+ * No collision-prevention mode, automatic CDN invalidation, or version-specific
269
+ object references. Standard S3 overwrite/delete and versioning rules apply.
270
+ * Browser multipart cleanup is best effort, not a substitute for lifecycle rules.
@@ -0,0 +1,117 @@
1
+ # Remix / React Router
2
+
3
+ Source: https://next.edgestore.dev/docs/adapters/remix
4
+
5
+ Use the Remix adapter with Remix or React Router framework mode. A client-only
6
+ React Router application needs a separate backend; this route runs on the server.
7
+
8
+ ## Setup
9
+
10
+ ### Install
11
+
12
+ Packages to install (use the application’s package manager):
13
+
14
+ ```text
15
+ @edgestore/server @edgestore/react
16
+ ```
17
+
18
+ ### Environment variables
19
+
20
+ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/) to the backend env file:
21
+
22
+ Example: title=".env"
23
+
24
+ ```sh
25
+ EDGE_STORE_ACCESS_KEY=your-access-key
26
+ EDGE_STORE_SECRET_KEY=your-secret-key
27
+ ```
28
+
29
+ > WARNING
30
+ >
31
+ > Add `.env` to `.gitignore`.
32
+
33
+ ### Backend
34
+
35
+ Create the EdgeStore API route:
36
+
37
+ Example: title="app/routes/api/edgestore.ts"
38
+
39
+ ```ts
40
+ import { initEdgeStore } from '@edgestore/server';
41
+ import { createEdgeStoreRemixHandler } from '@edgestore/server/adapters/remix';
42
+
43
+ const es = initEdgeStore.create();
44
+
45
+ const router = es.router({
46
+ publicFiles: es.fileBucket(),
47
+ });
48
+
49
+ export type EdgeStoreRouter = typeof router;
50
+
51
+ const handler = createEdgeStoreRemixHandler({
52
+ router,
53
+ });
54
+
55
+ export { handler as loader, handler as action };
56
+ ```
57
+
58
+ For React Router framework mode, add the endpoint to your existing routes file:
59
+
60
+ Example: title="app/routes.ts"
61
+
62
+ ```ts
63
+ import { index, route, type RouteConfig } from '@react-router/dev/routes';
64
+
65
+ export default [
66
+ index('routes/home.tsx'),
67
+ // [!code ++]
68
+ route('api/edgestore/*', 'routes/api/edgestore.ts'),
69
+ ] satisfies RouteConfig;
70
+ ```
71
+
72
+ For Remix v2's default file-based routing, put the same handler in
73
+ `app/routes/api.edgestore.$.ts` instead. For custom routing, see
74
+ [Remix route conventions](https://v2.remix.run/docs/file-conventions/routes/)
75
+ and [React Router routing](https://reactrouter.com/start/framework/routing).
76
+
77
+ ### Frontend
78
+
79
+ Create the React provider:
80
+
81
+ Example: title="app/lib/edgestore.ts"
82
+
83
+ ```tsx
84
+ import { createEdgeStoreProvider } from '@edgestore/react';
85
+ import type { EdgeStoreRouter } from '~/routes/api/edgestore';
86
+
87
+ const { EdgeStoreProvider, useEdgeStore } =
88
+ createEdgeStoreProvider<EdgeStoreRouter>();
89
+
90
+ export { EdgeStoreProvider, useEdgeStore };
91
+ ```
92
+
93
+ Point the type-only import at your actual route module; for the Remix filename
94
+ above, use `~/routes/api.edgestore.$`.
95
+
96
+ Wrap the root component with the provider:
97
+
98
+ Example: title="app/root.tsx"
99
+
100
+ ```tsx
101
+ // [!code ++]
102
+ import { EdgeStoreProvider } from '~/lib/edgestore';
103
+
104
+ // ...
105
+
106
+ export default function App() {
107
+ return (
108
+ <EdgeStoreProvider>
109
+ <Outlet />
110
+ </EdgeStoreProvider>
111
+ );
112
+ }
113
+ ```
114
+
115
+ ## Usage
116
+
117
+ See [Quick start](https://next.edgestore.dev/docs/quick-start) for the upload UI.
@@ -0,0 +1,99 @@
1
+ # TanStack Start
2
+
3
+ Source: https://next.edgestore.dev/docs/adapters/tanstack-start
4
+
5
+ ## Setup
6
+
7
+ ### Install
8
+
9
+ Packages to install (use the application’s package manager):
10
+
11
+ ```text
12
+ @edgestore/server @edgestore/react
13
+ ```
14
+
15
+ ### Environment variables
16
+
17
+ Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/) to the backend env file:
18
+
19
+ Example: title=".env.local"
20
+
21
+ ```sh
22
+ EDGE_STORE_ACCESS_KEY=your-access-key
23
+ EDGE_STORE_SECRET_KEY=your-secret-key
24
+ ```
25
+
26
+ > WARNING
27
+ >
28
+ > Use the app's existing env file, or `.env.local` for a new app. Keep it gitignored.
29
+
30
+ ### Backend
31
+
32
+ Create the EdgeStore API route:
33
+
34
+ Example: title="src/routes/api/edgestore.$.ts"
35
+
36
+ ```ts
37
+ import { initEdgeStore } from '@edgestore/server';
38
+ import { createEdgeStoreStartHandler } from '@edgestore/server/adapters/start';
39
+ import { createFileRoute } from '@tanstack/react-router';
40
+
41
+ const es = initEdgeStore.create();
42
+ const router = es.router({
43
+ publicFiles: es.fileBucket(),
44
+ });
45
+
46
+ export type EdgeStoreRouter = typeof router;
47
+
48
+ const handler = createEdgeStoreStartHandler({
49
+ router,
50
+ });
51
+
52
+ export const Route = createFileRoute('/api/edgestore/$')({
53
+ server: {
54
+ handlers: {
55
+ GET: handler,
56
+ POST: handler,
57
+ },
58
+ },
59
+ });
60
+ ```
61
+
62
+ ### Frontend
63
+
64
+ Create the React provider:
65
+
66
+ Example: title="src/utils/edgestore.ts"
67
+
68
+ ```tsx
69
+ import { createEdgeStoreProvider } from '@edgestore/react';
70
+ import { type EdgeStoreRouter } from '../routes/api/edgestore.$';
71
+
72
+ const { EdgeStoreProvider, useEdgeStore } =
73
+ createEdgeStoreProvider<EdgeStoreRouter>();
74
+
75
+ export { EdgeStoreProvider, useEdgeStore };
76
+ ```
77
+
78
+ Wrap your app with the provider:
79
+
80
+ Example: title="src/routes/\_\_root.tsx"
81
+
82
+ ```tsx
83
+ // [!code ++]
84
+ import { EdgeStoreProvider } from '~/utils/edgestore';
85
+
86
+ // ...
87
+
88
+ function RootComponent() {
89
+ return (
90
+ <EdgeStoreProvider>
91
+ <Outlet />
92
+ </EdgeStoreProvider>
93
+ );
94
+ }
95
+ ```
96
+
97
+ ## Usage
98
+
99
+ See [Quick start](https://next.edgestore.dev/docs/quick-start) for the upload UI.
@@ -0,0 +1,83 @@
1
+ # Troubleshooting
2
+
3
+ Source: https://next.edgestore.dev/docs/troubleshooting
4
+
5
+ ## Ask your agent to debug it
6
+
7
+ Read <https://edgestore.dev/docs/troubleshooting.md> and inspect my existing
8
+ EdgeStore integration. Explain the cause before making changes.
9
+
10
+ Problem:
11
+
12
+ \[Describe the problem]
13
+
14
+ Include the error message and steps to reproduce it.
15
+
16
+ ## Route not found or method not allowed
17
+
18
+ Open the handler's health endpoint. With the default Next.js route it is
19
+ <http://localhost:3000/api/edgestore/health>.
20
+ Use your backend origin and mounted path for other adapters.
21
+
22
+ For a 404 or 405, check the catch-all route and GET/POST exports. Match the React
23
+ provider's `basePath` to the mounted endpoint, including any proxy prefix.
24
+
25
+ ## Credentials or access denied
26
+
27
+ Confirm the backend loads the expected env file before creating the storage
28
+ provider, and that the keys belong to the intended project.
29
+
30
+ For protected buckets, check the application's authentication context and access
31
+ rules.
32
+
33
+ ## Browser upload failures
34
+
35
+ Check the browser console for errors and the failing request and response in the
36
+ Network panel, then use
37
+ [Error handling](https://next.edgestore.dev/docs/error-handling) to identify validation, size, or access
38
+ errors. Confirm that the React provider wraps the upload component.
39
+
40
+ For separate frontend and backend origins, allow the intended frontend origin in
41
+ CORS and check the adapter's cookie and deployment requirements.
42
+
43
+ ## Enable server debug logging
44
+
45
+ Enable [debug logging](https://next.edgestore.dev/docs/logging) to inspect server-side failures. Debug output
46
+ includes application context and cookies. Remove those values before sharing logs.
47
+
48
+ ## Inspect the application with the CLI
49
+
50
+ ```sh
51
+ edgestore --cwd <app> agent context --json
52
+ edgestore --cwd <app> doctor --offline --json
53
+ ```
54
+
55
+ Use the backend directory for server checks in a split workspace. `agent context`
56
+ reports installed versions and local references. `doctor --offline` inspects
57
+ configuration without authenticating or running the application.
58
+
59
+ ## Try an example app
60
+
61
+ Run an [example close to your framework](https://github.com/edgestorejs/edgestore/tree/main/examples)
62
+ to compare with your application.
63
+
64
+ For Next.js:
65
+
66
+ ```sh
67
+ npx degit edgestorejs/edgestore/examples/next-basic#main edgestore-example
68
+ cd edgestore-example
69
+ npm install
70
+ ```
71
+
72
+ Add your EdgeStore keys to `.env.local` as shown in
73
+ [Quick start](https://next.edgestore.dev/docs/quick-start#environment-variables), then run:
74
+
75
+ ```sh
76
+ npm run dev
77
+ ```
78
+
79
+ ## Still blocked?
80
+
81
+ Ask in [Discord](https://discord.gg/HvrnhRTfgQ) or
82
+ [open an issue](https://github.com/edgestorejs/edgestore/issues) with your framework,
83
+ installed EdgeStore versions, and the error.
@@ -2,9 +2,9 @@ import { type AnyContext } from '@edgestore/shared';
2
2
  import type { APIContext } from 'astro';
3
3
  import { type LogLevel } from '../../libs/logger.js';
4
4
  import { type CreateContextConfig } from '../dispatcher.js';
5
- import type { CookieConfig, HandlerEdgeStore } from '../shared.js';
5
+ import type { CookieConfig, HandlerRouter } from '../shared.js';
6
6
  export type Config<TCtx extends AnyContext> = {
7
- edgestore: HandlerEdgeStore<TCtx>;
7
+ router: HandlerRouter<TCtx>;
8
8
  logLevel?: LogLevel;
9
9
  cookieConfig?: CookieConfig;
10
10
  } & CreateContextConfig<TCtx, APIContext>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/astro/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEhE,MAAM,MAAM,MAAM,CAAC,IAAI,SAAS,UAAU,IAAI;IAC5C,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,GAAG,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAE1C,wBAAgB,2BAA2B,CAAC,IAAI,SAAS,UAAU,EACjE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAKN,SAAS,UAAU,uBAgBlC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/astro/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,MAAM,MAAM,CAAC,IAAI,SAAS,UAAU,IAAI;IAC5C,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,GAAG,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAE1C,wBAAgB,2BAA2B,CAAC,IAAI,SAAS,UAAU,EACjE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAKN,SAAS,UAAU,uBAelC"}
@@ -8,13 +8,12 @@ function createEdgeStoreAstroHandler(config) {
8
8
  const { request } = context;
9
9
  const url = new URL(request.url);
10
10
  return await dispatchEdgeStoreRequest({
11
- edgestore: config.edgestore,
11
+ router: config.router,
12
12
  logger: log,
13
13
  cookieConfig: config.cookieConfig,
14
14
  request: {
15
15
  pathname: url.pathname,
16
16
  readJson: ()=>request.json(),
17
- getQuery: (name)=>url.searchParams.get(name) ?? undefined,
18
17
  cookieHeader: request.headers.get('cookie') ?? undefined,
19
18
  createContext: ()=>resolveContext(config, context)
20
19
  }
@@ -1,10 +1,9 @@
1
1
  import { type AnyContext, type MaybePromise } from '@edgestore/shared';
2
2
  import type { LoggerLike } from '../libs/logger.js';
3
- import { type CookieConfig, type HandlerEdgeStore } from './shared.js';
3
+ import { type CookieConfig, type HandlerRouter } from './shared.js';
4
4
  export type EdgeStoreDispatchRequest<TCtx extends AnyContext> = {
5
5
  pathname: string;
6
6
  readJson: () => Promise<unknown>;
7
- getQuery: (name: string) => string | undefined;
8
7
  cookieHeader?: string;
9
8
  cookies?: Readonly<Record<string, string | undefined>>;
10
9
  createContext: () => MaybePromise<TCtx>;
@@ -16,7 +15,7 @@ export type CreateContextConfig<TCtx extends AnyContext, TOptions> = TCtx extend
16
15
  };
17
16
  export declare function resolveContext<TCtx extends AnyContext, TOptions>(config: object, options: TOptions): MaybePromise<TCtx>;
18
17
  export declare function dispatchEdgeStoreRequest<TCtx extends AnyContext>(params: {
19
- edgestore: HandlerEdgeStore<TCtx>;
18
+ router: HandlerRouter<TCtx>;
20
19
  request: EdgeStoreDispatchRequest<TCtx>;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