@edgestore/server 1.0.0-next.4 → 1.0.0-rc.6

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 (129) hide show
  1. package/README.md +2 -8
  2. package/agent-docs/README.md +1 -1
  3. package/agent-docs/astro.md +3 -9
  4. package/agent-docs/backend-client.md +16 -29
  5. package/agent-docs/configuration.md +41 -10
  6. package/agent-docs/express.md +3 -9
  7. package/agent-docs/fastify.md +3 -9
  8. package/agent-docs/hono.md +3 -9
  9. package/agent-docs/next.md +5 -17
  10. package/agent-docs/provider-azure-blob.md +150 -59
  11. package/agent-docs/provider-custom.md +42 -13
  12. package/agent-docs/provider-edgestore.md +9 -9
  13. package/agent-docs/provider-s3.md +224 -119
  14. package/agent-docs/remix.md +3 -9
  15. package/agent-docs/tanstack-start.md +3 -9
  16. package/dist/adapters/astro/index.d.ts +2 -2
  17. package/dist/adapters/astro/index.d.ts.map +1 -1
  18. package/dist/adapters/astro/index.js +1 -2
  19. package/dist/adapters/dispatcher.d.ts +2 -3
  20. package/dist/adapters/dispatcher.d.ts.map +1 -1
  21. package/dist/adapters/dispatcher.js +17 -22
  22. package/dist/adapters/express/index.d.ts +2 -2
  23. package/dist/adapters/express/index.d.ts.map +1 -1
  24. package/dist/adapters/express/index.js +1 -5
  25. package/dist/adapters/fastify/index.d.ts +2 -2
  26. package/dist/adapters/fastify/index.d.ts.map +1 -1
  27. package/dist/adapters/fastify/index.js +1 -5
  28. package/dist/adapters/hono/index.d.ts +2 -2
  29. package/dist/adapters/hono/index.d.ts.map +1 -1
  30. package/dist/adapters/hono/index.js +1 -2
  31. package/dist/adapters/next/app/index.d.ts +2 -2
  32. package/dist/adapters/next/app/index.d.ts.map +1 -1
  33. package/dist/adapters/next/app/index.js +1 -2
  34. package/dist/adapters/next/pages/index.d.ts +2 -2
  35. package/dist/adapters/next/pages/index.d.ts.map +1 -1
  36. package/dist/adapters/next/pages/index.js +1 -5
  37. package/dist/adapters/remix/index.d.ts +2 -2
  38. package/dist/adapters/remix/index.d.ts.map +1 -1
  39. package/dist/adapters/remix/index.js +1 -2
  40. package/dist/adapters/shared.d.ts +31 -143
  41. package/dist/adapters/shared.d.ts.map +1 -1
  42. package/dist/adapters/shared.js +115 -197
  43. package/dist/adapters/start/index.d.ts +2 -2
  44. package/dist/adapters/start/index.d.ts.map +1 -1
  45. package/dist/adapters/start/index.js +1 -2
  46. package/dist/core/client/bucketClient.d.ts +0 -1
  47. package/dist/core/client/bucketClient.d.ts.map +1 -1
  48. package/dist/core/client/bucketClient.js +6 -28
  49. package/dist/core/client/index.d.ts +25 -26
  50. package/dist/core/client/index.d.ts.map +1 -1
  51. package/dist/core/client/index.js +2 -3
  52. package/dist/core/provider.d.ts +11 -2
  53. package/dist/core/provider.d.ts.map +1 -1
  54. package/dist/core/provider.js +20 -3
  55. package/dist/core/router.d.ts +25 -0
  56. package/dist/core/router.d.ts.map +1 -0
  57. package/dist/core/router.js +49 -0
  58. package/dist/core/routerRules.d.ts +1 -1
  59. package/dist/index.d.ts +4 -2
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +3 -3
  62. package/dist/providers/azure-blob/blocks.d.ts +48 -0
  63. package/dist/providers/azure-blob/blocks.d.ts.map +1 -0
  64. package/dist/providers/azure-blob/blocks.js +126 -0
  65. package/dist/providers/azure-blob/index.d.ts +81 -49
  66. package/dist/providers/azure-blob/index.d.ts.map +1 -1
  67. package/dist/providers/azure-blob/index.js +194 -105
  68. package/dist/providers/edgestore/index.d.ts +12 -32
  69. package/dist/providers/edgestore/index.d.ts.map +1 -1
  70. package/dist/providers/edgestore/index.js +34 -31
  71. package/dist/providers/s3/backendUpload.d.ts +10 -0
  72. package/dist/providers/s3/backendUpload.d.ts.map +1 -0
  73. package/dist/providers/s3/backendUpload.js +59 -0
  74. package/dist/providers/s3/index.d.ts +52 -97
  75. package/dist/providers/s3/index.d.ts.map +1 -1
  76. package/dist/providers/s3/index.js +221 -91
  77. package/dist/providers/s3/multipart.d.ts +23 -0
  78. package/dist/providers/s3/multipart.d.ts.map +1 -0
  79. package/dist/providers/s3/multipart.js +96 -0
  80. package/dist/providers/s3/objectHeaders.d.ts +4 -0
  81. package/dist/providers/s3/objectHeaders.d.ts.map +1 -0
  82. package/dist/providers/s3/objectHeaders.js +22 -0
  83. package/dist/providers/s3/options.d.ts +85 -0
  84. package/dist/providers/s3/options.d.ts.map +1 -0
  85. package/dist/providers/storage/multipartSession.d.ts +51 -0
  86. package/dist/providers/storage/multipartSession.d.ts.map +1 -0
  87. package/dist/providers/storage/multipartSession.js +83 -0
  88. package/dist/providers/storage/objectKeys.d.ts +41 -0
  89. package/dist/providers/storage/objectKeys.d.ts.map +1 -0
  90. package/dist/providers/storage/objectKeys.js +67 -0
  91. package/dist/providers/storage/transfer.d.ts +18 -0
  92. package/dist/providers/storage/transfer.d.ts.map +1 -0
  93. package/dist/providers/storage/transfer.js +69 -0
  94. package/dist/version.d.ts +1 -1
  95. package/dist/version.d.ts.map +1 -1
  96. package/package.json +5 -12
  97. package/src/adapters/astro/index.ts +3 -4
  98. package/src/adapters/dispatcher.ts +21 -30
  99. package/src/adapters/express/index.ts +3 -9
  100. package/src/adapters/fastify/index.ts +3 -9
  101. package/src/adapters/hono/index.ts +3 -4
  102. package/src/adapters/next/app/index.ts +3 -4
  103. package/src/adapters/next/pages/index.ts +3 -9
  104. package/src/adapters/remix/index.ts +3 -4
  105. package/src/adapters/shared.ts +166 -285
  106. package/src/adapters/start/index.ts +3 -4
  107. package/src/core/client/bucketClient.ts +10 -41
  108. package/src/core/client/index.ts +29 -49
  109. package/src/core/provider.ts +25 -10
  110. package/src/core/router.ts +97 -0
  111. package/src/index.ts +4 -11
  112. package/src/providers/azure-blob/blocks.ts +201 -0
  113. package/src/providers/azure-blob/index.ts +290 -170
  114. package/src/providers/edgestore/index.ts +38 -35
  115. package/src/providers/s3/backendUpload.ts +82 -0
  116. package/src/providers/s3/index.ts +279 -227
  117. package/src/providers/s3/multipart.ts +138 -0
  118. package/src/providers/s3/objectHeaders.ts +23 -0
  119. package/src/providers/s3/options.ts +102 -0
  120. package/src/providers/storage/multipartSession.ts +145 -0
  121. package/src/providers/storage/objectKeys.ts +106 -0
  122. package/src/providers/storage/transfer.ts +105 -0
  123. package/src/version.ts +1 -1
  124. package/core/index.d.ts +0 -1
  125. package/core/index.js +0 -1
  126. package/dist/core/index.d.ts +0 -22
  127. package/dist/core/index.d.ts.map +0 -1
  128. package/dist/core/index.js +0 -14
  129. package/src/core/index.ts +0 -43
@@ -7,13 +7,12 @@ implementation. The same provider instance powers the EdgeStore HTTP handler
7
7
  and the router-derived backend client:
8
8
 
9
9
  ```ts
10
- const configuredEdgeStore = createEdgeStore({
11
- router,
12
- provider: myProvider,
13
- });
10
+ const router = es.router({
11
+ files: es.fileBucket(),
12
+ }).provider(myProvider);
14
13
 
15
- createEdgeStoreNextHandler({ edgestore: configuredEdgeStore });
16
- configuredEdgeStore.client.files.get({ key: 'files/report.pdf' });
14
+ createEdgeStoreNextHandler({ router });
15
+ router.client.files.get({ key: 'files/report.pdf' });
17
16
  ```
18
17
 
19
18
  Method inputs are contextually typed. File references, cursors, returned file
@@ -41,7 +40,6 @@ const baseUrl = 'https://files.example.com';
41
40
 
42
41
  export const myProvider = defineProvider({
43
42
  name: 'my-storage',
44
- baseUrl,
45
43
  async init() {
46
44
  return {};
47
45
  },
@@ -56,7 +54,7 @@ export const myProvider = defineProvider({
56
54
  const key = storage.createKey({ bucketName, fileInfo });
57
55
  return {
58
56
  uploadUrl: await storage.signUpload(key),
59
- accessUrl: `${baseUrl}/${key}`,
57
+ url: `${baseUrl}/${key}`,
60
58
  };
61
59
  },
62
60
  },
@@ -82,6 +80,22 @@ export const myProvider = defineProvider({
82
80
  The resulting backend client exposes `get`, but not `upload`, `list`, or
83
81
  mutations, because those optional capabilities were not defined.
84
82
 
83
+ `init` runs when the browser initializes EdgeStore. Return `{}` unless the
84
+ browser must prepare access to your file origin before loading protected
85
+ files. In that case, return `clientInit` with the absolute URLs to request and
86
+ any headers to send; the browser calls each URL with credentials:
87
+
88
+ ```ts
89
+ async init({ ctx }) {
90
+ return {
91
+ clientInit: {
92
+ urls: ['https://files.example.com/_init'],
93
+ headers: { 'x-file-token': await createFileToken(ctx) },
94
+ },
95
+ };
96
+ },
97
+ ```
98
+
85
99
  ## Complete provider
86
100
 
87
101
  A complete provider can add direct backend uploads, pagination, mutations, and
@@ -116,7 +130,6 @@ const toFile = (object: Awaited<ReturnType<typeof storage.head>>) => ({
116
130
 
117
131
  export const myProvider = defineProvider({
118
132
  name: 'my-storage',
119
- baseUrl,
120
133
  async init() {
121
134
  return {};
122
135
  },
@@ -129,12 +142,15 @@ export const myProvider = defineProvider({
129
142
  return storage.createUploadPlan({ bucketName, fileInfo });
130
143
  },
131
144
  multipart: {
132
- async requestParts({ multipart, path }) {
133
- return storage.createUploadParts({ multipart, path });
145
+ async requestParts({ uploadId, key, parts }) {
146
+ return { parts: await storage.signUploadParts({ uploadId, key, parts }) };
134
147
  },
135
148
  async complete({ uploadId, key, parts }) {
136
149
  await storage.completeMultipart({ uploadId, key, parts });
137
150
  },
151
+ async abort({ uploadId, key }) {
152
+ await storage.abortMultipart({ uploadId, key });
153
+ },
138
154
  },
139
155
  async upload({ bucketName, fileInfo, source, signal, onProgress }) {
140
156
  const object = await storage.upload({
@@ -238,8 +254,21 @@ file reference or calculate counts.
238
254
 
239
255
  Multipart support is optional. A single-part provider defines only
240
256
  `uploads.request`. When `uploads.multipart` is present, `uploads.request` may
241
- return a multipart plan and EdgeStore exposes the matching part-request and
242
- completion routes.
257
+ return a multipart plan and EdgeStore exposes the matching part-request,
258
+ completion, and cancellation routes. The plan only needs signed URLs for the
259
+ first parts: the browser requests the rest through `requestParts` in batches as
260
+ it reaches them, and requests a fresh URL once when storage rejects one. The
261
+ browser calls `abort` after a failed or canceled transfer. Cleanup is best
262
+ effort, so storage lifecycle rules should still remove abandoned uploads.
263
+
264
+ A single-part plan can include `uploadHeaders`. The browser sends them with the
265
+ upload request, which lets a provider sign headers such as `Content-Type` or
266
+ storage metadata into the URL.
267
+
268
+ Set `uploads.supportedOptions` to reject upload options your storage cannot
269
+ honor. For example, `supportedOptions: { temporary: false }` removes
270
+ `temporary` from the browser and backend upload types, and EdgeStore rejects it
271
+ at runtime before calling the provider.
243
272
 
244
273
  `uploads.request` and `uploads.upload` remain separate because they perform
245
274
  different work: the former creates signed instructions for a browser transfer,
@@ -2,11 +2,12 @@
2
2
 
3
3
  Source: https://next.edgestore.dev/docs/providers/edgestore
4
4
 
5
- The hosted `edgestore()` provider uses EdgeStore API v2. Configure it together
6
- with your router, then pass that configured instance to the HTTP adapter.
5
+ The hosted EdgeStore provider uses API v2 and is the default for `es.router()`.
6
+ No provider configuration is needed when using environment credentials. Chain
7
+ `.provider(edgestore(options))` to supply custom credentials or an API URL.
7
8
 
8
9
  ```ts
9
- import { createEdgeStore, initEdgeStore } from '@edgestore/server';
10
+ import { initEdgeStore } from '@edgestore/server';
10
11
  import {
11
12
  createEdgeStoreNextHandler,
12
13
  type CreateContextOptions,
@@ -15,14 +16,13 @@ import {
15
16
  import { edgestore } from '@edgestore/server/providers/edgestore';
16
17
  import { z } from 'zod';
17
18
 
18
- const configuredEdgeStore = createEdgeStore({
19
- router,
20
- // [!code ++]
21
- provider: edgestore(),
22
- });
19
+ const es = initEdgeStore.context<Context>().create();
20
+ const router = es.router({
21
+ publicFiles: es.fileBucket(),
22
+ }).provider(edgestore());
23
23
 
24
24
  export default createEdgeStoreNextHandler<Context>({
25
- edgestore: configuredEdgeStore,
25
+ router,
26
26
  createContext,
27
27
  });
28
28
  ```
@@ -2,15 +2,13 @@
2
2
 
3
3
  Source: https://next.edgestore.dev/docs/providers/s3
4
4
 
5
- You can also use the EdgeStore package with your own AWS S3 bucket. You might want to do that in case you have strict company policies that require you to have all the data in your own AWS account.
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.
6
8
 
7
- You can also use the S3 provider with other S3-compatible storage services like [MinIO](https://min.io/).
9
+ ## Setup
8
10
 
9
- By using this provider, you will be able to use most of the basic features of EdgeStore. However, for some of the more advanced features like access control with protected files, you will have to create your own infrastructure and logic from scratch.
10
-
11
- ## Installation
12
-
13
- You need to install some peer dependencies to use this provider.
11
+ Install the optional AWS dependencies:
14
12
 
15
13
  Packages to install (use the application’s package manager):
16
14
 
@@ -18,149 +16,256 @@ Packages to install (use the application’s package manager):
18
16
  @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
19
17
  ```
20
18
 
21
- Then configure the provider together with the router and pass the resulting
22
- `configuredEdgeStore` instance to the adapter.
19
+ Configure the provider on your router:
20
+
21
+ Example: title="src/server/edgestore.ts"
23
22
 
24
23
  ```ts
25
- import { createEdgeStore, initEdgeStore } from '@edgestore/server';
26
- import {
27
- createEdgeStoreNextHandler,
28
- type CreateContextOptions,
29
- } from '@edgestore/server/adapters/next/pages';
30
- // [!code ++]
24
+ import { initEdgeStore } from '@edgestore/server';
31
25
  import { s3 } from '@edgestore/server/providers/s3';
32
- import { z } from 'zod';
33
26
 
34
- // ...
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
+ }));
35
34
 
36
- const configuredEdgeStore = createEdgeStore({
37
- router,
38
- // [!code ++]
39
- provider: s3(),
40
- });
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
41
 
42
- export default createEdgeStoreNextHandler<Context>({
43
- edgestore: configuredEdgeStore,
44
- createContext,
42
+ Pass `credentials` with an AWS credentials object or provider function. If it
43
+ is unset, `ES_AWS_ACCESS_KEY_ID` and `ES_AWS_SECRET_ACCESS_KEY` are used when
44
+ both are set; otherwise the AWS SDK's default provider chain applies, including
45
+ environment variables, shared config, and instance/task roles.
46
+
47
+ | Option | Default / environment variable |
48
+ | ---------------------------- | ---------------------------------------------------------------------------------------- |
49
+ | `bucketName` | `ES_AWS_BUCKET_NAME` |
50
+ | `region` | `ES_AWS_REGION`, then AWS SDK region resolution |
51
+ | `endpoint` | `ES_AWS_ENDPOINT` |
52
+ | `forcePathStyle` | `ES_AWS_FORCE_PATH_STYLE === 'true'` |
53
+ | `baseUrl` | `EDGE_STORE_BASE_URL`, otherwise the storage URL |
54
+ | `uploadUrlExpiresIn` | 3600 seconds |
55
+ | `signedUrlExpiresIn` | 3600 seconds |
56
+ | `multipart.thresholdBytes` | 100 MiB |
57
+ | `multipart.partSizeBytes` | 16 MiB; minimum 5 MiB |
58
+ | `multipart.sessionExpiresIn` | 86400 seconds |
59
+ | `jwtSecret` | Multipart signing override; otherwise `EDGE_STORE_JWT_SECRET` or `EDGE_STORE_SECRET_KEY` |
60
+
61
+ Setting `jwtSecret` does not replace the required environment secret.
62
+ Signed URL lifetimes must be between 1 and 604800 seconds; temporary AWS
63
+ credentials can expire sooner.
64
+
65
+ ## Paths and filenames
66
+
67
+ The default key is the logical router bucket, an optional `_public` segment,
68
+ router path values, and a generated UUID plus extension:
69
+
70
+ ```text
71
+ documents/acme/generated-id.pdf
72
+ avatars/_public/user-123/generated-id.webp
73
+ ```
74
+
75
+ Use the router's `.path(...)` for context/input-derived folders. Use
76
+ `options: { manualFileName: file.name }` on a browser upload to preserve the
77
+ original filename. A repeated key overwrites the existing object (or creates a
78
+ new version if bucket versioning is enabled). Generated names avoid accidental
79
+ collisions; use manual names only when overwrite behavior is intentional.
80
+
81
+ For custom layouts, the async `path` callback can rewrite everything beneath the
82
+ logical bucket prefix:
83
+
84
+ ```ts
85
+ s3({
86
+ path: ({ defaultPath }) => defaultPath.replace(/^_public\//, ''),
45
87
  });
46
88
  ```
47
89
 
48
- ## Options
90
+ The callback receives `edgestoreBucketName`, `fileInfo` (including router path
91
+ values and metadata), and `defaultPath`. It cannot remove the logical bucket
92
+ prefix or use `.` / `..` path segments. For example, it can produce
93
+ `documents/acme/invoices/report.pdf`, but cannot place that file outside
94
+ `documents/`.
95
+
96
+ S3 uploads return a `key`. Save it in your database for backend lookup,
97
+ deletion, and signed URL creation, which accept `{ key }` or `{ url }`. Key
98
+ references continue to work when you change CDN domains. URL references must
99
+ match the currently configured `baseUrl`.
100
+
101
+ ## Large files and cancellation
102
+
103
+ Keep using the normal React `upload({ file, onProgressChange, signal })` call.
104
+ Files above the threshold automatically use multipart uploads with retries.
105
+ Use `AbortController` to cancel an upload.
49
106
 
50
107
  ```ts
51
- export type S3ProviderOptions = {
52
- /**
53
- * AWS SDK credentials (or credentials provider) to use for S3 requests.
54
- *
55
- * If unset, the AWS SDK will use its default credential provider chain
56
- * (environment variables, shared config files, instance/task roles, etc).
57
- */
58
- credentials?: S3ClientConfig['credentials'];
59
- /**
60
- * AWS region to use.
61
- * Can also be set via the `ES_AWS_REGION` environment variable.
62
- */
63
- region?: string;
64
- /**
65
- * Name of the S3 bucket to use.
66
- * Can also be set via the `ES_AWS_BUCKET_NAME` environment variable.
67
- */
68
- bucketName?: string;
69
- /**
70
- * Custom endpoint for S3-compatible storage providers (e.g., MinIO).
71
- * Can also be set via the `ES_AWS_ENDPOINT` environment variable.
72
- */
73
- endpoint?: string;
74
- /**
75
- * Force path style for S3-compatible storage providers.
76
- * Can also be set via the `ES_AWS_FORCE_PATH_STYLE` environment variable.
77
- * Defaults to false for AWS S3, but should be true for most S3-compatible providers.
78
- */
79
- forcePathStyle?: boolean;
80
- /**
81
- * Base URL to use for accessing files.
82
- * Only needed if you are using a custom domain or cloudfront.
83
- *
84
- * Can also be set via the `EDGE_STORE_BASE_URL` environment variable.
85
- */
86
- baseUrl?: string;
87
- /**
88
- * Secret to use for encrypting JWT tokens.
89
- * Can be generated with `openssl rand -base64 32`.
90
- *
91
- * Can also be set via the `EDGE_STORE_JWT_SECRET` environment variable.
92
- */
93
- jwtSecret?: string;
94
- /**
95
- * Customizes the object path beneath the logical EdgeStore bucket prefix.
96
- *
97
- * The logical bucket prefix is always preserved so router authorization for
98
- * one bucket cannot access objects from another.
99
- */
100
- path?: (args: {
101
- edgestoreBucketName: string;
102
- fileInfo: FileInfo;
103
- defaultPath: string;
104
- }) => Promise<string> | string;
105
- };
108
+ s3({
109
+ multipart: {
110
+ thresholdBytes: 100 * 1024 * 1024,
111
+ partSizeBytes: 16 * 1024 * 1024,
112
+ },
113
+ });
106
114
  ```
107
115
 
108
- ## Customizing S3 Object Paths
116
+ The browser requests part URLs as it reaches each part and refreshes a rejected
117
+ URL once, so `uploadUrlExpiresIn` only needs to cover one part transfer. A
118
+ multipart session can request URLs, complete, or abort until
119
+ `multipart.sessionExpiresIn` passes. Uploads do not resume across page reloads.
109
120
 
110
- By default, the S3 provider uses the same path-generation logic as the hosted
111
- provider. The first object-key segment is always the logical EdgeStore router
112
- bucket. This lets multiple logical buckets safely share one physical S3 bucket:
121
+ Backend uploads send up to four parts at a time through your S3 client, so the
122
+ client's retry and transport settings apply.
113
123
 
114
- ```text
115
- documents/_public/acme/invoice.pdf
116
- avatars/_public/user-123/profile.png
124
+ Configure an S3 lifecycle rule to clean up incomplete uploads left by browser
125
+ shutdowns, network loss, or failed cancellation:
126
+
127
+ ```json
128
+ {
129
+ "Rules": [{
130
+ "ID": "abort-incomplete-uploads",
131
+ "Status": "Enabled",
132
+ "Filter": { "Prefix": "" },
133
+ "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 1 }
134
+ }]
135
+ }
117
136
  ```
118
137
 
119
- Use `path` to customize everything beneath that protected prefix. For example,
120
- this removes `_public` while keeping the remaining generated path:
138
+ Merge this rule into your existing lifecycle configuration.
121
139
 
122
- Example: title="src/server/edgestore.ts"
140
+ ## Private downloads
141
+
142
+ Keep the physical bucket private and use `.accessControl('private')`. Your
143
+ backend must authorize the caller before issuing a signed URL:
123
144
 
124
145
  ```ts
125
- const configuredEdgeStore = createEdgeStore({
126
- router,
127
- provider: s3({
128
- path: ({ defaultPath }) => {
129
- // `documents/_public/acme/invoice.pdf`
130
- // becomes `documents/acme/invoice.pdf`
131
- return defaultPath.replace(/^_public\//, '');
132
- },
133
- }),
146
+ // After checking that the current user can read this database file record:
147
+ const download = await router.client.documents.createSignedUrl({
148
+ url: { key: storedFileKey },
149
+ expiresIn: 300,
134
150
  });
151
+ // Send download.signedUrl to the browser.
152
+ ```
153
+
154
+ The backend client is privileged; it does not authenticate application users for
155
+ you. Cookie-based access-control schemas are unsupported and rejected at adapter
156
+ initialization. A logical bucket's public/private setting does not configure S3
157
+ permissions. `_public` is a naming convention that you can use in infrastructure
158
+ rules. For example, an S3 policy can grant public reads to
159
+ `avatars/_public/*`, or a CloudFront behavior can allow public viewing of that
160
+ path while other behaviors require signed access. The prefix alone grants no
161
+ access. With CloudFront origin access control, the S3 bucket can remain private.
162
+ If you customize the path, update your access rules to match.
163
+
164
+ Add `.autoSignedUrls({ expiresIn: 300 })` to a private router bucket to receive a
165
+ signed read URL with upload results. Save the key or canonical URL, not the
166
+ expiring signed URL. Request a fresh signed URL when needed; the client does not
167
+ refresh private download URLs automatically. Browser upload read URLs begin
168
+ expiring when the upload is requested, so allow enough time for the transfer.
169
+
170
+ For public files, configure public reads or a CDN separately. `baseUrl` changes
171
+ canonical file URLs, but signed downloads still use the S3 endpoint; it does not
172
+ create CloudFront signed URLs.
135
173
 
136
- const handler = createEdgeStoreNextHandler({
137
- edgestore: configuredEdgeStore,
138
- createContext,
174
+ ## Backend uploads and object settings
175
+
176
+ Use the same configured router for generated files and background jobs:
177
+
178
+ ```ts
179
+ const uploaded = await router.client.documents.upload({
180
+ content: {
181
+ blob: new Blob([pdfBytes], { type: 'application/pdf' }),
182
+ extension: 'pdf',
183
+ },
184
+ options: { manualFileName: 'report.pdf' },
139
185
  });
140
186
  ```
141
187
 
142
- The callback returns a path relative to the logical bucket and cannot escape
143
- that boundary. It also receives `edgestoreBucketName` and `fileInfo` when you
144
- need provider-specific naming logic.
188
+ Backend uploads use the same path, object settings, and multipart configuration.
189
+ They accept Blob, text, or URL content. Streaming sources are not supported.
145
190
 
146
- If you remove `_public`, you might also want to disable the development proxy
147
- in `createEdgeStoreProvider`.
191
+ Use `objectOptions` for cache policy, download filenames, metadata, tags, storage
192
+ class, and S3/KMS encryption settings. It accepts a static object or an async
193
+ callback with the same arguments as `path`:
148
194
 
149
195
  ```ts
150
- const { EdgeStoreProvider, useEdgeStore } =
151
- createEdgeStoreProvider<EdgeStoreRouter>({
152
- disableDevProxy: true,
153
- });
196
+ s3({
197
+ objectOptions: ({ fileInfo }) => ({
198
+ CacheControl: 'private, max-age=60',
199
+ ContentDisposition: 'attachment',
200
+ Metadata: { category: fileInfo.metadata.category ?? 'general' },
201
+ }),
202
+ });
203
+ ```
204
+
205
+ `ContentType` comes from the file's MIME type. File contents are not inspected.
206
+
207
+ For custom AWS retry/transport behavior, pass `client: new S3Client(...)`.
208
+ For browser uploads, configure that client with
209
+ `requestChecksumCalculation: 'WHEN_REQUIRED'`.
210
+ When injecting a client with a custom endpoint, also set `baseUrl` explicitly.
211
+
212
+ ## IAM and CORS
213
+
214
+ A baseline application role policy is below. Replace the bucket name and narrow
215
+ object prefixes to your logical buckets where appropriate. KMS encryption needs
216
+ additional key permissions.
217
+
218
+ ```json
219
+ {
220
+ "Version": "2012-10-17",
221
+ "Statement": [{
222
+ "Effect": "Allow",
223
+ "Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:AbortMultipartUpload"],
224
+ "Resource": "arn:aws:s3:::my-storage-bucket/*"
225
+ }]
226
+ }
227
+ ```
228
+
229
+ Configure bucket CORS for your actual application origins. Exposing `ETag` is
230
+ required for browser multipart completion:
231
+
232
+ ```json
233
+ [{
234
+ "AllowedOrigins": ["http://localhost:3000", "https://app.example.com"],
235
+ "AllowedMethods": ["PUT", "GET", "HEAD"],
236
+ "AllowedHeaders": ["*"],
237
+ "ExposeHeaders": ["ETag"],
238
+ "MaxAgeSeconds": 3600
239
+ }]
154
240
  ```
155
241
 
156
- ## Using with Minio
242
+ ## S3-compatible services
157
243
 
158
- You can use the S3 provider with MinIO or other S3-compatible storage providers
159
- by setting the `endpoint` and `forcePathStyle` options.
244
+ For local MinIO:
160
245
 
161
246
  ```ts
162
- provider: s3({
163
- endpoint: 'http://localhost:9000', // can be set via the `ES_AWS_ENDPOINT` environment variable
164
- forcePathStyle: true, // can be set via the `ES_AWS_FORCE_PATH_STYLE` environment variable
165
- }),
247
+ s3({
248
+ bucketName: 'edgestore',
249
+ region: 'us-east-1',
250
+ endpoint: 'http://localhost:9000',
251
+ forcePathStyle: true,
252
+ });
166
253
  ```
254
+
255
+ The endpoint must be reachable from both the application server and browser.
256
+ Set `baseUrl` explicitly for custom domains or virtual-hosted endpoint layouts.
257
+ S3-compatible services may differ in support for KMS, storage classes, tags,
258
+ checksums, and lifecycle policies; only enable settings your service supports.
259
+
260
+ ## Limitations
261
+
262
+ * `temporary` and `replaceTargetUrl` are rejected. Track application-owned files
263
+ in your database and delete old files after successful replacement.
264
+ * Confirmation, listing/filtering, restore, and provider-generated thumbnails are
265
+ unsupported. Thumbnail options do not generate thumbnails.
266
+ * Router path/metadata values are returned at upload time but are not persisted
267
+ as an EdgeStore index. `get()` returns key, URL, size, and S3 timestamps. Persist
268
+ application metadata in your database or explicitly set S3 `Metadata`.
269
+ * No collision-prevention mode, automatic CDN invalidation, or version-specific
270
+ object references. Standard S3 overwrite/delete and versioning rules apply.
271
+ * Browser multipart cleanup is best effort, not a substitute for lifecycle rules.
@@ -12,7 +12,7 @@ React Router application needs a separate backend; this route runs on the server
12
12
  Packages to install (use the application’s package manager):
13
13
 
14
14
  ```text
15
- @edgestore/server @edgestore/react
15
+ @edgestore/server@rc @edgestore/react@rc
16
16
  ```
17
17
 
18
18
  ### Environment variables
@@ -37,9 +37,8 @@ Create the EdgeStore API route:
37
37
  Example: title="app/routes/api/edgestore.ts"
38
38
 
39
39
  ```ts
40
- import { createEdgeStore, initEdgeStore } from '@edgestore/server';
40
+ import { initEdgeStore } from '@edgestore/server';
41
41
  import { createEdgeStoreRemixHandler } from '@edgestore/server/adapters/remix';
42
- import { edgestore } from '@edgestore/server/providers/edgestore';
43
42
 
44
43
  const es = initEdgeStore.create();
45
44
 
@@ -49,13 +48,8 @@ const router = es.router({
49
48
 
50
49
  export type EdgeStoreRouter = typeof router;
51
50
 
52
- const configuredEdgeStore = createEdgeStore({
53
- router,
54
- provider: edgestore(),
55
- });
56
-
57
51
  const handler = createEdgeStoreRemixHandler({
58
- edgestore: configuredEdgeStore,
52
+ router,
59
53
  });
60
54
 
61
55
  export { handler as loader, handler as action };
@@ -9,7 +9,7 @@ Source: https://next.edgestore.dev/docs/adapters/tanstack-start
9
9
  Packages to install (use the application’s package manager):
10
10
 
11
11
  ```text
12
- @edgestore/server @edgestore/react
12
+ @edgestore/server@rc @edgestore/react@rc
13
13
  ```
14
14
 
15
15
  ### Environment variables
@@ -34,9 +34,8 @@ Create the EdgeStore API route:
34
34
  Example: title="src/routes/api/edgestore.$.ts"
35
35
 
36
36
  ```ts
37
- import { createEdgeStore, initEdgeStore } from '@edgestore/server';
37
+ import { initEdgeStore } from '@edgestore/server';
38
38
  import { createEdgeStoreStartHandler } from '@edgestore/server/adapters/start';
39
- import { edgestore } from '@edgestore/server/providers/edgestore';
40
39
  import { createFileRoute } from '@tanstack/react-router';
41
40
 
42
41
  const es = initEdgeStore.create();
@@ -46,13 +45,8 @@ const router = es.router({
46
45
 
47
46
  export type EdgeStoreRouter = typeof router;
48
47
 
49
- const configuredEdgeStore = createEdgeStore({
50
- router,
51
- provider: edgestore(),
52
- });
53
-
54
48
  const handler = createEdgeStoreStartHandler({
55
- edgestore: configuredEdgeStore,
49
+ router,
56
50
  });
57
51
 
58
52
  export const Route = createFileRoute('/api/edgestore/$')({
@@ -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>;
21
20
  logger: LoggerLike;
22
21
  cookieConfig?: CookieConfig;