@edgestore/server 0.7.0 → 0.8.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/dist/adapters/astro/index.d.ts.map +1 -1
- package/dist/adapters/astro/index.js +9 -15
- package/dist/adapters/astro/index.mjs +10 -16
- package/dist/adapters/express/index.d.ts.map +1 -1
- package/dist/adapters/express/index.js +8 -13
- package/dist/adapters/express/index.mjs +9 -14
- package/dist/adapters/fastify/index.d.ts +1 -1
- package/dist/adapters/fastify/index.d.ts.map +1 -1
- package/dist/adapters/fastify/index.js +7 -14
- package/dist/adapters/fastify/index.mjs +8 -15
- package/dist/adapters/hono/index.d.ts +4 -70
- package/dist/adapters/hono/index.d.ts.map +1 -1
- package/dist/adapters/hono/index.js +12 -13
- package/dist/adapters/hono/index.mjs +13 -14
- package/dist/adapters/next/app/index.d.ts.map +1 -1
- package/dist/adapters/next/app/index.js +7 -13
- package/dist/adapters/next/app/index.mjs +8 -14
- package/dist/adapters/next/pages/index.d.ts.map +1 -1
- package/dist/adapters/next/pages/index.js +8 -13
- package/dist/adapters/next/pages/index.mjs +9 -14
- package/dist/adapters/remix/index.d.ts.map +1 -1
- package/dist/adapters/remix/index.js +9 -14
- package/dist/adapters/remix/index.mjs +10 -15
- package/dist/adapters/shared.d.ts +8 -0
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/shared.js +36 -7
- package/dist/adapters/shared.mjs +36 -8
- package/dist/adapters/start/index.d.ts.map +1 -1
- package/dist/adapters/start/index.js +9 -15
- package/dist/adapters/start/index.mjs +10 -16
- package/dist/core/client/index.d.ts +112 -69
- package/dist/core/client/index.d.ts.map +1 -1
- package/dist/core/client/index.js +52 -4
- package/dist/core/client/index.mjs +52 -4
- package/dist/core/sdk/index.d.ts +44 -2
- package/dist/core/sdk/index.d.ts.map +1 -1
- package/dist/core/sdk/index.js +36 -6
- package/dist/core/sdk/index.mjs +36 -6
- package/dist/providers/aws/index.d.ts +1 -1
- package/dist/providers/aws/index.d.ts.map +1 -1
- package/dist/providers/aws/index.js +3 -3
- package/dist/providers/aws/index.mjs +3 -3
- package/dist/providers/azure/index.d.ts.map +1 -1
- package/dist/providers/azure/index.js +33 -7
- package/dist/providers/azure/index.mjs +33 -7
- package/dist/providers/edgestore/index.d.ts.map +1 -1
- package/dist/providers/edgestore/index.js +24 -4
- package/dist/providers/edgestore/index.mjs +24 -4
- package/dist/test-utils/edgestoreSmoke.d.ts +32 -0
- package/dist/test-utils/edgestoreSmoke.d.ts.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.mjs +4 -0
- package/package.json +11 -2
- package/src/adapters/astro/index.ts +11 -21
- package/src/adapters/express/index.ts +10 -16
- package/src/adapters/fastify/index.ts +13 -19
- package/src/adapters/hono/index.ts +19 -23
- package/src/adapters/next/app/index.ts +12 -22
- package/src/adapters/next/pages/index.ts +11 -16
- package/src/adapters/remix/index.ts +11 -12
- package/src/adapters/shared.ts +49 -4
- package/src/adapters/start/index.ts +11 -12
- package/src/core/client/index.ts +199 -74
- package/src/core/sdk/index.ts +75 -0
- package/src/providers/aws/index.ts +4 -4
- package/src/providers/azure/index.ts +40 -10
- package/src/providers/edgestore/index.ts +29 -0
- package/src/test-utils/edgestoreSmoke.ts +141 -0
- package/src/version.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/astro/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/astro/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAWL,KAAK,YAAY,EAIlB,MAAM,WAAW,CAAC;AAEnB,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;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,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,UAAU,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACxD,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC;AAsBP,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAQtD,SAAS,UAAU,uBAuJlC"}
|
|
@@ -40,7 +40,7 @@ function createEdgeStoreAstroHandler(config) {
|
|
|
40
40
|
cause: err instanceof Error ? err : undefined
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
const { newCookies,
|
|
43
|
+
const { newCookies, ...body } = await shared.init({
|
|
44
44
|
ctx,
|
|
45
45
|
provider,
|
|
46
46
|
router: config.router,
|
|
@@ -56,11 +56,7 @@ function createEdgeStoreAstroHandler(config) {
|
|
|
56
56
|
} else if (newCookies) {
|
|
57
57
|
headers.append('Set-Cookie', newCookies);
|
|
58
58
|
}
|
|
59
|
-
return new Response(JSON.stringify({
|
|
60
|
-
token,
|
|
61
|
-
baseUrl,
|
|
62
|
-
providerName
|
|
63
|
-
}), {
|
|
59
|
+
return new Response(JSON.stringify(body), {
|
|
64
60
|
headers
|
|
65
61
|
});
|
|
66
62
|
} else if (utils.matchPath(url.pathname, 'request-upload')) {
|
|
@@ -129,17 +125,15 @@ function createEdgeStoreAstroHandler(config) {
|
|
|
129
125
|
} else if (utils.matchPath(url.pathname, 'proxy-file')) {
|
|
130
126
|
const url = new URL(request.url).searchParams.get('url');
|
|
131
127
|
if (typeof url === 'string') {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
cookie: cookieHeader
|
|
136
|
-
}
|
|
128
|
+
const proxyRes = await shared.fetchProxyFile({
|
|
129
|
+
cookieHeader: request.headers.get('cookie') ?? undefined,
|
|
130
|
+
url
|
|
137
131
|
});
|
|
138
|
-
const data = await proxyRes.arrayBuffer();
|
|
139
132
|
const headers = new Headers();
|
|
140
|
-
headers.set('Content-Type', proxyRes.
|
|
141
|
-
return new Response(
|
|
142
|
-
headers
|
|
133
|
+
headers.set('Content-Type', proxyRes.contentType);
|
|
134
|
+
return new Response(proxyRes.body, {
|
|
135
|
+
headers,
|
|
136
|
+
status: proxyRes.status
|
|
143
137
|
});
|
|
144
138
|
} else {
|
|
145
139
|
return new Response(null, {
|
|
@@ -2,7 +2,7 @@ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
|
2
2
|
import Logger from '../../libs/logger.mjs';
|
|
3
3
|
import { matchPath } from '../../libs/utils.mjs';
|
|
4
4
|
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
5
|
-
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile } from '../shared.mjs';
|
|
5
|
+
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../shared.mjs';
|
|
6
6
|
|
|
7
7
|
// Helper to safely get cookies from Astro request
|
|
8
8
|
function getCookie(request, name) {
|
|
@@ -38,7 +38,7 @@ function createEdgeStoreAstroHandler(config) {
|
|
|
38
38
|
cause: err instanceof Error ? err : undefined
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
const { newCookies,
|
|
41
|
+
const { newCookies, ...body } = await init({
|
|
42
42
|
ctx,
|
|
43
43
|
provider,
|
|
44
44
|
router: config.router,
|
|
@@ -54,11 +54,7 @@ function createEdgeStoreAstroHandler(config) {
|
|
|
54
54
|
} else if (newCookies) {
|
|
55
55
|
headers.append('Set-Cookie', newCookies);
|
|
56
56
|
}
|
|
57
|
-
return new Response(JSON.stringify({
|
|
58
|
-
token,
|
|
59
|
-
baseUrl,
|
|
60
|
-
providerName
|
|
61
|
-
}), {
|
|
57
|
+
return new Response(JSON.stringify(body), {
|
|
62
58
|
headers
|
|
63
59
|
});
|
|
64
60
|
} else if (matchPath(url.pathname, 'request-upload')) {
|
|
@@ -127,17 +123,15 @@ function createEdgeStoreAstroHandler(config) {
|
|
|
127
123
|
} else if (matchPath(url.pathname, 'proxy-file')) {
|
|
128
124
|
const url = new URL(request.url).searchParams.get('url');
|
|
129
125
|
if (typeof url === 'string') {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
cookie: cookieHeader
|
|
134
|
-
}
|
|
126
|
+
const proxyRes = await fetchProxyFile({
|
|
127
|
+
cookieHeader: request.headers.get('cookie') ?? undefined,
|
|
128
|
+
url
|
|
135
129
|
});
|
|
136
|
-
const data = await proxyRes.arrayBuffer();
|
|
137
130
|
const headers = new Headers();
|
|
138
|
-
headers.set('Content-Type', proxyRes.
|
|
139
|
-
return new Response(
|
|
140
|
-
headers
|
|
131
|
+
headers.set('Content-Type', proxyRes.contentType);
|
|
132
|
+
return new Response(proxyRes.body, {
|
|
133
|
+
headers,
|
|
134
|
+
status: proxyRes.status
|
|
141
135
|
});
|
|
142
136
|
} else {
|
|
143
137
|
return new Response(null, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/express/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/express/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAWL,KAAK,YAAY,EAIlB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,QAAQ,CAAC;CACf,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;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,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;IAClE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC;AAMP,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAQxD,KAAK,OAAO,EAAE,KAAK,QAAQ,mBA4G1C"}
|
|
@@ -31,18 +31,14 @@ function createEdgeStoreExpressHandler(config) {
|
|
|
31
31
|
cause: err instanceof Error ? err : undefined
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
const { newCookies,
|
|
34
|
+
const { newCookies, ...body } = await shared.init({
|
|
35
35
|
ctx,
|
|
36
36
|
provider,
|
|
37
37
|
router: config.router,
|
|
38
38
|
cookieConfig
|
|
39
39
|
});
|
|
40
40
|
res.setHeader('Set-Cookie', newCookies);
|
|
41
|
-
res.json(
|
|
42
|
-
token,
|
|
43
|
-
baseUrl,
|
|
44
|
-
providerName
|
|
45
|
-
});
|
|
41
|
+
res.json(body);
|
|
46
42
|
} else if (utils.matchPath(pathname, '/request-upload')) {
|
|
47
43
|
res.json(await shared.requestUpload({
|
|
48
44
|
provider,
|
|
@@ -82,14 +78,13 @@ function createEdgeStoreExpressHandler(config) {
|
|
|
82
78
|
} else if (utils.matchPath(pathname, '/proxy-file')) {
|
|
83
79
|
const { url } = req.query;
|
|
84
80
|
if (typeof url === 'string') {
|
|
85
|
-
const proxyRes = await
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
81
|
+
const proxyRes = await shared.fetchProxyFile({
|
|
82
|
+
cookieHeader: req.headers.cookie,
|
|
83
|
+
url
|
|
89
84
|
});
|
|
90
|
-
|
|
91
|
-
res.
|
|
92
|
-
res.end(Buffer.from(
|
|
85
|
+
res.setHeader('Content-Type', proxyRes.contentType);
|
|
86
|
+
res.status(proxyRes.status);
|
|
87
|
+
res.end(proxyRes.body === null ? undefined : Buffer.from(proxyRes.body));
|
|
93
88
|
} else {
|
|
94
89
|
res.status(400).end();
|
|
95
90
|
}
|
|
@@ -2,7 +2,7 @@ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
|
2
2
|
import Logger from '../../libs/logger.mjs';
|
|
3
3
|
import { matchPath } from '../../libs/utils.mjs';
|
|
4
4
|
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
5
|
-
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile } from '../shared.mjs';
|
|
5
|
+
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../shared.mjs';
|
|
6
6
|
|
|
7
7
|
function createEdgeStoreExpressHandler(config) {
|
|
8
8
|
const { provider = EdgeStoreProvider(), cookieConfig } = config;
|
|
@@ -29,18 +29,14 @@ function createEdgeStoreExpressHandler(config) {
|
|
|
29
29
|
cause: err instanceof Error ? err : undefined
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
const { newCookies,
|
|
32
|
+
const { newCookies, ...body } = await init({
|
|
33
33
|
ctx,
|
|
34
34
|
provider,
|
|
35
35
|
router: config.router,
|
|
36
36
|
cookieConfig
|
|
37
37
|
});
|
|
38
38
|
res.setHeader('Set-Cookie', newCookies);
|
|
39
|
-
res.json(
|
|
40
|
-
token,
|
|
41
|
-
baseUrl,
|
|
42
|
-
providerName
|
|
43
|
-
});
|
|
39
|
+
res.json(body);
|
|
44
40
|
} else if (matchPath(pathname, '/request-upload')) {
|
|
45
41
|
res.json(await requestUpload({
|
|
46
42
|
provider,
|
|
@@ -80,14 +76,13 @@ function createEdgeStoreExpressHandler(config) {
|
|
|
80
76
|
} else if (matchPath(pathname, '/proxy-file')) {
|
|
81
77
|
const { url } = req.query;
|
|
82
78
|
if (typeof url === 'string') {
|
|
83
|
-
const proxyRes = await
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
79
|
+
const proxyRes = await fetchProxyFile({
|
|
80
|
+
cookieHeader: req.headers.cookie,
|
|
81
|
+
url
|
|
87
82
|
});
|
|
88
|
-
|
|
89
|
-
res.
|
|
90
|
-
res.end(Buffer.from(
|
|
83
|
+
res.setHeader('Content-Type', proxyRes.contentType);
|
|
84
|
+
res.status(proxyRes.status);
|
|
85
|
+
res.end(proxyRes.body === null ? undefined : Buffer.from(proxyRes.body));
|
|
91
86
|
} else {
|
|
92
87
|
res.status(400).end();
|
|
93
88
|
}
|
|
@@ -17,5 +17,5 @@ export type Config<TCtx> = {
|
|
|
17
17
|
createContext: (opts: CreateContextOptions) => MaybePromise<TCtx>;
|
|
18
18
|
cookieConfig?: CookieConfig;
|
|
19
19
|
});
|
|
20
|
-
export declare function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>): (req: FastifyRequest, reply: FastifyReply) => Promise<
|
|
20
|
+
export declare function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>): (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
21
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACjE,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,
|
|
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,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACjE,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAWL,KAAK,YAAY,EAIlB,MAAM,WAAW,CAAC;AAEnB,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;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,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;IAClE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC;AA6BP,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAQxD,KAAK,cAAc,EAAE,OAAO,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC,CA+HvE"}
|
|
@@ -49,7 +49,7 @@ function createEdgeStoreFastifyHandler(config) {
|
|
|
49
49
|
cause: err instanceof Error ? err : undefined
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
const { newCookies,
|
|
52
|
+
const { newCookies, ...body } = await shared.init({
|
|
53
53
|
ctx,
|
|
54
54
|
provider,
|
|
55
55
|
router: config.router,
|
|
@@ -66,11 +66,7 @@ function createEdgeStoreFastifyHandler(config) {
|
|
|
66
66
|
// If it's a single cookie string
|
|
67
67
|
void reply.header('Set-Cookie', newCookies);
|
|
68
68
|
}
|
|
69
|
-
return reply.send(
|
|
70
|
-
token,
|
|
71
|
-
baseUrl,
|
|
72
|
-
providerName
|
|
73
|
-
});
|
|
69
|
+
return reply.send(body);
|
|
74
70
|
} else if (utils.matchPath(pathname, '/request-upload')) {
|
|
75
71
|
return reply.send(await shared.requestUpload({
|
|
76
72
|
provider,
|
|
@@ -110,15 +106,12 @@ function createEdgeStoreFastifyHandler(config) {
|
|
|
110
106
|
} else if (utils.matchPath(pathname, '/proxy-file')) {
|
|
111
107
|
const url = req.query ? req.query.url : undefined;
|
|
112
108
|
if (typeof url === 'string') {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
cookie: cookieHeader
|
|
117
|
-
}
|
|
109
|
+
const proxyRes = await shared.fetchProxyFile({
|
|
110
|
+
cookieHeader: req.headers.cookie,
|
|
111
|
+
url
|
|
118
112
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return reply.send(Buffer.from(data));
|
|
113
|
+
void reply.header('Content-Type', proxyRes.contentType);
|
|
114
|
+
return reply.status(proxyRes.status).send(proxyRes.body === null ? undefined : Buffer.from(proxyRes.body));
|
|
122
115
|
} else {
|
|
123
116
|
return reply.status(400).send();
|
|
124
117
|
}
|
|
@@ -2,7 +2,7 @@ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
|
2
2
|
import Logger from '../../libs/logger.mjs';
|
|
3
3
|
import { matchPath } from '../../libs/utils.mjs';
|
|
4
4
|
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
5
|
-
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile } from '../shared.mjs';
|
|
5
|
+
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../shared.mjs';
|
|
6
6
|
|
|
7
7
|
// Helper to safely get cookies from Fastify request
|
|
8
8
|
function getCookie(req, name) {
|
|
@@ -47,7 +47,7 @@ function createEdgeStoreFastifyHandler(config) {
|
|
|
47
47
|
cause: err instanceof Error ? err : undefined
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
const { newCookies,
|
|
50
|
+
const { newCookies, ...body } = await init({
|
|
51
51
|
ctx,
|
|
52
52
|
provider,
|
|
53
53
|
router: config.router,
|
|
@@ -64,11 +64,7 @@ function createEdgeStoreFastifyHandler(config) {
|
|
|
64
64
|
// If it's a single cookie string
|
|
65
65
|
void reply.header('Set-Cookie', newCookies);
|
|
66
66
|
}
|
|
67
|
-
return reply.send(
|
|
68
|
-
token,
|
|
69
|
-
baseUrl,
|
|
70
|
-
providerName
|
|
71
|
-
});
|
|
67
|
+
return reply.send(body);
|
|
72
68
|
} else if (matchPath(pathname, '/request-upload')) {
|
|
73
69
|
return reply.send(await requestUpload({
|
|
74
70
|
provider,
|
|
@@ -108,15 +104,12 @@ function createEdgeStoreFastifyHandler(config) {
|
|
|
108
104
|
} else if (matchPath(pathname, '/proxy-file')) {
|
|
109
105
|
const url = req.query ? req.query.url : undefined;
|
|
110
106
|
if (typeof url === 'string') {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
cookie: cookieHeader
|
|
115
|
-
}
|
|
107
|
+
const proxyRes = await fetchProxyFile({
|
|
108
|
+
cookieHeader: req.headers.cookie,
|
|
109
|
+
url
|
|
116
110
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return reply.send(Buffer.from(data));
|
|
111
|
+
void reply.header('Content-Type', proxyRes.contentType);
|
|
112
|
+
return reply.status(proxyRes.status).send(proxyRes.body === null ? undefined : Buffer.from(proxyRes.body));
|
|
120
113
|
} else {
|
|
121
114
|
return reply.status(400).send();
|
|
122
115
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type Context } from 'hono';
|
|
1
|
+
import { type EdgeStoreRouter, type MaybePromise, type Provider } from '@edgestore/shared';
|
|
2
|
+
import { type Context as HonoContext } from 'hono';
|
|
3
3
|
import { type LogLevel } from '../../libs/logger';
|
|
4
4
|
import { type CookieConfig } from '../shared';
|
|
5
5
|
export type CreateContextOptions = {
|
|
6
|
-
c:
|
|
6
|
+
c: HonoContext;
|
|
7
7
|
};
|
|
8
8
|
export type Config<TCtx> = {
|
|
9
9
|
provider?: Provider;
|
|
@@ -16,71 +16,5 @@ export type Config<TCtx> = {
|
|
|
16
16
|
createContext: (opts: CreateContextOptions) => MaybePromise<TCtx>;
|
|
17
17
|
cookieConfig?: CookieConfig;
|
|
18
18
|
});
|
|
19
|
-
export declare function createEdgeStoreHonoHandler<TCtx>(config: Config<TCtx>): (c:
|
|
20
|
-
token: string | undefined;
|
|
21
|
-
baseUrl: string;
|
|
22
|
-
providerName: string;
|
|
23
|
-
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
24
|
-
uploadUrl: string;
|
|
25
|
-
accessUrl: string;
|
|
26
|
-
thumbnailUrl?: string | null | undefined;
|
|
27
|
-
size: number;
|
|
28
|
-
uploadedAt: string;
|
|
29
|
-
path: {
|
|
30
|
-
[x: string]: string;
|
|
31
|
-
};
|
|
32
|
-
pathOrder: string[];
|
|
33
|
-
metadata: {
|
|
34
|
-
[x: string]: string | null | undefined;
|
|
35
|
-
};
|
|
36
|
-
} | {
|
|
37
|
-
multipart: {
|
|
38
|
-
key: string;
|
|
39
|
-
uploadId: string;
|
|
40
|
-
partSize: number;
|
|
41
|
-
totalParts: number;
|
|
42
|
-
parts: {
|
|
43
|
-
partNumber: number;
|
|
44
|
-
uploadUrl: string;
|
|
45
|
-
}[];
|
|
46
|
-
};
|
|
47
|
-
accessUrl: string;
|
|
48
|
-
thumbnailUrl?: string | null | undefined;
|
|
49
|
-
size: number;
|
|
50
|
-
uploadedAt: string;
|
|
51
|
-
path: {
|
|
52
|
-
[x: string]: string;
|
|
53
|
-
};
|
|
54
|
-
pathOrder: string[];
|
|
55
|
-
metadata: {
|
|
56
|
-
[x: string]: string | null | undefined;
|
|
57
|
-
};
|
|
58
|
-
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
59
|
-
multipart: {
|
|
60
|
-
uploadId: string;
|
|
61
|
-
parts: {
|
|
62
|
-
partNumber: number;
|
|
63
|
-
uploadUrl: string;
|
|
64
|
-
}[];
|
|
65
|
-
};
|
|
66
|
-
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
67
|
-
success: boolean;
|
|
68
|
-
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<unknown, import("hono/utils/http-status").ContentfulStatusCode, "body">) | (Response & import("hono").TypedResponse<{
|
|
69
|
-
message: string;
|
|
70
|
-
code: "FILE_TOO_LARGE";
|
|
71
|
-
details: {
|
|
72
|
-
maxFileSize: number;
|
|
73
|
-
fileSize: number;
|
|
74
|
-
};
|
|
75
|
-
} | {
|
|
76
|
-
message: string;
|
|
77
|
-
code: "MIME_TYPE_NOT_ALLOWED";
|
|
78
|
-
details: {
|
|
79
|
-
allowedMimeTypes: string[];
|
|
80
|
-
mimeType: string;
|
|
81
|
-
};
|
|
82
|
-
} | {
|
|
83
|
-
message: string;
|
|
84
|
-
code: Exclude<EdgeStoreErrorCodeKey, "FILE_TOO_LARGE" | "MIME_TYPE_NOT_ALLOWED">;
|
|
85
|
-
}, 400 | 401 | 403 | 500, "json">)>;
|
|
19
|
+
export declare function createEdgeStoreHonoHandler<TCtx>(config: Config<TCtx>): (c: HonoContext) => Promise<Response>;
|
|
86
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AACnD,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAWL,KAAK,YAAY,EAIlB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,oBAAoB,GAAG;IACjC,CAAC,EAAE,WAAW,CAAC;CAChB,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;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,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;IAClE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC;AAeP,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAQrD,GAAG,WAAW,KAAG,OAAO,CAAC,QAAQ,CAAC,CAkIjD"}
|
|
@@ -37,7 +37,7 @@ function createEdgeStoreHonoHandler(config) {
|
|
|
37
37
|
cause: err instanceof Error ? err : undefined
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const { newCookies,
|
|
40
|
+
const { newCookies, ...body } = await shared.init({
|
|
41
41
|
ctx,
|
|
42
42
|
provider,
|
|
43
43
|
router: config.router,
|
|
@@ -46,16 +46,14 @@ function createEdgeStoreHonoHandler(config) {
|
|
|
46
46
|
// Set cookies
|
|
47
47
|
if (Array.isArray(newCookies)) {
|
|
48
48
|
for (const cookie of newCookies){
|
|
49
|
-
c.header('Set-Cookie', cookie
|
|
49
|
+
c.header('Set-Cookie', cookie, {
|
|
50
|
+
append: true
|
|
51
|
+
});
|
|
50
52
|
}
|
|
51
53
|
} else if (newCookies) {
|
|
52
54
|
c.header('Set-Cookie', newCookies);
|
|
53
55
|
}
|
|
54
|
-
return c.json(
|
|
55
|
-
token,
|
|
56
|
-
baseUrl,
|
|
57
|
-
providerName
|
|
58
|
-
});
|
|
56
|
+
return c.json(body);
|
|
59
57
|
} else if (utils.matchPath(pathname, '/request-upload')) {
|
|
60
58
|
const body = await c.req.json();
|
|
61
59
|
return c.json(await shared.requestUpload({
|
|
@@ -100,15 +98,16 @@ function createEdgeStoreHonoHandler(config) {
|
|
|
100
98
|
} else if (utils.matchPath(pathname, '/proxy-file')) {
|
|
101
99
|
const url = c.req.query('url');
|
|
102
100
|
if (typeof url === 'string') {
|
|
103
|
-
const
|
|
104
|
-
|
|
101
|
+
const proxyRes = await shared.fetchProxyFile({
|
|
102
|
+
cookieHeader: c.req.header('cookie'),
|
|
103
|
+
url
|
|
104
|
+
});
|
|
105
|
+
return new Response(proxyRes.body === null ? null : Buffer.from(proxyRes.body), {
|
|
106
|
+
status: proxyRes.status,
|
|
105
107
|
headers: {
|
|
106
|
-
|
|
108
|
+
'Content-Type': proxyRes.contentType
|
|
107
109
|
}
|
|
108
110
|
});
|
|
109
|
-
const data = await proxyRes.arrayBuffer();
|
|
110
|
-
c.header('Content-Type', proxyRes.headers.get('Content-Type') ?? 'application/octet-stream');
|
|
111
|
-
return c.body(Buffer.from(data));
|
|
112
111
|
} else {
|
|
113
112
|
return c.body(null, 400);
|
|
114
113
|
}
|
|
@@ -2,7 +2,7 @@ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
|
2
2
|
import Logger from '../../libs/logger.mjs';
|
|
3
3
|
import { matchPath } from '../../libs/utils.mjs';
|
|
4
4
|
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
5
|
-
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile } from '../shared.mjs';
|
|
5
|
+
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../shared.mjs';
|
|
6
6
|
|
|
7
7
|
// Helper to get a cookie value from Hono Context
|
|
8
8
|
function getCookie(c, name) {
|
|
@@ -35,7 +35,7 @@ function createEdgeStoreHonoHandler(config) {
|
|
|
35
35
|
cause: err instanceof Error ? err : undefined
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
const { newCookies,
|
|
38
|
+
const { newCookies, ...body } = await init({
|
|
39
39
|
ctx,
|
|
40
40
|
provider,
|
|
41
41
|
router: config.router,
|
|
@@ -44,16 +44,14 @@ function createEdgeStoreHonoHandler(config) {
|
|
|
44
44
|
// Set cookies
|
|
45
45
|
if (Array.isArray(newCookies)) {
|
|
46
46
|
for (const cookie of newCookies){
|
|
47
|
-
c.header('Set-Cookie', cookie
|
|
47
|
+
c.header('Set-Cookie', cookie, {
|
|
48
|
+
append: true
|
|
49
|
+
});
|
|
48
50
|
}
|
|
49
51
|
} else if (newCookies) {
|
|
50
52
|
c.header('Set-Cookie', newCookies);
|
|
51
53
|
}
|
|
52
|
-
return c.json(
|
|
53
|
-
token,
|
|
54
|
-
baseUrl,
|
|
55
|
-
providerName
|
|
56
|
-
});
|
|
54
|
+
return c.json(body);
|
|
57
55
|
} else if (matchPath(pathname, '/request-upload')) {
|
|
58
56
|
const body = await c.req.json();
|
|
59
57
|
return c.json(await requestUpload({
|
|
@@ -98,15 +96,16 @@ function createEdgeStoreHonoHandler(config) {
|
|
|
98
96
|
} else if (matchPath(pathname, '/proxy-file')) {
|
|
99
97
|
const url = c.req.query('url');
|
|
100
98
|
if (typeof url === 'string') {
|
|
101
|
-
const
|
|
102
|
-
|
|
99
|
+
const proxyRes = await fetchProxyFile({
|
|
100
|
+
cookieHeader: c.req.header('cookie'),
|
|
101
|
+
url
|
|
102
|
+
});
|
|
103
|
+
return new Response(proxyRes.body === null ? null : Buffer.from(proxyRes.body), {
|
|
104
|
+
status: proxyRes.status,
|
|
103
105
|
headers: {
|
|
104
|
-
|
|
106
|
+
'Content-Type': proxyRes.contentType
|
|
105
107
|
}
|
|
106
108
|
});
|
|
107
|
-
const data = await proxyRes.arrayBuffer();
|
|
108
|
-
c.header('Content-Type', proxyRes.headers.get('Content-Type') ?? 'application/octet-stream');
|
|
109
|
-
return c.body(Buffer.from(data));
|
|
110
109
|
} else {
|
|
111
110
|
return c.body(null, 400);
|
|
112
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/next/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/next/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,EAWL,KAAK,YAAY,EAIlB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,WAAW,CAAC;CAClB,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;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,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;IAClE,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC;AAMP,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAQrD,KAAK,WAAW,uBA+J/B"}
|
|
@@ -36,17 +36,13 @@ function createEdgeStoreNextHandler(config) {
|
|
|
36
36
|
cause: err instanceof Error ? err : undefined
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
const { newCookies,
|
|
39
|
+
const { newCookies, ...body } = await shared.init({
|
|
40
40
|
ctx,
|
|
41
41
|
provider,
|
|
42
42
|
router: config.router,
|
|
43
43
|
cookieConfig
|
|
44
44
|
});
|
|
45
|
-
const res = new Response(JSON.stringify({
|
|
46
|
-
token,
|
|
47
|
-
baseUrl,
|
|
48
|
-
providerName
|
|
49
|
-
}), {
|
|
45
|
+
const res = new Response(JSON.stringify(body), {
|
|
50
46
|
status: 200,
|
|
51
47
|
headers: {
|
|
52
48
|
'Content-Type': 'application/json'
|
|
@@ -121,16 +117,14 @@ function createEdgeStoreNextHandler(config) {
|
|
|
121
117
|
} else if (utils.matchPath(pathname, '/proxy-file')) {
|
|
122
118
|
const url = req.nextUrl.searchParams.get('url');
|
|
123
119
|
if (typeof url === 'string') {
|
|
124
|
-
const proxyRes = await
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
120
|
+
const proxyRes = await shared.fetchProxyFile({
|
|
121
|
+
cookieHeader: req.cookies.toString(),
|
|
122
|
+
url
|
|
128
123
|
});
|
|
129
|
-
|
|
130
|
-
return new Response(data, {
|
|
124
|
+
return new Response(proxyRes.body, {
|
|
131
125
|
status: proxyRes.status,
|
|
132
126
|
headers: {
|
|
133
|
-
'Content-Type': proxyRes.
|
|
127
|
+
'Content-Type': proxyRes.contentType
|
|
134
128
|
}
|
|
135
129
|
});
|
|
136
130
|
} else {
|
|
@@ -2,7 +2,7 @@ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
|
2
2
|
import Logger from '../../../libs/logger.mjs';
|
|
3
3
|
import { matchPath } from '../../../libs/utils.mjs';
|
|
4
4
|
import { EdgeStoreProvider } from '../../../providers/edgestore/index.mjs';
|
|
5
|
-
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile } from '../../shared.mjs';
|
|
5
|
+
import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../../shared.mjs';
|
|
6
6
|
|
|
7
7
|
function createEdgeStoreNextHandler(config) {
|
|
8
8
|
const { provider = EdgeStoreProvider(), cookieConfig } = config;
|
|
@@ -34,17 +34,13 @@ function createEdgeStoreNextHandler(config) {
|
|
|
34
34
|
cause: err instanceof Error ? err : undefined
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
const { newCookies,
|
|
37
|
+
const { newCookies, ...body } = await init({
|
|
38
38
|
ctx,
|
|
39
39
|
provider,
|
|
40
40
|
router: config.router,
|
|
41
41
|
cookieConfig
|
|
42
42
|
});
|
|
43
|
-
const res = new Response(JSON.stringify({
|
|
44
|
-
token,
|
|
45
|
-
baseUrl,
|
|
46
|
-
providerName
|
|
47
|
-
}), {
|
|
43
|
+
const res = new Response(JSON.stringify(body), {
|
|
48
44
|
status: 200,
|
|
49
45
|
headers: {
|
|
50
46
|
'Content-Type': 'application/json'
|
|
@@ -119,16 +115,14 @@ function createEdgeStoreNextHandler(config) {
|
|
|
119
115
|
} else if (matchPath(pathname, '/proxy-file')) {
|
|
120
116
|
const url = req.nextUrl.searchParams.get('url');
|
|
121
117
|
if (typeof url === 'string') {
|
|
122
|
-
const proxyRes = await
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
118
|
+
const proxyRes = await fetchProxyFile({
|
|
119
|
+
cookieHeader: req.cookies.toString(),
|
|
120
|
+
url
|
|
126
121
|
});
|
|
127
|
-
|
|
128
|
-
return new Response(data, {
|
|
122
|
+
return new Response(proxyRes.body, {
|
|
129
123
|
status: proxyRes.status,
|
|
130
124
|
headers: {
|
|
131
|
-
'Content-Type': proxyRes.
|
|
125
|
+
'Content-Type': proxyRes.contentType
|
|
132
126
|
}
|
|
133
127
|
});
|
|
134
128
|
} else {
|