@edgestore/server 0.1.4 → 0.1.5-alpha.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/next/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAK7E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAenD,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,IAAI,IAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACzD;IACE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;CAC/B,GACD;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;AAEN,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAEhD,WAAW,uBAyI/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/next/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAK7E,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAenD,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,IAAI,IAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACzD;IACE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;CAC/B,GACD;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;AAEN,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAEhD,WAAW,uBAqI/B"}
@@ -15,7 +15,7 @@ function createEdgeStoreNextHandler(config) {
15
15
  const { provider = providers_edgestore_index.EdgeStoreProvider() } = config;
16
16
  return async (req)=>{
17
17
  try {
18
- if (req.nextUrl.pathname === '/api/edgestore/init') {
18
+ if (req.nextUrl.pathname.endsWith('/init')) {
19
19
  const ctx = 'createContext' in config ? await config.createContext({
20
20
  req
21
21
  }) : {};
@@ -37,7 +37,7 @@ function createEdgeStoreNextHandler(config) {
37
37
  res.headers.append('Set-Cookie', cookie);
38
38
  }
39
39
  return res;
40
- } else if (req.nextUrl.pathname === '/api/edgestore/request-upload') {
40
+ } else if (req.nextUrl.pathname.endsWith('/request-upload')) {
41
41
  const res = await shared.requestUpload({
42
42
  provider,
43
43
  router: config.router,
@@ -50,7 +50,7 @@ function createEdgeStoreNextHandler(config) {
50
50
  'Content-Type': 'application/json'
51
51
  }
52
52
  });
53
- } else if (req.nextUrl.pathname === '/api/edgestore/request-upload-parts') {
53
+ } else if (req.nextUrl.pathname.endsWith('/request-upload-parts')) {
54
54
  const res = await shared.requestUploadParts({
55
55
  provider,
56
56
  router: config.router,
@@ -63,7 +63,7 @@ function createEdgeStoreNextHandler(config) {
63
63
  'Content-Type': 'application/json'
64
64
  }
65
65
  });
66
- } else if (req.nextUrl.pathname === '/api/edgestore/complete-multipart-upload') {
66
+ } else if (req.nextUrl.pathname.endsWith('/complete-multipart-upload')) {
67
67
  await shared.completeMultipartUpload({
68
68
  provider,
69
69
  router: config.router,
@@ -73,7 +73,7 @@ function createEdgeStoreNextHandler(config) {
73
73
  return new Response(null, {
74
74
  status: 200
75
75
  });
76
- } else if (req.nextUrl.pathname === '/api/edgestore/confirm-upload') {
76
+ } else if (req.nextUrl.pathname.endsWith('/confirm-upload')) {
77
77
  const res = await shared.confirmUpload({
78
78
  provider,
79
79
  router: config.router,
@@ -86,7 +86,7 @@ function createEdgeStoreNextHandler(config) {
86
86
  'Content-Type': 'application/json'
87
87
  }
88
88
  });
89
- } else if (req.nextUrl.pathname === '/api/edgestore/delete-file') {
89
+ } else if (req.nextUrl.pathname.endsWith('/delete-file')) {
90
90
  const res = await shared.deleteFile({
91
91
  provider,
92
92
  router: config.router,
@@ -99,7 +99,7 @@ function createEdgeStoreNextHandler(config) {
99
99
  'Content-Type': 'application/json'
100
100
  }
101
101
  });
102
- } else if (req.nextUrl.pathname === '/api/edgestore/proxy-file') {
102
+ } else if (req.nextUrl.pathname.endsWith('/proxy-file')) {
103
103
  const url = req.nextUrl.searchParams.get('url');
104
104
  if (typeof url === 'string') {
105
105
  const proxyRes = await fetch(url, {
@@ -11,7 +11,7 @@ function createEdgeStoreNextHandler(config) {
11
11
  const { provider = EdgeStoreProvider() } = config;
12
12
  return async (req)=>{
13
13
  try {
14
- if (req.nextUrl.pathname === '/api/edgestore/init') {
14
+ if (req.nextUrl.pathname.endsWith('/init')) {
15
15
  const ctx = 'createContext' in config ? await config.createContext({
16
16
  req
17
17
  }) : {};
@@ -33,7 +33,7 @@ function createEdgeStoreNextHandler(config) {
33
33
  res.headers.append('Set-Cookie', cookie);
34
34
  }
35
35
  return res;
36
- } else if (req.nextUrl.pathname === '/api/edgestore/request-upload') {
36
+ } else if (req.nextUrl.pathname.endsWith('/request-upload')) {
37
37
  const res = await requestUpload({
38
38
  provider,
39
39
  router: config.router,
@@ -46,7 +46,7 @@ function createEdgeStoreNextHandler(config) {
46
46
  'Content-Type': 'application/json'
47
47
  }
48
48
  });
49
- } else if (req.nextUrl.pathname === '/api/edgestore/request-upload-parts') {
49
+ } else if (req.nextUrl.pathname.endsWith('/request-upload-parts')) {
50
50
  const res = await requestUploadParts({
51
51
  provider,
52
52
  router: config.router,
@@ -59,7 +59,7 @@ function createEdgeStoreNextHandler(config) {
59
59
  'Content-Type': 'application/json'
60
60
  }
61
61
  });
62
- } else if (req.nextUrl.pathname === '/api/edgestore/complete-multipart-upload') {
62
+ } else if (req.nextUrl.pathname.endsWith('/complete-multipart-upload')) {
63
63
  await completeMultipartUpload({
64
64
  provider,
65
65
  router: config.router,
@@ -69,7 +69,7 @@ function createEdgeStoreNextHandler(config) {
69
69
  return new Response(null, {
70
70
  status: 200
71
71
  });
72
- } else if (req.nextUrl.pathname === '/api/edgestore/confirm-upload') {
72
+ } else if (req.nextUrl.pathname.endsWith('/confirm-upload')) {
73
73
  const res = await confirmUpload({
74
74
  provider,
75
75
  router: config.router,
@@ -82,7 +82,7 @@ function createEdgeStoreNextHandler(config) {
82
82
  'Content-Type': 'application/json'
83
83
  }
84
84
  });
85
- } else if (req.nextUrl.pathname === '/api/edgestore/delete-file') {
85
+ } else if (req.nextUrl.pathname.endsWith('/delete-file')) {
86
86
  const res = await deleteFile({
87
87
  provider,
88
88
  router: config.router,
@@ -95,7 +95,7 @@ function createEdgeStoreNextHandler(config) {
95
95
  'Content-Type': 'application/json'
96
96
  }
97
97
  });
98
- } else if (req.nextUrl.pathname === '/api/edgestore/proxy-file') {
98
+ } else if (req.nextUrl.pathname.endsWith('/proxy-file')) {
99
99
  const url = req.nextUrl.searchParams.get('url');
100
100
  if (typeof url === 'string') {
101
101
  const proxyRes = await fetch(url, {
@@ -15,7 +15,7 @@ function createEdgeStoreNextHandler(config) {
15
15
  const { provider = providers_edgestore_index.EdgeStoreProvider() } = config;
16
16
  return async (req, res)=>{
17
17
  try {
18
- if (req.url === '/api/edgestore/init') {
18
+ if (req.url?.includes?.('/init')) {
19
19
  const ctx = 'createContext' in config ? await config.createContext({
20
20
  req,
21
21
  res
@@ -30,21 +30,21 @@ function createEdgeStoreNextHandler(config) {
30
30
  token,
31
31
  baseUrl
32
32
  });
33
- } else if (req.url === '/api/edgestore/request-upload') {
33
+ } else if (req.url?.includes?.('/request-upload')) {
34
34
  res.json(await shared.requestUpload({
35
35
  provider,
36
36
  router: config.router,
37
37
  body: req.body,
38
38
  ctxToken: req.cookies['edgestore-ctx']
39
39
  }));
40
- } else if (req.url === '/api/edgestore/request-upload-parts') {
40
+ } else if (req.url?.includes?.('/request-upload-parts')) {
41
41
  res.json(await shared.requestUploadParts({
42
42
  provider,
43
43
  router: config.router,
44
44
  body: req.body,
45
45
  ctxToken: req.cookies['edgestore-ctx']
46
46
  }));
47
- } else if (req.url === '/api/edgestore/complete-multipart-upload') {
47
+ } else if (req.url?.includes?.('/complete-multipart-upload')) {
48
48
  await shared.completeMultipartUpload({
49
49
  provider,
50
50
  router: config.router,
@@ -52,21 +52,21 @@ function createEdgeStoreNextHandler(config) {
52
52
  ctxToken: req.cookies['edgestore-ctx']
53
53
  });
54
54
  res.status(200).end();
55
- } else if (req.url === '/api/edgestore/confirm-upload') {
55
+ } else if (req.url?.includes?.('/confirm-upload')) {
56
56
  res.json(await shared.confirmUpload({
57
57
  provider,
58
58
  router: config.router,
59
59
  body: req.body,
60
60
  ctxToken: req.cookies['edgestore-ctx']
61
61
  }));
62
- } else if (req.url === '/api/edgestore/delete-file') {
62
+ } else if (req.url?.includes?.('/delete-file')) {
63
63
  res.json(await shared.deleteFile({
64
64
  provider,
65
65
  router: config.router,
66
66
  body: req.body,
67
67
  ctxToken: req.cookies['edgestore-ctx']
68
68
  }));
69
- } else if (req.url?.startsWith('/api/edgestore/proxy-file')) {
69
+ } else if (req.url?.includes?.('/proxy-file')) {
70
70
  const { url } = req.query;
71
71
  if (typeof url === 'string') {
72
72
  const proxyRes = await fetch(url, {
@@ -11,7 +11,7 @@ function createEdgeStoreNextHandler(config) {
11
11
  const { provider = EdgeStoreProvider() } = config;
12
12
  return async (req, res)=>{
13
13
  try {
14
- if (req.url === '/api/edgestore/init') {
14
+ if (req.url?.includes?.('/init')) {
15
15
  const ctx = 'createContext' in config ? await config.createContext({
16
16
  req,
17
17
  res
@@ -26,21 +26,21 @@ function createEdgeStoreNextHandler(config) {
26
26
  token,
27
27
  baseUrl
28
28
  });
29
- } else if (req.url === '/api/edgestore/request-upload') {
29
+ } else if (req.url?.includes?.('/request-upload')) {
30
30
  res.json(await requestUpload({
31
31
  provider,
32
32
  router: config.router,
33
33
  body: req.body,
34
34
  ctxToken: req.cookies['edgestore-ctx']
35
35
  }));
36
- } else if (req.url === '/api/edgestore/request-upload-parts') {
36
+ } else if (req.url?.includes?.('/request-upload-parts')) {
37
37
  res.json(await requestUploadParts({
38
38
  provider,
39
39
  router: config.router,
40
40
  body: req.body,
41
41
  ctxToken: req.cookies['edgestore-ctx']
42
42
  }));
43
- } else if (req.url === '/api/edgestore/complete-multipart-upload') {
43
+ } else if (req.url?.includes?.('/complete-multipart-upload')) {
44
44
  await completeMultipartUpload({
45
45
  provider,
46
46
  router: config.router,
@@ -48,21 +48,21 @@ function createEdgeStoreNextHandler(config) {
48
48
  ctxToken: req.cookies['edgestore-ctx']
49
49
  });
50
50
  res.status(200).end();
51
- } else if (req.url === '/api/edgestore/confirm-upload') {
51
+ } else if (req.url?.includes?.('/confirm-upload')) {
52
52
  res.json(await confirmUpload({
53
53
  provider,
54
54
  router: config.router,
55
55
  body: req.body,
56
56
  ctxToken: req.cookies['edgestore-ctx']
57
57
  }));
58
- } else if (req.url === '/api/edgestore/delete-file') {
58
+ } else if (req.url?.includes?.('/delete-file')) {
59
59
  res.json(await deleteFile({
60
60
  provider,
61
61
  router: config.router,
62
62
  body: req.body,
63
63
  ctxToken: req.cookies['edgestore-ctx']
64
64
  }));
65
- } else if (req.url?.startsWith('/api/edgestore/proxy-file')) {
65
+ } else if (req.url?.includes?.('/proxy-file')) {
66
66
  const { url } = req.query;
67
67
  if (typeof url === 'string') {
68
68
  const proxyRes = await fetch(url, {
@@ -45,7 +45,7 @@ function AWSProvider(options) {
45
45
  const pathPrefix = `${esBucketName}${fileInfo.isPublic ? '/_public' : ''}`;
46
46
  const nameId = uuid.v4();
47
47
  const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
48
- const fileName = `${nameId}${extension}`;
48
+ const fileName = fileInfo.fileName ?? `${nameId}${extension}`;
49
49
  const filePath = fileInfo.path.reduce((acc, item)=>{
50
50
  return `${acc}/${item.value}`;
51
51
  }, '');
@@ -41,7 +41,7 @@ function AWSProvider(options) {
41
41
  const pathPrefix = `${esBucketName}${fileInfo.isPublic ? '/_public' : ''}`;
42
42
  const nameId = v4();
43
43
  const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
44
- const fileName = `${nameId}${extension}`;
44
+ const fileName = fileInfo.fileName ?? `${nameId}${extension}`;
45
45
  const filePath = fileInfo.path.reduce((acc, item)=>{
46
46
  return `${acc}/${item.value}`;
47
47
  }, '');
@@ -32,6 +32,7 @@ export type RequestUploadParams = {
32
32
  size: number;
33
33
  extension: string;
34
34
  isPublic: boolean;
35
+ fileName?: string;
35
36
  path: {
36
37
  key: string;
37
38
  value: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE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AC;IACpD,UAAU,EAAE,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,YAAY,CAAC,UAAU,CAAC,CAAC;IAC7D,aAAa,EAAE,CACb,MAAM,EAAE,mBAAmB,KACxB,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACpC,kBAAkB,EAAE,CAClB,MAAM,EAAE,wBAAwB,KAC7B,YAAY,CAAC,qBAAqB,CAAC,CAAC;IACzC,uBAAuB,EAAE,CACvB,MAAM,EAAE,6BAA6B,KAClC,YAAY,CAAC,0BAA0B,CAAC,CAAC;IAC9C,aAAa,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACzE,UAAU,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,YAAY,CAAC,aAAa,CAAC,CAAC;CACvE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgestore/server",
3
- "version": "0.1.4",
3
+ "version": "0.1.5-alpha.1",
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",
@@ -117,5 +117,5 @@
117
117
  "typescript": "^5.1.6",
118
118
  "zod": "^3.21.4"
119
119
  },
120
- "gitHead": "8caf5d5b576aea4d057d20b48eb61adc5bb0aa3d"
120
+ "gitHead": "94b31fd879a0f4f9ed13cc08c9646e29d03c3f92"
121
121
  }
@@ -39,7 +39,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
39
39
  const { provider = EdgeStoreProvider() } = config;
40
40
  return async (req: NextRequest) => {
41
41
  try {
42
- if (req.nextUrl.pathname === '/api/edgestore/init') {
42
+ if (req.nextUrl.pathname.endsWith('/init')) {
43
43
  const ctx =
44
44
  'createContext' in config
45
45
  ? await config.createContext({ req })
@@ -65,7 +65,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
65
65
  res.headers.append('Set-Cookie', cookie);
66
66
  }
67
67
  return res;
68
- } else if (req.nextUrl.pathname === '/api/edgestore/request-upload') {
68
+ } else if (req.nextUrl.pathname.endsWith('/request-upload')) {
69
69
  const res = await requestUpload({
70
70
  provider,
71
71
  router: config.router,
@@ -78,9 +78,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
78
78
  'Content-Type': 'application/json',
79
79
  },
80
80
  });
81
- } else if (
82
- req.nextUrl.pathname === '/api/edgestore/request-upload-parts'
83
- ) {
81
+ } else if (req.nextUrl.pathname.endsWith('/request-upload-parts')) {
84
82
  const res = await requestUploadParts({
85
83
  provider,
86
84
  router: config.router,
@@ -93,9 +91,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
93
91
  'Content-Type': 'application/json',
94
92
  },
95
93
  });
96
- } else if (
97
- req.nextUrl.pathname === '/api/edgestore/complete-multipart-upload'
98
- ) {
94
+ } else if (req.nextUrl.pathname.endsWith('/complete-multipart-upload')) {
99
95
  await completeMultipartUpload({
100
96
  provider,
101
97
  router: config.router,
@@ -105,7 +101,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
105
101
  return new Response(null, {
106
102
  status: 200,
107
103
  });
108
- } else if (req.nextUrl.pathname === '/api/edgestore/confirm-upload') {
104
+ } else if (req.nextUrl.pathname.endsWith('/confirm-upload')) {
109
105
  const res = await confirmUpload({
110
106
  provider,
111
107
  router: config.router,
@@ -118,7 +114,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
118
114
  'Content-Type': 'application/json',
119
115
  },
120
116
  });
121
- } else if (req.nextUrl.pathname === '/api/edgestore/delete-file') {
117
+ } else if (req.nextUrl.pathname.endsWith('/delete-file')) {
122
118
  const res = await deleteFile({
123
119
  provider,
124
120
  router: config.router,
@@ -131,7 +127,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
131
127
  'Content-Type': 'application/json',
132
128
  },
133
129
  });
134
- } else if (req.nextUrl.pathname === '/api/edgestore/proxy-file') {
130
+ } else if (req.nextUrl.pathname.endsWith('/proxy-file')) {
135
131
  const url = req.nextUrl.searchParams.get('url');
136
132
  if (typeof url === 'string') {
137
133
  const proxyRes = await fetch(url, {
@@ -40,7 +40,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
40
40
  const { provider = EdgeStoreProvider() } = config;
41
41
  return async (req: NextApiRequest, res: NextApiResponse) => {
42
42
  try {
43
- if (req.url === '/api/edgestore/init') {
43
+ if (req.url?.includes?.('/init')) {
44
44
  const ctx =
45
45
  'createContext' in config
46
46
  ? await config.createContext({ req, res })
@@ -55,7 +55,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
55
55
  token,
56
56
  baseUrl,
57
57
  });
58
- } else if (req.url === '/api/edgestore/request-upload') {
58
+ } else if (req.url?.includes?.('/request-upload')) {
59
59
  res.json(
60
60
  await requestUpload({
61
61
  provider,
@@ -64,7 +64,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
64
64
  ctxToken: req.cookies['edgestore-ctx'],
65
65
  }),
66
66
  );
67
- } else if (req.url === '/api/edgestore/request-upload-parts') {
67
+ } else if (req.url?.includes?.('/request-upload-parts')) {
68
68
  res.json(
69
69
  await requestUploadParts({
70
70
  provider,
@@ -73,7 +73,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
73
73
  ctxToken: req.cookies['edgestore-ctx'],
74
74
  }),
75
75
  );
76
- } else if (req.url === '/api/edgestore/complete-multipart-upload') {
76
+ } else if (req.url?.includes?.('/complete-multipart-upload')) {
77
77
  await completeMultipartUpload({
78
78
  provider,
79
79
  router: config.router,
@@ -81,7 +81,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
81
81
  ctxToken: req.cookies['edgestore-ctx'],
82
82
  });
83
83
  res.status(200).end();
84
- } else if (req.url === '/api/edgestore/confirm-upload') {
84
+ } else if (req.url?.includes?.('/confirm-upload')) {
85
85
  res.json(
86
86
  await confirmUpload({
87
87
  provider,
@@ -90,7 +90,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
90
90
  ctxToken: req.cookies['edgestore-ctx'],
91
91
  }),
92
92
  );
93
- } else if (req.url === '/api/edgestore/delete-file') {
93
+ } else if (req.url?.includes?.('/delete-file')) {
94
94
  res.json(
95
95
  await deleteFile({
96
96
  provider,
@@ -99,7 +99,7 @@ export function createEdgeStoreNextHandler<TCtx>(config: Config<TCtx>) {
99
99
  ctxToken: req.cookies['edgestore-ctx'],
100
100
  }),
101
101
  );
102
- } else if (req.url?.startsWith('/api/edgestore/proxy-file')) {
102
+ } else if (req.url?.includes?.('/proxy-file')) {
103
103
  const { url } = req.query;
104
104
  if (typeof url === 'string') {
105
105
  const proxyRes = await fetch(url, {
@@ -107,7 +107,7 @@ export function AWSProvider(options?: AWSProviderOptions): Provider {
107
107
  const extension = fileInfo.extension
108
108
  ? `.${fileInfo.extension.replace('.', '')}`
109
109
  : '';
110
- const fileName = `${nameId}${extension}`;
110
+ const fileName = fileInfo.fileName ?? `${nameId}${extension}`;
111
111
  const filePath = fileInfo.path.reduce((acc, item) => {
112
112
  return `${acc}/${item.value}`;
113
113
  }, '');
@@ -41,6 +41,7 @@ export type RequestUploadParams = {
41
41
  size: number;
42
42
  extension: string;
43
43
  isPublic: boolean;
44
+ fileName?: string;
44
45
  path: {
45
46
  key: string;
46
47
  value: string;
@@ -1 +0,0 @@
1
- export * from '../../dist/adapters/next';
@@ -1 +0,0 @@
1
- module.exports = require('../../dist/adapters/next');