@edgestore/server 0.3.2 → 0.4.0
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 +3 -3
- package/adapters/fastify/index.d.ts +1 -0
- package/adapters/fastify/index.js +1 -0
- package/dist/adapters/express/index.js +3 -3
- package/dist/adapters/express/index.mjs +3 -3
- package/dist/adapters/fastify/index.d.ts +18 -0
- package/dist/adapters/fastify/index.d.ts.map +1 -0
- package/dist/adapters/fastify/index.js +147 -0
- package/dist/adapters/fastify/index.mjs +143 -0
- package/dist/adapters/next/app/index.js +3 -3
- package/dist/adapters/next/app/index.mjs +3 -3
- package/dist/adapters/next/pages/index.js +3 -3
- package/dist/adapters/next/pages/index.mjs +3 -3
- package/dist/adapters/start/index.d.ts.map +1 -1
- package/dist/adapters/start/index.js +3 -3
- package/dist/adapters/start/index.mjs +3 -3
- package/dist/core/client/index.d.ts +1 -1
- package/dist/core/client/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +3 -3
- package/dist/core/sdk/index.d.ts +4 -4
- package/dist/core/sdk/index.d.ts.map +1 -1
- package/dist/{index-beed799d.js → index-474a21c4.js} +1 -1
- package/dist/{index-28efdacf.mjs → index-a7cc3cd3.mjs} +1 -1
- package/dist/{index-4491caf0.js → index-b689bf59.js} +1 -1
- package/dist/providers/aws/index.d.ts +11 -0
- package/dist/providers/aws/index.d.ts.map +1 -1
- package/dist/providers/aws/index.js +5 -3
- package/dist/providers/aws/index.mjs +5 -3
- package/dist/providers/edgestore/index.js +1 -1
- package/dist/providers/edgestore/index.mjs +1 -1
- package/dist/{shared-7c700083.js → shared-6f6fd0bd.js} +1 -1
- package/dist/{shared-039276af.mjs → shared-c9442cbb.mjs} +1 -1
- package/dist/{shared-83f288f6.js → shared-d27101a7.js} +2 -2
- package/package.json +14 -8
- package/src/adapters/express/index.ts +1 -1
- package/src/adapters/fastify/index.ts +205 -0
- package/src/adapters/next/app/index.ts +1 -1
- package/src/adapters/next/pages/index.ts +1 -1
- package/src/adapters/shared.ts +1 -1
- package/src/adapters/start/index.ts +1 -1
- package/src/core/client/index.ts +9 -1
- package/src/libs/errors/EdgeStoreCredentialsError.ts +1 -1
- package/src/providers/aws/index.ts +22 -2
package/README.md
CHANGED
|
@@ -26,9 +26,9 @@ EDGE_STORE_SECRET_KEY=your-secret-key
|
|
|
26
26
|
### Backend
|
|
27
27
|
|
|
28
28
|
Now we can create the backend code for our Next.js app.<br/>
|
|
29
|
-
|
|
29
|
+
EdgeStore is compatible with both types of Next.js apps (`pages router` and `app router`).
|
|
30
30
|
|
|
31
|
-
The example below is the simplest bucket you can create with
|
|
31
|
+
The example below is the simplest bucket you can create with EdgeStore. Just a simple file bucket with no validation that will be accessible by anyone with the link.
|
|
32
32
|
|
|
33
33
|
You can have multiple buckets in your app, each with its own configuration.
|
|
34
34
|
|
|
@@ -39,7 +39,7 @@ import { createEdgeStoreNextHandler } from '@edgestore/server/adapters/next/app'
|
|
|
39
39
|
const es = initEdgeStore.create();
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* This is the main router for the
|
|
42
|
+
* This is the main router for the EdgeStore buckets.
|
|
43
43
|
*/
|
|
44
44
|
const edgeStoreRouter = es.router({
|
|
45
45
|
publicFiles: es.fileBucket(),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/adapters/fastify';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/adapters/fastify');
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var shared = require('@edgestore/shared');
|
|
6
6
|
var utils = require('../../utils-5819d5e1.js');
|
|
7
7
|
var providers_edgestore_index = require('../../providers/edgestore/index.js');
|
|
8
|
-
var shared$1 = require('../../shared-
|
|
9
|
-
require('../../index-
|
|
8
|
+
var shared$1 = require('../../shared-6f6fd0bd.js');
|
|
9
|
+
require('../../index-b689bf59.js');
|
|
10
10
|
require('@panva/hkdf');
|
|
11
11
|
require('cookie');
|
|
12
12
|
require('jose');
|
|
@@ -16,7 +16,7 @@ function createEdgeStoreExpressHandler(config) {
|
|
|
16
16
|
const { provider = providers_edgestore_index.EdgeStoreProvider() } = config;
|
|
17
17
|
const log = new utils.Logger(config.logLevel);
|
|
18
18
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
19
|
-
log.debug('Creating
|
|
19
|
+
log.debug('Creating EdgeStore Express handler');
|
|
20
20
|
return async (req, res)=>{
|
|
21
21
|
try {
|
|
22
22
|
const pathname = req.url ?? '';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
2
2
|
import { L as Logger, m as matchPath } from '../../utils-f6f56d38.mjs';
|
|
3
3
|
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
4
|
-
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../shared-
|
|
5
|
-
import '../../index-
|
|
4
|
+
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../shared-c9442cbb.mjs';
|
|
5
|
+
import '../../index-a7cc3cd3.mjs';
|
|
6
6
|
import '@panva/hkdf';
|
|
7
7
|
import 'cookie';
|
|
8
8
|
import 'jose';
|
|
@@ -12,7 +12,7 @@ function createEdgeStoreExpressHandler(config) {
|
|
|
12
12
|
const { provider = EdgeStoreProvider() } = config;
|
|
13
13
|
const log = new Logger(config.logLevel);
|
|
14
14
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
15
|
-
log.debug('Creating
|
|
15
|
+
log.debug('Creating EdgeStore Express handler');
|
|
16
16
|
return async (req, res)=>{
|
|
17
17
|
try {
|
|
18
18
|
const pathname = req.url ?? '';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type EdgeStoreRouter, type MaybePromise, type Provider } from '@edgestore/shared';
|
|
2
|
+
import { type FastifyRequest, type FastifyReply } from 'fastify';
|
|
3
|
+
import { type LogLevel } from '../../libs/logger';
|
|
4
|
+
export type CreateContextOptions = {
|
|
5
|
+
req: FastifyRequest;
|
|
6
|
+
reply: FastifyReply;
|
|
7
|
+
};
|
|
8
|
+
export type Config<TCtx> = {
|
|
9
|
+
provider?: Provider;
|
|
10
|
+
router: EdgeStoreRouter<TCtx>;
|
|
11
|
+
logLevel?: LogLevel;
|
|
12
|
+
} & (TCtx extends Record<string, never> ? object : {
|
|
13
|
+
provider?: Provider;
|
|
14
|
+
router: EdgeStoreRouter<TCtx>;
|
|
15
|
+
createContext: (opts: CreateContextOptions) => MaybePromise<TCtx>;
|
|
16
|
+
});
|
|
17
|
+
export declare function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>): (req: FastifyRequest, reply: FastifyReply) => Promise<never>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiB1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,IAAI,IAAI;IACzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,GAAG,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACnC,MAAM,GACN;IACE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,aAAa,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CACnE,CAAC,CAAC;AA2BP,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAMnD,cAAc,SAAS,YAAY,oBAkIvD"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shared = require('@edgestore/shared');
|
|
6
|
+
var utils = require('../../utils-5819d5e1.js');
|
|
7
|
+
var providers_edgestore_index = require('../../providers/edgestore/index.js');
|
|
8
|
+
var shared$1 = require('../../shared-6f6fd0bd.js');
|
|
9
|
+
require('../../index-b689bf59.js');
|
|
10
|
+
require('@panva/hkdf');
|
|
11
|
+
require('cookie');
|
|
12
|
+
require('jose');
|
|
13
|
+
require('uuid');
|
|
14
|
+
|
|
15
|
+
// Helper to safely get cookies from Fastify request
|
|
16
|
+
function getCookie(req, name) {
|
|
17
|
+
// Check if cookies plugin is available
|
|
18
|
+
if ('cookies' in req) {
|
|
19
|
+
// Type assertion for TypeScript
|
|
20
|
+
return req.cookies[name];
|
|
21
|
+
}
|
|
22
|
+
// Fallback to parsing cookie header
|
|
23
|
+
const cookieHeader = req.headers.cookie;
|
|
24
|
+
if (!cookieHeader) return undefined;
|
|
25
|
+
const cookies = cookieHeader.split(';').reduce((acc, cookie)=>{
|
|
26
|
+
const [key, value] = cookie.trim().split('=');
|
|
27
|
+
if (key && value) acc[key] = value;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
return cookies[name];
|
|
31
|
+
}
|
|
32
|
+
function createEdgeStoreFastifyHandler(config) {
|
|
33
|
+
const { provider = providers_edgestore_index.EdgeStoreProvider() } = config;
|
|
34
|
+
const log = new utils.Logger(config.logLevel);
|
|
35
|
+
globalThis._EDGE_STORE_LOGGER = log;
|
|
36
|
+
log.debug('Creating EdgeStore Fastify handler');
|
|
37
|
+
return async (req, reply)=>{
|
|
38
|
+
try {
|
|
39
|
+
// Get the URL from the request - simplified approach
|
|
40
|
+
const pathname = req.url;
|
|
41
|
+
if (utils.matchPath(pathname, '/health')) {
|
|
42
|
+
return reply.send('OK');
|
|
43
|
+
} else if (utils.matchPath(pathname, '/init')) {
|
|
44
|
+
let ctx = {};
|
|
45
|
+
try {
|
|
46
|
+
ctx = 'createContext' in config ? await config.createContext({
|
|
47
|
+
req,
|
|
48
|
+
reply
|
|
49
|
+
}) : {};
|
|
50
|
+
} catch (err) {
|
|
51
|
+
throw new shared.EdgeStoreError({
|
|
52
|
+
message: 'Error creating context',
|
|
53
|
+
code: 'CREATE_CONTEXT_ERROR',
|
|
54
|
+
cause: err instanceof Error ? err : undefined
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const { newCookies, token, baseUrl } = await shared$1.init({
|
|
58
|
+
ctx,
|
|
59
|
+
provider,
|
|
60
|
+
router: config.router
|
|
61
|
+
});
|
|
62
|
+
// Set cookies more efficiently - handling them using void operator
|
|
63
|
+
// to explicitly mark these synchronous calls as intentionally not awaited
|
|
64
|
+
if (Array.isArray(newCookies)) {
|
|
65
|
+
// If it's an array of cookies, set them all
|
|
66
|
+
for (const cookie of newCookies){
|
|
67
|
+
void reply.header('Set-Cookie', cookie);
|
|
68
|
+
}
|
|
69
|
+
} else if (newCookies) {
|
|
70
|
+
// If it's a single cookie string
|
|
71
|
+
void reply.header('Set-Cookie', newCookies);
|
|
72
|
+
}
|
|
73
|
+
return reply.send({
|
|
74
|
+
token,
|
|
75
|
+
baseUrl
|
|
76
|
+
});
|
|
77
|
+
} else if (utils.matchPath(pathname, '/request-upload')) {
|
|
78
|
+
return reply.send(await shared$1.requestUpload({
|
|
79
|
+
provider,
|
|
80
|
+
router: config.router,
|
|
81
|
+
body: req.body,
|
|
82
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
83
|
+
}));
|
|
84
|
+
} else if (utils.matchPath(pathname, '/request-upload-parts')) {
|
|
85
|
+
return reply.send(await shared$1.requestUploadParts({
|
|
86
|
+
provider,
|
|
87
|
+
router: config.router,
|
|
88
|
+
body: req.body,
|
|
89
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
90
|
+
}));
|
|
91
|
+
} else if (utils.matchPath(pathname, '/complete-multipart-upload')) {
|
|
92
|
+
await shared$1.completeMultipartUpload({
|
|
93
|
+
provider,
|
|
94
|
+
router: config.router,
|
|
95
|
+
body: req.body,
|
|
96
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
97
|
+
});
|
|
98
|
+
return reply.status(200).send();
|
|
99
|
+
} else if (utils.matchPath(pathname, '/confirm-upload')) {
|
|
100
|
+
return reply.send(await shared$1.confirmUpload({
|
|
101
|
+
provider,
|
|
102
|
+
router: config.router,
|
|
103
|
+
body: req.body,
|
|
104
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
105
|
+
}));
|
|
106
|
+
} else if (utils.matchPath(pathname, '/delete-file')) {
|
|
107
|
+
return reply.send(await shared$1.deleteFile({
|
|
108
|
+
provider,
|
|
109
|
+
router: config.router,
|
|
110
|
+
body: req.body,
|
|
111
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
112
|
+
}));
|
|
113
|
+
} else if (utils.matchPath(pathname, '/proxy-file')) {
|
|
114
|
+
const url = req.query ? req.query.url : undefined;
|
|
115
|
+
if (typeof url === 'string') {
|
|
116
|
+
const cookieHeader = req.headers.cookie ?? '';
|
|
117
|
+
const proxyRes = await fetch(url, {
|
|
118
|
+
headers: {
|
|
119
|
+
cookie: cookieHeader
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const data = await proxyRes.arrayBuffer();
|
|
123
|
+
void reply.header('Content-Type', proxyRes.headers.get('Content-Type') ?? 'application/octet-stream');
|
|
124
|
+
return reply.send(Buffer.from(data));
|
|
125
|
+
} else {
|
|
126
|
+
return reply.status(400).send();
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
return reply.status(404).send();
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
if (err instanceof shared.EdgeStoreError) {
|
|
133
|
+
log[err.level](err.formattedMessage());
|
|
134
|
+
if (err.cause) log[err.level](err.cause);
|
|
135
|
+
return reply.status(shared.EDGE_STORE_ERROR_CODES[err.code]).send(err.formattedJson());
|
|
136
|
+
} else {
|
|
137
|
+
log.error(err);
|
|
138
|
+
return reply.status(500).send(new shared.EdgeStoreError({
|
|
139
|
+
message: 'Internal Server Error',
|
|
140
|
+
code: 'SERVER_ERROR'
|
|
141
|
+
}).formattedJson());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
exports.createEdgeStoreFastifyHandler = createEdgeStoreFastifyHandler;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
2
|
+
import { L as Logger, m as matchPath } from '../../utils-f6f56d38.mjs';
|
|
3
|
+
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
4
|
+
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../shared-c9442cbb.mjs';
|
|
5
|
+
import '../../index-a7cc3cd3.mjs';
|
|
6
|
+
import '@panva/hkdf';
|
|
7
|
+
import 'cookie';
|
|
8
|
+
import 'jose';
|
|
9
|
+
import 'uuid';
|
|
10
|
+
|
|
11
|
+
// Helper to safely get cookies from Fastify request
|
|
12
|
+
function getCookie(req, name) {
|
|
13
|
+
// Check if cookies plugin is available
|
|
14
|
+
if ('cookies' in req) {
|
|
15
|
+
// Type assertion for TypeScript
|
|
16
|
+
return req.cookies[name];
|
|
17
|
+
}
|
|
18
|
+
// Fallback to parsing cookie header
|
|
19
|
+
const cookieHeader = req.headers.cookie;
|
|
20
|
+
if (!cookieHeader) return undefined;
|
|
21
|
+
const cookies = cookieHeader.split(';').reduce((acc, cookie)=>{
|
|
22
|
+
const [key, value] = cookie.trim().split('=');
|
|
23
|
+
if (key && value) acc[key] = value;
|
|
24
|
+
return acc;
|
|
25
|
+
}, {});
|
|
26
|
+
return cookies[name];
|
|
27
|
+
}
|
|
28
|
+
function createEdgeStoreFastifyHandler(config) {
|
|
29
|
+
const { provider = EdgeStoreProvider() } = config;
|
|
30
|
+
const log = new Logger(config.logLevel);
|
|
31
|
+
globalThis._EDGE_STORE_LOGGER = log;
|
|
32
|
+
log.debug('Creating EdgeStore Fastify handler');
|
|
33
|
+
return async (req, reply)=>{
|
|
34
|
+
try {
|
|
35
|
+
// Get the URL from the request - simplified approach
|
|
36
|
+
const pathname = req.url;
|
|
37
|
+
if (matchPath(pathname, '/health')) {
|
|
38
|
+
return reply.send('OK');
|
|
39
|
+
} else if (matchPath(pathname, '/init')) {
|
|
40
|
+
let ctx = {};
|
|
41
|
+
try {
|
|
42
|
+
ctx = 'createContext' in config ? await config.createContext({
|
|
43
|
+
req,
|
|
44
|
+
reply
|
|
45
|
+
}) : {};
|
|
46
|
+
} catch (err) {
|
|
47
|
+
throw new EdgeStoreError({
|
|
48
|
+
message: 'Error creating context',
|
|
49
|
+
code: 'CREATE_CONTEXT_ERROR',
|
|
50
|
+
cause: err instanceof Error ? err : undefined
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const { newCookies, token, baseUrl } = await init({
|
|
54
|
+
ctx,
|
|
55
|
+
provider,
|
|
56
|
+
router: config.router
|
|
57
|
+
});
|
|
58
|
+
// Set cookies more efficiently - handling them using void operator
|
|
59
|
+
// to explicitly mark these synchronous calls as intentionally not awaited
|
|
60
|
+
if (Array.isArray(newCookies)) {
|
|
61
|
+
// If it's an array of cookies, set them all
|
|
62
|
+
for (const cookie of newCookies){
|
|
63
|
+
void reply.header('Set-Cookie', cookie);
|
|
64
|
+
}
|
|
65
|
+
} else if (newCookies) {
|
|
66
|
+
// If it's a single cookie string
|
|
67
|
+
void reply.header('Set-Cookie', newCookies);
|
|
68
|
+
}
|
|
69
|
+
return reply.send({
|
|
70
|
+
token,
|
|
71
|
+
baseUrl
|
|
72
|
+
});
|
|
73
|
+
} else if (matchPath(pathname, '/request-upload')) {
|
|
74
|
+
return reply.send(await requestUpload({
|
|
75
|
+
provider,
|
|
76
|
+
router: config.router,
|
|
77
|
+
body: req.body,
|
|
78
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
79
|
+
}));
|
|
80
|
+
} else if (matchPath(pathname, '/request-upload-parts')) {
|
|
81
|
+
return reply.send(await requestUploadParts({
|
|
82
|
+
provider,
|
|
83
|
+
router: config.router,
|
|
84
|
+
body: req.body,
|
|
85
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
86
|
+
}));
|
|
87
|
+
} else if (matchPath(pathname, '/complete-multipart-upload')) {
|
|
88
|
+
await completeMultipartUpload({
|
|
89
|
+
provider,
|
|
90
|
+
router: config.router,
|
|
91
|
+
body: req.body,
|
|
92
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
93
|
+
});
|
|
94
|
+
return reply.status(200).send();
|
|
95
|
+
} else if (matchPath(pathname, '/confirm-upload')) {
|
|
96
|
+
return reply.send(await confirmUpload({
|
|
97
|
+
provider,
|
|
98
|
+
router: config.router,
|
|
99
|
+
body: req.body,
|
|
100
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
101
|
+
}));
|
|
102
|
+
} else if (matchPath(pathname, '/delete-file')) {
|
|
103
|
+
return reply.send(await deleteFile({
|
|
104
|
+
provider,
|
|
105
|
+
router: config.router,
|
|
106
|
+
body: req.body,
|
|
107
|
+
ctxToken: getCookie(req, 'edgestore-ctx')
|
|
108
|
+
}));
|
|
109
|
+
} else if (matchPath(pathname, '/proxy-file')) {
|
|
110
|
+
const url = req.query ? req.query.url : undefined;
|
|
111
|
+
if (typeof url === 'string') {
|
|
112
|
+
const cookieHeader = req.headers.cookie ?? '';
|
|
113
|
+
const proxyRes = await fetch(url, {
|
|
114
|
+
headers: {
|
|
115
|
+
cookie: cookieHeader
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const data = await proxyRes.arrayBuffer();
|
|
119
|
+
void reply.header('Content-Type', proxyRes.headers.get('Content-Type') ?? 'application/octet-stream');
|
|
120
|
+
return reply.send(Buffer.from(data));
|
|
121
|
+
} else {
|
|
122
|
+
return reply.status(400).send();
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
return reply.status(404).send();
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (err instanceof EdgeStoreError) {
|
|
129
|
+
log[err.level](err.formattedMessage());
|
|
130
|
+
if (err.cause) log[err.level](err.cause);
|
|
131
|
+
return reply.status(EDGE_STORE_ERROR_CODES[err.code]).send(err.formattedJson());
|
|
132
|
+
} else {
|
|
133
|
+
log.error(err);
|
|
134
|
+
return reply.status(500).send(new EdgeStoreError({
|
|
135
|
+
message: 'Internal Server Error',
|
|
136
|
+
code: 'SERVER_ERROR'
|
|
137
|
+
}).formattedJson());
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { createEdgeStoreFastifyHandler };
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var shared = require('@edgestore/shared');
|
|
6
6
|
var utils = require('../../../utils-5819d5e1.js');
|
|
7
7
|
var providers_edgestore_index = require('../../../providers/edgestore/index.js');
|
|
8
|
-
var shared$1 = require('../../../shared-
|
|
9
|
-
require('../../../index-
|
|
8
|
+
var shared$1 = require('../../../shared-6f6fd0bd.js');
|
|
9
|
+
require('../../../index-b689bf59.js');
|
|
10
10
|
require('@panva/hkdf');
|
|
11
11
|
require('cookie');
|
|
12
12
|
require('jose');
|
|
@@ -16,7 +16,7 @@ function createEdgeStoreNextHandler(config) {
|
|
|
16
16
|
const { provider = providers_edgestore_index.EdgeStoreProvider() } = config;
|
|
17
17
|
const log = new utils.Logger(config.logLevel);
|
|
18
18
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
19
|
-
log.debug('Creating
|
|
19
|
+
log.debug('Creating EdgeStore Next handler (app adapter)');
|
|
20
20
|
return async (req)=>{
|
|
21
21
|
try {
|
|
22
22
|
if (!('nextUrl' in req)) throw new shared.EdgeStoreError({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
2
2
|
import { L as Logger, m as matchPath } from '../../../utils-f6f56d38.mjs';
|
|
3
3
|
import { EdgeStoreProvider } from '../../../providers/edgestore/index.mjs';
|
|
4
|
-
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../../shared-
|
|
5
|
-
import '../../../index-
|
|
4
|
+
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../../shared-c9442cbb.mjs';
|
|
5
|
+
import '../../../index-a7cc3cd3.mjs';
|
|
6
6
|
import '@panva/hkdf';
|
|
7
7
|
import 'cookie';
|
|
8
8
|
import 'jose';
|
|
@@ -12,7 +12,7 @@ function createEdgeStoreNextHandler(config) {
|
|
|
12
12
|
const { provider = EdgeStoreProvider() } = config;
|
|
13
13
|
const log = new Logger(config.logLevel);
|
|
14
14
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
15
|
-
log.debug('Creating
|
|
15
|
+
log.debug('Creating EdgeStore Next handler (app adapter)');
|
|
16
16
|
return async (req)=>{
|
|
17
17
|
try {
|
|
18
18
|
if (!('nextUrl' in req)) throw new EdgeStoreError({
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var shared = require('@edgestore/shared');
|
|
6
6
|
var utils = require('../../../utils-5819d5e1.js');
|
|
7
7
|
var providers_edgestore_index = require('../../../providers/edgestore/index.js');
|
|
8
|
-
var shared$1 = require('../../../shared-
|
|
9
|
-
require('../../../index-
|
|
8
|
+
var shared$1 = require('../../../shared-6f6fd0bd.js');
|
|
9
|
+
require('../../../index-b689bf59.js');
|
|
10
10
|
require('@panva/hkdf');
|
|
11
11
|
require('cookie');
|
|
12
12
|
require('jose');
|
|
@@ -16,7 +16,7 @@ function createEdgeStoreNextHandler(config) {
|
|
|
16
16
|
const { provider = providers_edgestore_index.EdgeStoreProvider() } = config;
|
|
17
17
|
const log = new utils.Logger(config.logLevel);
|
|
18
18
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
19
|
-
log.debug('Creating
|
|
19
|
+
log.debug('Creating EdgeStore Next handler (pages adapter)');
|
|
20
20
|
return async (req, res)=>{
|
|
21
21
|
try {
|
|
22
22
|
if (!('json' in res)) throw new shared.EdgeStoreError({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
2
2
|
import { L as Logger, m as matchPath } from '../../../utils-f6f56d38.mjs';
|
|
3
3
|
import { EdgeStoreProvider } from '../../../providers/edgestore/index.mjs';
|
|
4
|
-
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../../shared-
|
|
5
|
-
import '../../../index-
|
|
4
|
+
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../../shared-c9442cbb.mjs';
|
|
5
|
+
import '../../../index-a7cc3cd3.mjs';
|
|
6
6
|
import '@panva/hkdf';
|
|
7
7
|
import 'cookie';
|
|
8
8
|
import 'jose';
|
|
@@ -12,7 +12,7 @@ function createEdgeStoreNextHandler(config) {
|
|
|
12
12
|
const { provider = EdgeStoreProvider() } = config;
|
|
13
13
|
const log = new Logger(config.logLevel);
|
|
14
14
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
15
|
-
log.debug('Creating
|
|
15
|
+
log.debug('Creating EdgeStore Next handler (pages adapter)');
|
|
16
16
|
return async (req, res)=>{
|
|
17
17
|
try {
|
|
18
18
|
if (!('json' in res)) throw new EdgeStoreError({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiB1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,IAAI,IAAI;IACzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,GAAG,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACnC,MAAM,GACN;IACE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,aAAa,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CACnE,CAAC,CAAC;AAsBP,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiB1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,IAAI,IAAI;IACzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,GAAG,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACnC,MAAM,GACN;IACE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,aAAa,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CACnE,CAAC,CAAC;AAsBP,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,iBAMzC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,uBA4IhD"}
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var shared = require('@edgestore/shared');
|
|
6
6
|
var utils = require('../../utils-5819d5e1.js');
|
|
7
7
|
var providers_edgestore_index = require('../../providers/edgestore/index.js');
|
|
8
|
-
var shared$1 = require('../../shared-
|
|
9
|
-
require('../../index-
|
|
8
|
+
var shared$1 = require('../../shared-6f6fd0bd.js');
|
|
9
|
+
require('../../index-b689bf59.js');
|
|
10
10
|
require('@panva/hkdf');
|
|
11
11
|
require('cookie');
|
|
12
12
|
require('jose');
|
|
@@ -28,7 +28,7 @@ function createEdgeStoreStartHandler(config) {
|
|
|
28
28
|
const { provider = providers_edgestore_index.EdgeStoreProvider() } = config;
|
|
29
29
|
const log = new utils.Logger(config.logLevel);
|
|
30
30
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
31
|
-
log.debug('Creating
|
|
31
|
+
log.debug('Creating EdgeStore TanStack Start handler');
|
|
32
32
|
return async ({ request })=>{
|
|
33
33
|
try {
|
|
34
34
|
const { pathname } = new URL(request.url);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
2
2
|
import { L as Logger, m as matchPath } from '../../utils-f6f56d38.mjs';
|
|
3
3
|
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
4
|
-
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../shared-
|
|
5
|
-
import '../../index-
|
|
4
|
+
import { i as init, r as requestUpload, a as requestUploadParts, c as completeMultipartUpload, d as confirmUpload, e as deleteFile } from '../../shared-c9442cbb.mjs';
|
|
5
|
+
import '../../index-a7cc3cd3.mjs';
|
|
6
6
|
import '@panva/hkdf';
|
|
7
7
|
import 'cookie';
|
|
8
8
|
import 'jose';
|
|
@@ -24,7 +24,7 @@ function createEdgeStoreStartHandler(config) {
|
|
|
24
24
|
const { provider = EdgeStoreProvider() } = config;
|
|
25
25
|
const log = new Logger(config.logLevel);
|
|
26
26
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
27
|
-
log.debug('Creating
|
|
27
|
+
log.debug('Creating EdgeStore TanStack Start handler');
|
|
28
28
|
return async ({ request })=>{
|
|
29
29
|
try {
|
|
30
30
|
const { pathname } = new URL(request.url);
|
|
@@ -210,7 +210,7 @@ export declare function initEdgeStoreClient<TRouter extends AnyRouter>(config: {
|
|
|
210
210
|
}): EdgeStoreClient<TRouter>;
|
|
211
211
|
export type InferClientResponse<TRouter extends AnyRouter> = {
|
|
212
212
|
[TBucketName in keyof TRouter['buckets']]: {
|
|
213
|
-
[TClienFn in keyof EdgeStoreClient<TRouter>[TBucketName]]: Simplify<Awaited<ReturnType<EdgeStoreClient<TRouter>[TBucketName][TClienFn]>>>;
|
|
213
|
+
[TClienFn in keyof EdgeStoreClient<TRouter>[TBucketName]]: Simplify<Awaited<ReturnType<EdgeStoreClient<TRouter>[TBucketName][TClienFn] extends (...args: any) => any ? EdgeStoreClient<TRouter>[TBucketName][TClienFn] : never>>>;
|
|
214
214
|
};
|
|
215
215
|
};
|
|
216
216
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,CAAC,EAAE,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,IAAI,CAAC;AAIrC,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,UAAU,IAAI;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,WAAW,GAAG,MAAM,CAAC;AAC1B,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;C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QACH,UAAU,EAAE,CAAC,MAAM,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC;YAC/C,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC,CAAC;QACH;;;;;WAKG;QACH,SAAS,EAAE,CACT,MAAM,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,KAC7C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAClE;CACF,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,SAAS,EAAE,MAAM,EAAE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,4BAsJA;AA6BD,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,SAAS,IAAI;KAC1D,WAAW,IAAI,MAAM,OAAO,CAAC,SAAS,CAAC,GAAG;SACxC,QAAQ,IAAI,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,GAAG,QAAQ,CACjE,OAAO,CACL,UAAU,CACR,eAAe,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,SAAS,CACtD,GAAG,IAAI,EAAE,GAAG,KACT,GAAG,GACJ,eAAe,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,GAC/C,KAAK,CACV,CACF,CACF;KACF;CACF,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var shared = require('../shared-
|
|
6
|
-
var index = require('../index-
|
|
5
|
+
var shared = require('../shared-6f6fd0bd.js');
|
|
6
|
+
var index = require('../index-b689bf59.js');
|
|
7
7
|
require('@edgestore/shared');
|
|
8
8
|
require('@panva/hkdf');
|
|
9
9
|
require('cookie');
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as buildPath, p as parsePath } from '../shared-
|
|
2
|
-
import { i as initEdgeStoreSdk } from '../index-
|
|
3
|
-
export { e as edgeStoreRawSdk, i as initEdgeStoreSdk } from '../index-
|
|
1
|
+
import { b as buildPath, p as parsePath } from '../shared-c9442cbb.mjs';
|
|
2
|
+
import { i as initEdgeStoreSdk } from '../index-a7cc3cd3.mjs';
|
|
3
|
+
export { e as edgeStoreRawSdk, i as initEdgeStoreSdk } from '../index-a7cc3cd3.mjs';
|
|
4
4
|
import '@edgestore/shared';
|
|
5
5
|
import '@panva/hkdf';
|
|
6
6
|
import 'cookie';
|
package/dist/core/sdk/index.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare const edgeStoreRawSdk: {
|
|
|
60
60
|
fileInfo: FileInfoForUpload;
|
|
61
61
|
multipart?: {
|
|
62
62
|
parts: number[];
|
|
63
|
-
}
|
|
63
|
+
};
|
|
64
64
|
}): Promise<{
|
|
65
65
|
multipart: {
|
|
66
66
|
key: string;
|
|
@@ -122,8 +122,8 @@ export declare const edgeStoreRawSdk: {
|
|
|
122
122
|
accessKey: string;
|
|
123
123
|
secretKey: string;
|
|
124
124
|
bucketName: string;
|
|
125
|
-
filter?: ListFilesFilter
|
|
126
|
-
pagination?: Pagination
|
|
125
|
+
filter?: ListFilesFilter;
|
|
126
|
+
pagination?: Pagination;
|
|
127
127
|
}): Promise<{
|
|
128
128
|
data: {
|
|
129
129
|
url: string;
|
|
@@ -164,7 +164,7 @@ export declare function initEdgeStoreSdk(params: {
|
|
|
164
164
|
fileInfo: FileInfoForUpload;
|
|
165
165
|
multipart?: {
|
|
166
166
|
parts: number[];
|
|
167
|
-
}
|
|
167
|
+
};
|
|
168
168
|
}): Promise<{
|
|
169
169
|
multipart: {
|
|
170
170
|
key: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAM3B,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,YAAY,GACZ,UAAU,CAAC;AAEf,MAAM,MAAM,UAAU,CAAC,KAAK,GAAG,MAAM,IACjC,KAAK,GACL,OAAO,CACL;KACG,CAAC,IAAI,cAAc,GAAG,KAAK;CAC7B,GAAG;IACF,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACzB,CACF,CAAC;AAEN,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC;IACxB,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;KAC3B,CAAC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AAO;;2BAmLd;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;iBA9JR,OAAO;;wBAqKjB;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;iBAlJL,OAAO;;sBAyJnB;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,eAAe,CAAC;QACzB,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB;cArIO;YACJ,GAAG,EAAE,MAAM,CAAC;YACZ,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;YAC5B,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAClC,EAAE;oBACS;YACV,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,UAAU,EAAE,MAAM,CAAC;SACpB;;EAgIN;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EdgeStoreError } from '@edgestore/shared';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
|
|
4
|
-
This can happen if you are trying to import something related to the backend of
|
|
4
|
+
This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
|
|
5
5
|
class EdgeStoreCredentialsError extends Error {
|
|
6
6
|
constructor(message = DEFAULT_MESSAGE) {
|
|
7
7
|
super(message);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EdgeStoreError } from '@edgestore/shared';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
|
|
4
|
-
This can happen if you are trying to import something related to the backend of
|
|
4
|
+
This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
|
|
5
5
|
class EdgeStoreCredentialsError extends Error {
|
|
6
6
|
constructor(message = DEFAULT_MESSAGE){
|
|
7
7
|
super(message);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var shared = require('@edgestore/shared');
|
|
4
4
|
|
|
5
5
|
const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
|
|
6
|
-
This can happen if you are trying to import something related to the backend of
|
|
6
|
+
This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
|
|
7
7
|
class EdgeStoreCredentialsError extends Error {
|
|
8
8
|
constructor(message = DEFAULT_MESSAGE){
|
|
9
9
|
super(message);
|
|
@@ -24,6 +24,17 @@ export type AWSProviderOptions = {
|
|
|
24
24
|
* Can also be set via the `ES_AWS_BUCKET_NAME` environment variable.
|
|
25
25
|
*/
|
|
26
26
|
bucketName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Custom endpoint for S3-compatible storage providers (e.g., MinIO).
|
|
29
|
+
* Can also be set via the `ES_AWS_ENDPOINT` environment variable.
|
|
30
|
+
*/
|
|
31
|
+
endpoint?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Force path style for S3-compatible storage providers.
|
|
34
|
+
* Can also be set via the `ES_AWS_FORCE_PATH_STYLE` environment variable.
|
|
35
|
+
* Defaults to false for AWS S3, but should be true for most S3-compatible providers.
|
|
36
|
+
*/
|
|
37
|
+
forcePathStyle?: boolean;
|
|
27
38
|
/**
|
|
28
39
|
* Base URL to use for accessing files.
|
|
29
40
|
* Only needed if you are using a custom domain or cloudfront.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CA8GlE"}
|
|
@@ -7,15 +7,17 @@ var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
|
7
7
|
var uuid = require('uuid');
|
|
8
8
|
|
|
9
9
|
function AWSProvider(options) {
|
|
10
|
-
const { accessKeyId = process.env.ES_AWS_ACCESS_KEY_ID, secretAccessKey = process.env.ES_AWS_SECRET_ACCESS_KEY, region = process.env.ES_AWS_REGION, bucketName = process.env.ES_AWS_BUCKET_NAME } = options ?? {};
|
|
11
|
-
const baseUrl = options?.baseUrl ?? process.env.EDGE_STORE_BASE_URL ?? `https://${bucketName}.s3.${region}.amazonaws.com
|
|
10
|
+
const { accessKeyId = process.env.ES_AWS_ACCESS_KEY_ID, secretAccessKey = process.env.ES_AWS_SECRET_ACCESS_KEY, region = process.env.ES_AWS_REGION, bucketName = process.env.ES_AWS_BUCKET_NAME, endpoint = process.env.ES_AWS_ENDPOINT, forcePathStyle = process.env.ES_AWS_FORCE_PATH_STYLE === 'true' } = options ?? {};
|
|
11
|
+
const baseUrl = options?.baseUrl ?? process.env.EDGE_STORE_BASE_URL ?? (endpoint ? `${endpoint}/${bucketName}` : `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
12
12
|
const credentials = accessKeyId && secretAccessKey ? {
|
|
13
13
|
accessKeyId,
|
|
14
14
|
secretAccessKey
|
|
15
15
|
} : undefined;
|
|
16
16
|
const s3Client = new clientS3.S3Client({
|
|
17
17
|
region,
|
|
18
|
-
credentials
|
|
18
|
+
credentials,
|
|
19
|
+
endpoint,
|
|
20
|
+
forcePathStyle
|
|
19
21
|
});
|
|
20
22
|
return {
|
|
21
23
|
async init () {
|
|
@@ -3,15 +3,17 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
|
3
3
|
import { v4 } from 'uuid';
|
|
4
4
|
|
|
5
5
|
function AWSProvider(options) {
|
|
6
|
-
const { accessKeyId = process.env.ES_AWS_ACCESS_KEY_ID, secretAccessKey = process.env.ES_AWS_SECRET_ACCESS_KEY, region = process.env.ES_AWS_REGION, bucketName = process.env.ES_AWS_BUCKET_NAME } = options ?? {};
|
|
7
|
-
const baseUrl = options?.baseUrl ?? process.env.EDGE_STORE_BASE_URL ?? `https://${bucketName}.s3.${region}.amazonaws.com
|
|
6
|
+
const { accessKeyId = process.env.ES_AWS_ACCESS_KEY_ID, secretAccessKey = process.env.ES_AWS_SECRET_ACCESS_KEY, region = process.env.ES_AWS_REGION, bucketName = process.env.ES_AWS_BUCKET_NAME, endpoint = process.env.ES_AWS_ENDPOINT, forcePathStyle = process.env.ES_AWS_FORCE_PATH_STYLE === 'true' } = options ?? {};
|
|
7
|
+
const baseUrl = options?.baseUrl ?? process.env.EDGE_STORE_BASE_URL ?? (endpoint ? `${endpoint}/${bucketName}` : `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
8
8
|
const credentials = accessKeyId && secretAccessKey ? {
|
|
9
9
|
accessKeyId,
|
|
10
10
|
secretAccessKey
|
|
11
11
|
} : undefined;
|
|
12
12
|
const s3Client = new S3Client({
|
|
13
13
|
region,
|
|
14
|
-
credentials
|
|
14
|
+
credentials,
|
|
15
|
+
endpoint,
|
|
16
|
+
forcePathStyle
|
|
15
17
|
});
|
|
16
18
|
return {
|
|
17
19
|
async init () {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var shared = require('@edgestore/shared');
|
|
6
|
-
var index = require('../../index-
|
|
6
|
+
var index = require('../../index-b689bf59.js');
|
|
7
7
|
|
|
8
8
|
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
9
9
|
function EdgeStoreProvider(options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EdgeStoreError } from '@edgestore/shared';
|
|
2
|
-
import { E as EdgeStoreCredentialsError, i as initEdgeStoreSdk } from '../../index-
|
|
2
|
+
import { E as EdgeStoreCredentialsError, i as initEdgeStoreSdk } from '../../index-a7cc3cd3.mjs';
|
|
3
3
|
|
|
4
4
|
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
5
5
|
function EdgeStoreProvider(options) {
|
|
@@ -349,7 +349,7 @@ async function decryptJWT(token) {
|
|
|
349
349
|
return payload;
|
|
350
350
|
}
|
|
351
351
|
async function getDerivedEncryptionKey(secret) {
|
|
352
|
-
return await hkdf.hkdf('sha256', secret, '', '
|
|
352
|
+
return await hkdf.hkdf('sha256', secret, '', 'EdgeStore Generated Encryption Key', 32);
|
|
353
353
|
}
|
|
354
354
|
function buildPath(params) {
|
|
355
355
|
const { bucket } = params;
|
|
@@ -347,7 +347,7 @@ async function decryptJWT(token) {
|
|
|
347
347
|
return payload;
|
|
348
348
|
}
|
|
349
349
|
async function getDerivedEncryptionKey(secret) {
|
|
350
|
-
return await hkdf('sha256', secret, '', '
|
|
350
|
+
return await hkdf('sha256', secret, '', 'EdgeStore Generated Encryption Key', 32);
|
|
351
351
|
}
|
|
352
352
|
function buildPath(params) {
|
|
353
353
|
const { bucket } = params;
|
|
@@ -166,7 +166,7 @@ async function requestUpload(params) {
|
|
|
166
166
|
return {
|
|
167
167
|
...requestUploadRes,
|
|
168
168
|
size: fileInfo.size,
|
|
169
|
-
uploadedAt: new Date().toISOString(),
|
|
169
|
+
uploadedAt: new Date().toISOString(), // TODO: maybe delete this field since it's not the actual upload time
|
|
170
170
|
path: parsedPath,
|
|
171
171
|
pathOrder,
|
|
172
172
|
metadata,
|
|
@@ -320,7 +320,7 @@ async function decryptJWT(token) {
|
|
|
320
320
|
return payload;
|
|
321
321
|
}
|
|
322
322
|
async function getDerivedEncryptionKey(secret) {
|
|
323
|
-
return await hkdf('sha256', secret, '', '
|
|
323
|
+
return await hkdf('sha256', secret, '', 'EdgeStore Generated Encryption Key', 32);
|
|
324
324
|
}
|
|
325
325
|
function buildPath(params) {
|
|
326
326
|
const { bucket } = params;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgestore/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Upload files with ease from React/Next.js",
|
|
5
5
|
"homepage": "https://edgestore.dev",
|
|
6
6
|
"repository": "https://github.com/edgestorejs/edgestore.git",
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
"require": "./dist/adapters/express/index.js",
|
|
43
43
|
"default": "./dist/adapters/express/index.js"
|
|
44
44
|
},
|
|
45
|
+
"./adapters/fastify": {
|
|
46
|
+
"import": "./dist/adapters/fastify/index.mjs",
|
|
47
|
+
"require": "./dist/adapters/fastify/index.js",
|
|
48
|
+
"default": "./dist/adapters/fastify/index.js"
|
|
49
|
+
},
|
|
45
50
|
"./adapters/next/pages": {
|
|
46
51
|
"import": "./dist/adapters/next/pages/index.mjs",
|
|
47
52
|
"require": "./dist/adapters/next/pages/index.js",
|
|
@@ -89,7 +94,7 @@
|
|
|
89
94
|
},
|
|
90
95
|
"license": "MIT",
|
|
91
96
|
"dependencies": {
|
|
92
|
-
"@edgestore/shared": "0.
|
|
97
|
+
"@edgestore/shared": "0.4.0",
|
|
93
98
|
"@panva/hkdf": "^1.0.4",
|
|
94
99
|
"cookie": "^0.5.0",
|
|
95
100
|
"jose": "^4.13.1",
|
|
@@ -120,13 +125,14 @@
|
|
|
120
125
|
"@aws-sdk/s3-request-presigner": "^3.420.0",
|
|
121
126
|
"@azure/storage-blob": "^12.17.0",
|
|
122
127
|
"@types/cookie": "^0.5.1",
|
|
123
|
-
"@types/node": "^
|
|
128
|
+
"@types/node": "^20",
|
|
124
129
|
"@types/uuid": "^9.0.1",
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"react
|
|
128
|
-
"
|
|
130
|
+
"fastify": "^5.3.2",
|
|
131
|
+
"next": "^15.2.4",
|
|
132
|
+
"react": "^19.0.0",
|
|
133
|
+
"react-dom": "^19.0.0",
|
|
134
|
+
"typescript": "^5",
|
|
129
135
|
"zod": "3.21.4"
|
|
130
136
|
},
|
|
131
|
-
"gitHead": "
|
|
137
|
+
"gitHead": "63d6ba86e038a61bfbf506385183482c91e80842"
|
|
132
138
|
}
|
|
@@ -49,7 +49,7 @@ export function createEdgeStoreExpressHandler<TCtx>(config: Config<TCtx>) {
|
|
|
49
49
|
const { provider = EdgeStoreProvider() } = config;
|
|
50
50
|
const log = new Logger(config.logLevel);
|
|
51
51
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
52
|
-
log.debug('Creating
|
|
52
|
+
log.debug('Creating EdgeStore Express handler');
|
|
53
53
|
|
|
54
54
|
return async (req: Request, res: Response) => {
|
|
55
55
|
try {
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EDGE_STORE_ERROR_CODES,
|
|
3
|
+
EdgeStoreError,
|
|
4
|
+
type EdgeStoreErrorCodeKey,
|
|
5
|
+
type EdgeStoreRouter,
|
|
6
|
+
type MaybePromise,
|
|
7
|
+
type Provider,
|
|
8
|
+
} from '@edgestore/shared';
|
|
9
|
+
import { type FastifyRequest, type FastifyReply } from 'fastify';
|
|
10
|
+
import Logger, { type LogLevel } from '../../libs/logger';
|
|
11
|
+
import { matchPath } from '../../libs/utils';
|
|
12
|
+
import { EdgeStoreProvider } from '../../providers/edgestore';
|
|
13
|
+
import {
|
|
14
|
+
completeMultipartUpload,
|
|
15
|
+
confirmUpload,
|
|
16
|
+
deleteFile,
|
|
17
|
+
init,
|
|
18
|
+
requestUpload,
|
|
19
|
+
requestUploadParts,
|
|
20
|
+
type CompleteMultipartUploadBody,
|
|
21
|
+
type ConfirmUploadBody,
|
|
22
|
+
type DeleteFileBody,
|
|
23
|
+
type RequestUploadBody,
|
|
24
|
+
type RequestUploadPartsParams,
|
|
25
|
+
} from '../shared';
|
|
26
|
+
|
|
27
|
+
export type CreateContextOptions = {
|
|
28
|
+
req: FastifyRequest;
|
|
29
|
+
reply: FastifyReply;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type Config<TCtx> = {
|
|
33
|
+
provider?: Provider;
|
|
34
|
+
router: EdgeStoreRouter<TCtx>;
|
|
35
|
+
logLevel?: LogLevel;
|
|
36
|
+
} & (TCtx extends Record<string, never>
|
|
37
|
+
? object
|
|
38
|
+
: {
|
|
39
|
+
provider?: Provider;
|
|
40
|
+
router: EdgeStoreRouter<TCtx>;
|
|
41
|
+
createContext: (opts: CreateContextOptions) => MaybePromise<TCtx>;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
declare const globalThis: {
|
|
45
|
+
_EDGE_STORE_LOGGER: Logger;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Helper to safely get cookies from Fastify request
|
|
49
|
+
function getCookie(req: FastifyRequest, name: string): string | undefined {
|
|
50
|
+
// Check if cookies plugin is available
|
|
51
|
+
if ('cookies' in req) {
|
|
52
|
+
// Type assertion for TypeScript
|
|
53
|
+
return (req as any).cookies[name];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Fallback to parsing cookie header
|
|
57
|
+
const cookieHeader = req.headers.cookie;
|
|
58
|
+
if (!cookieHeader) return undefined;
|
|
59
|
+
|
|
60
|
+
const cookies = cookieHeader.split(';').reduce<Record<string, string>>((acc, cookie) => {
|
|
61
|
+
const [key, value] = cookie.trim().split('=');
|
|
62
|
+
if (key && value) acc[key] = value;
|
|
63
|
+
return acc;
|
|
64
|
+
}, {});
|
|
65
|
+
|
|
66
|
+
return cookies[name];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>) {
|
|
70
|
+
const { provider = EdgeStoreProvider() } = config;
|
|
71
|
+
const log = new Logger(config.logLevel);
|
|
72
|
+
globalThis._EDGE_STORE_LOGGER = log;
|
|
73
|
+
log.debug('Creating EdgeStore Fastify handler');
|
|
74
|
+
|
|
75
|
+
return async (req: FastifyRequest, reply: FastifyReply) => {
|
|
76
|
+
try {
|
|
77
|
+
// Get the URL from the request - simplified approach
|
|
78
|
+
const pathname = req.url;
|
|
79
|
+
|
|
80
|
+
if (matchPath(pathname, '/health')) {
|
|
81
|
+
return reply.send('OK');
|
|
82
|
+
} else if (matchPath(pathname, '/init')) {
|
|
83
|
+
let ctx = {} as TCtx;
|
|
84
|
+
try {
|
|
85
|
+
ctx =
|
|
86
|
+
'createContext' in config
|
|
87
|
+
? await config.createContext({ req, reply })
|
|
88
|
+
: ({} as TCtx);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
throw new EdgeStoreError({
|
|
91
|
+
message: 'Error creating context',
|
|
92
|
+
code: 'CREATE_CONTEXT_ERROR',
|
|
93
|
+
cause: err instanceof Error ? err : undefined,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const { newCookies, token, baseUrl } = await init({
|
|
97
|
+
ctx,
|
|
98
|
+
provider,
|
|
99
|
+
router: config.router,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Set cookies more efficiently - handling them using void operator
|
|
103
|
+
// to explicitly mark these synchronous calls as intentionally not awaited
|
|
104
|
+
if (Array.isArray(newCookies)) {
|
|
105
|
+
// If it's an array of cookies, set them all
|
|
106
|
+
for (const cookie of newCookies) {
|
|
107
|
+
void reply.header('Set-Cookie', cookie);
|
|
108
|
+
}
|
|
109
|
+
} else if (newCookies) {
|
|
110
|
+
// If it's a single cookie string
|
|
111
|
+
void reply.header('Set-Cookie', newCookies);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return reply.send({
|
|
115
|
+
token,
|
|
116
|
+
baseUrl,
|
|
117
|
+
});
|
|
118
|
+
} else if (matchPath(pathname, '/request-upload')) {
|
|
119
|
+
return reply.send(
|
|
120
|
+
await requestUpload({
|
|
121
|
+
provider,
|
|
122
|
+
router: config.router,
|
|
123
|
+
body: req.body as RequestUploadBody,
|
|
124
|
+
ctxToken: getCookie(req, 'edgestore-ctx'),
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
} else if (matchPath(pathname, '/request-upload-parts')) {
|
|
128
|
+
return reply.send(
|
|
129
|
+
await requestUploadParts({
|
|
130
|
+
provider,
|
|
131
|
+
router: config.router,
|
|
132
|
+
body: req.body as RequestUploadPartsParams,
|
|
133
|
+
ctxToken: getCookie(req, 'edgestore-ctx'),
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
} else if (matchPath(pathname, '/complete-multipart-upload')) {
|
|
137
|
+
await completeMultipartUpload({
|
|
138
|
+
provider,
|
|
139
|
+
router: config.router,
|
|
140
|
+
body: req.body as CompleteMultipartUploadBody,
|
|
141
|
+
ctxToken: getCookie(req, 'edgestore-ctx'),
|
|
142
|
+
});
|
|
143
|
+
return reply.status(200).send();
|
|
144
|
+
} else if (matchPath(pathname, '/confirm-upload')) {
|
|
145
|
+
return reply.send(
|
|
146
|
+
await confirmUpload({
|
|
147
|
+
provider,
|
|
148
|
+
router: config.router,
|
|
149
|
+
body: req.body as ConfirmUploadBody,
|
|
150
|
+
ctxToken: getCookie(req, 'edgestore-ctx'),
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
} else if (matchPath(pathname, '/delete-file')) {
|
|
154
|
+
return reply.send(
|
|
155
|
+
await deleteFile({
|
|
156
|
+
provider,
|
|
157
|
+
router: config.router,
|
|
158
|
+
body: req.body as DeleteFileBody,
|
|
159
|
+
ctxToken: getCookie(req, 'edgestore-ctx'),
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
162
|
+
} else if (matchPath(pathname, '/proxy-file')) {
|
|
163
|
+
const url = req.query ? (req.query as Record<string, any>).url : undefined;
|
|
164
|
+
|
|
165
|
+
if (typeof url === 'string') {
|
|
166
|
+
const cookieHeader = req.headers.cookie ?? '';
|
|
167
|
+
|
|
168
|
+
const proxyRes = await fetch(url, {
|
|
169
|
+
headers: {
|
|
170
|
+
cookie: cookieHeader,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const data = await proxyRes.arrayBuffer();
|
|
175
|
+
void reply.header(
|
|
176
|
+
'Content-Type',
|
|
177
|
+
proxyRes.headers.get('Content-Type') ?? 'application/octet-stream',
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return reply.send(Buffer.from(data));
|
|
181
|
+
} else {
|
|
182
|
+
return reply.status(400).send();
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
return reply.status(404).send();
|
|
186
|
+
}
|
|
187
|
+
} catch (err) {
|
|
188
|
+
if (err instanceof EdgeStoreError) {
|
|
189
|
+
log[err.level](err.formattedMessage());
|
|
190
|
+
if (err.cause) log[err.level](err.cause);
|
|
191
|
+
return reply
|
|
192
|
+
.status(EDGE_STORE_ERROR_CODES[err.code as EdgeStoreErrorCodeKey])
|
|
193
|
+
.send(err.formattedJson());
|
|
194
|
+
} else {
|
|
195
|
+
log.error(err);
|
|
196
|
+
return reply.status(500).send(
|
|
197
|
+
new EdgeStoreError({
|
|
198
|
+
message: 'Internal Server Error',
|
|
199
|
+
code: 'SERVER_ERROR',
|
|
200
|
+
}).formattedJson(),
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -48,7 +48,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
|
|
|
48
48
|
const { provider = EdgeStoreProvider() } = config;
|
|
49
49
|
const log = new Logger(config.logLevel);
|
|
50
50
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
51
|
-
log.debug('Creating
|
|
51
|
+
log.debug('Creating EdgeStore Next handler (app adapter)');
|
|
52
52
|
|
|
53
53
|
return async (req: NextRequest) => {
|
|
54
54
|
try {
|
|
@@ -49,7 +49,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
|
|
|
49
49
|
const { provider = EdgeStoreProvider() } = config;
|
|
50
50
|
const log = new Logger(config.logLevel);
|
|
51
51
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
52
|
-
log.debug('Creating
|
|
52
|
+
log.debug('Creating EdgeStore Next handler (pages adapter)');
|
|
53
53
|
|
|
54
54
|
return async (req: NextApiRequest, res: NextApiResponse) => {
|
|
55
55
|
try {
|
package/src/adapters/shared.ts
CHANGED
|
@@ -63,7 +63,7 @@ export function createEdgeStoreStartHandler<TCtx>(config: Config<TCtx>) {
|
|
|
63
63
|
const { provider = EdgeStoreProvider() } = config;
|
|
64
64
|
const log = new Logger(config.logLevel);
|
|
65
65
|
globalThis._EDGE_STORE_LOGGER = log;
|
|
66
|
-
log.debug('Creating
|
|
66
|
+
log.debug('Creating EdgeStore TanStack Start handler');
|
|
67
67
|
|
|
68
68
|
return async ({ request }: { request: Request }) => {
|
|
69
69
|
try {
|
package/src/core/client/index.ts
CHANGED
|
@@ -432,7 +432,15 @@ async function getBlobFromUrl(url: string) {
|
|
|
432
432
|
export type InferClientResponse<TRouter extends AnyRouter> = {
|
|
433
433
|
[TBucketName in keyof TRouter['buckets']]: {
|
|
434
434
|
[TClienFn in keyof EdgeStoreClient<TRouter>[TBucketName]]: Simplify<
|
|
435
|
-
Awaited<
|
|
435
|
+
Awaited<
|
|
436
|
+
ReturnType<
|
|
437
|
+
EdgeStoreClient<TRouter>[TBucketName][TClienFn] extends (
|
|
438
|
+
...args: any
|
|
439
|
+
) => any
|
|
440
|
+
? EdgeStoreClient<TRouter>[TBucketName][TClienFn]
|
|
441
|
+
: never
|
|
442
|
+
>
|
|
443
|
+
>
|
|
436
444
|
>;
|
|
437
445
|
};
|
|
438
446
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
|
|
2
|
-
This can happen if you are trying to import something related to the backend of
|
|
2
|
+
This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
|
|
3
3
|
|
|
4
4
|
class EdgeStoreCredentialsError extends Error {
|
|
5
5
|
constructor(message = DEFAULT_MESSAGE) {
|
|
@@ -33,6 +33,17 @@ export type AWSProviderOptions = {
|
|
|
33
33
|
* Can also be set via the `ES_AWS_BUCKET_NAME` environment variable.
|
|
34
34
|
*/
|
|
35
35
|
bucketName?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Custom endpoint for S3-compatible storage providers (e.g., MinIO).
|
|
38
|
+
* Can also be set via the `ES_AWS_ENDPOINT` environment variable.
|
|
39
|
+
*/
|
|
40
|
+
endpoint?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Force path style for S3-compatible storage providers.
|
|
43
|
+
* Can also be set via the `ES_AWS_FORCE_PATH_STYLE` environment variable.
|
|
44
|
+
* Defaults to false for AWS S3, but should be true for most S3-compatible providers.
|
|
45
|
+
*/
|
|
46
|
+
forcePathStyle?: boolean;
|
|
36
47
|
/**
|
|
37
48
|
* Base URL to use for accessing files.
|
|
38
49
|
* Only needed if you are using a custom domain or cloudfront.
|
|
@@ -55,12 +66,16 @@ export function AWSProvider(options?: AWSProviderOptions): Provider {
|
|
|
55
66
|
secretAccessKey = process.env.ES_AWS_SECRET_ACCESS_KEY,
|
|
56
67
|
region = process.env.ES_AWS_REGION,
|
|
57
68
|
bucketName = process.env.ES_AWS_BUCKET_NAME,
|
|
69
|
+
endpoint = process.env.ES_AWS_ENDPOINT,
|
|
70
|
+
forcePathStyle = process.env.ES_AWS_FORCE_PATH_STYLE === 'true',
|
|
58
71
|
} = options ?? {};
|
|
59
72
|
|
|
60
73
|
const baseUrl =
|
|
61
74
|
options?.baseUrl ??
|
|
62
75
|
process.env.EDGE_STORE_BASE_URL ??
|
|
63
|
-
|
|
76
|
+
(endpoint
|
|
77
|
+
? `${endpoint}/${bucketName}`
|
|
78
|
+
: `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
64
79
|
|
|
65
80
|
const credentials =
|
|
66
81
|
accessKeyId && secretAccessKey
|
|
@@ -69,7 +84,12 @@ export function AWSProvider(options?: AWSProviderOptions): Provider {
|
|
|
69
84
|
secretAccessKey,
|
|
70
85
|
}
|
|
71
86
|
: undefined;
|
|
72
|
-
const s3Client = new S3Client({
|
|
87
|
+
const s3Client = new S3Client({
|
|
88
|
+
region,
|
|
89
|
+
credentials,
|
|
90
|
+
endpoint,
|
|
91
|
+
forcePathStyle,
|
|
92
|
+
});
|
|
73
93
|
|
|
74
94
|
return {
|
|
75
95
|
async init() {
|