@edgestore/server 0.8.0 → 1.0.0-next.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.
Files changed (89) hide show
  1. package/adapters/astro/index.d.ts +1 -1
  2. package/adapters/astro/index.js +1 -1
  3. package/adapters/express/index.d.ts +1 -1
  4. package/adapters/express/index.js +1 -1
  5. package/adapters/fastify/index.d.ts +1 -1
  6. package/adapters/fastify/index.js +1 -1
  7. package/adapters/hono/index.d.ts +1 -1
  8. package/adapters/hono/index.js +1 -1
  9. package/adapters/next/app/index.d.ts +1 -1
  10. package/adapters/next/app/index.js +1 -1
  11. package/adapters/next/pages/index.d.ts +1 -1
  12. package/adapters/next/pages/index.js +1 -1
  13. package/adapters/remix/index.d.ts +1 -1
  14. package/adapters/remix/index.js +1 -1
  15. package/adapters/start/index.d.ts +1 -1
  16. package/adapters/start/index.js +1 -1
  17. package/core/index.d.ts +1 -1
  18. package/core/index.js +1 -1
  19. package/dist/adapters/astro/index.d.ts +2 -2
  20. package/dist/adapters/astro/index.js +28 -30
  21. package/dist/adapters/express/index.d.ts +2 -2
  22. package/dist/adapters/express/index.js +28 -30
  23. package/dist/adapters/fastify/index.d.ts +2 -2
  24. package/dist/adapters/fastify/index.js +28 -30
  25. package/dist/adapters/hono/index.d.ts +2 -2
  26. package/dist/adapters/hono/index.js +28 -30
  27. package/dist/adapters/imageTypes.js +1 -3
  28. package/dist/adapters/next/app/index.d.ts +2 -2
  29. package/dist/adapters/next/app/index.js +29 -31
  30. package/dist/adapters/next/pages/index.d.ts +2 -2
  31. package/dist/adapters/next/pages/index.js +29 -31
  32. package/dist/adapters/remix/index.d.ts +2 -2
  33. package/dist/adapters/remix/index.js +28 -30
  34. package/dist/adapters/shared.d.ts.map +1 -1
  35. package/dist/adapters/shared.js +44 -50
  36. package/dist/adapters/start/index.d.ts +2 -2
  37. package/dist/adapters/start/index.js +28 -30
  38. package/dist/core/client/index.d.ts.map +1 -1
  39. package/dist/core/client/index.js +7 -9
  40. package/dist/core/index.d.ts +2 -2
  41. package/dist/core/index.js +2 -10
  42. package/dist/core/sdk/index.d.ts.map +1 -1
  43. package/dist/core/sdk/index.js +10 -13
  44. package/dist/index.js +1 -10
  45. package/dist/libs/errors/EdgeStoreCredentialsError.js +1 -3
  46. package/dist/libs/logger.js +5 -9
  47. package/dist/libs/utils.js +1 -3
  48. package/dist/providers/aws/index.d.ts.map +1 -1
  49. package/dist/providers/aws/index.js +12 -15
  50. package/dist/providers/azure/index.d.ts.map +1 -1
  51. package/dist/providers/azure/index.js +6 -9
  52. package/dist/providers/edgestore/index.js +12 -14
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.d.ts.map +1 -1
  55. package/dist/version.js +2 -5
  56. package/package.json +51 -50
  57. package/providers/aws/index.d.ts +1 -1
  58. package/providers/aws/index.js +1 -1
  59. package/providers/azure/index.d.ts +1 -1
  60. package/providers/azure/index.js +1 -1
  61. package/providers/edgestore/index.d.ts +1 -1
  62. package/providers/edgestore/index.js +1 -1
  63. package/src/adapters/shared.ts +12 -13
  64. package/src/core/client/index.ts +0 -1
  65. package/src/core/sdk/index.ts +1 -8
  66. package/src/providers/aws/index.ts +1 -2
  67. package/src/providers/azure/index.ts +1 -2
  68. package/src/version.ts +1 -1
  69. package/dist/adapters/astro/index.mjs +0 -172
  70. package/dist/adapters/express/index.mjs +0 -108
  71. package/dist/adapters/fastify/index.mjs +0 -135
  72. package/dist/adapters/hono/index.mjs +0 -131
  73. package/dist/adapters/imageTypes.mjs +0 -12
  74. package/dist/adapters/next/app/index.mjs +0 -163
  75. package/dist/adapters/next/pages/index.mjs +0 -112
  76. package/dist/adapters/remix/index.mjs +0 -148
  77. package/dist/adapters/shared.mjs +0 -471
  78. package/dist/adapters/start/index.mjs +0 -181
  79. package/dist/core/client/index.mjs +0 -221
  80. package/dist/core/index.mjs +0 -2
  81. package/dist/core/sdk/index.mjs +0 -253
  82. package/dist/index.mjs +0 -1
  83. package/dist/libs/errors/EdgeStoreCredentialsError.mjs +0 -10
  84. package/dist/libs/logger.mjs +0 -53
  85. package/dist/libs/utils.mjs +0 -10
  86. package/dist/providers/aws/index.mjs +0 -103
  87. package/dist/providers/azure/index.mjs +0 -85
  88. package/dist/providers/edgestore/index.mjs +0 -164
  89. package/dist/version.mjs +0 -4
@@ -1 +1 @@
1
- export * from '../../dist/adapters/astro';
1
+ export * from '../../dist/adapters/astro/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../dist/adapters/astro');
1
+ export * from '../../dist/adapters/astro/index.js';
@@ -1 +1 @@
1
- export * from '../../dist/adapters/express';
1
+ export * from '../../dist/adapters/express/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../dist/adapters/express');
1
+ export * from '../../dist/adapters/express/index.js';
@@ -1 +1 @@
1
- export * from '../../dist/adapters/fastify';
1
+ export * from '../../dist/adapters/fastify/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../dist/adapters/fastify');
1
+ export * from '../../dist/adapters/fastify/index.js';
@@ -1 +1 @@
1
- export * from '../../dist/adapters/hono';
1
+ export * from '../../dist/adapters/hono/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../dist/adapters/hono');
1
+ export * from '../../dist/adapters/hono/index.js';
@@ -1 +1 @@
1
- export * from '../../../dist/adapters/next/app';
1
+ export * from '../../../dist/adapters/next/app/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../../dist/adapters/next/app');
1
+ export * from '../../../dist/adapters/next/app/index.js';
@@ -1 +1 @@
1
- export * from '../../../dist/adapters/next/pages';
1
+ export * from '../../../dist/adapters/next/pages/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../../dist/adapters/next/pages');
1
+ export * from '../../../dist/adapters/next/pages/index.js';
@@ -1 +1 @@
1
- export * from '../../dist/adapters/remix';
1
+ export * from '../../dist/adapters/remix/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../dist/adapters/remix');
1
+ export * from '../../dist/adapters/remix/index.js';
@@ -1 +1 @@
1
- export * from '../../dist/adapters/start';
1
+ export * from '../../dist/adapters/start/index.js';
@@ -1 +1 @@
1
- module.exports = require('../../dist/adapters/start');
1
+ export * from '../../dist/adapters/start/index.js';
package/core/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '../dist/core';
1
+ export * from '../dist/core/index.js';
package/core/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('../dist/core');
1
+ export * from '../dist/core/index.js';
@@ -1,7 +1,7 @@
1
1
  import { type EdgeStoreRouter, type MaybePromise, type Provider } from '@edgestore/shared';
2
2
  import type { APIContext } from 'astro';
3
- import { type LogLevel } from '../../libs/logger';
4
- import { type CookieConfig } from '../shared';
3
+ import { type LogLevel } from '../../libs/logger.js';
4
+ import { type CookieConfig } from '../shared.js';
5
5
  export type Config<TCtx> = {
6
6
  provider?: Provider;
7
7
  router: EdgeStoreRouter<TCtx>;
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
- var shared$1 = require('@edgestore/shared');
4
- var logger = require('../../libs/logger.js');
5
- var utils = require('../../libs/utils.js');
6
- var index = require('../../providers/edgestore/index.js');
7
- var shared = require('../shared.js');
1
+ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
2
+ import Logger from '../../libs/logger.js';
3
+ import { matchPath } from '../../libs/utils.js';
4
+ import { EdgeStoreProvider } from '../../providers/edgestore/index.js';
5
+ import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../shared.js';
8
6
 
9
7
  // Helper to safely get cookies from Astro request
10
8
  function getCookie(request, name) {
@@ -18,29 +16,29 @@ function getCookie(request, name) {
18
16
  return cookies[name];
19
17
  }
20
18
  function createEdgeStoreAstroHandler(config) {
21
- const { provider = index.EdgeStoreProvider(), cookieConfig } = config;
22
- const log = new logger(config.logLevel);
19
+ const { provider = EdgeStoreProvider(), cookieConfig } = config;
20
+ const log = new Logger(config.logLevel);
23
21
  globalThis._EDGE_STORE_LOGGER = log;
24
22
  log.debug('Creating EdgeStore Astro handler');
25
- const resolvedCookieConfig = shared.getCookieConfig(cookieConfig);
23
+ const resolvedCookieConfig = getCookieConfig(cookieConfig);
26
24
  return async (context)=>{
27
25
  try {
28
26
  const { request } = context;
29
27
  const url = new URL(request.url);
30
- if (utils.matchPath(url.pathname, 'health')) {
28
+ if (matchPath(url.pathname, 'health')) {
31
29
  return new Response('OK');
32
- } else if (utils.matchPath(url.pathname, 'init')) {
30
+ } else if (matchPath(url.pathname, 'init')) {
33
31
  let ctx = {};
34
32
  try {
35
33
  ctx = 'createContext' in config ? await config.createContext(context) : {};
36
34
  } catch (err) {
37
- throw new shared$1.EdgeStoreError({
35
+ throw new EdgeStoreError({
38
36
  message: 'Error creating context',
39
37
  code: 'CREATE_CONTEXT_ERROR',
40
38
  cause: err instanceof Error ? err : undefined
41
39
  });
42
40
  }
43
- const { newCookies, ...body } = await shared.init({
41
+ const { newCookies, ...body } = await init({
44
42
  ctx,
45
43
  provider,
46
44
  router: config.router,
@@ -59,9 +57,9 @@ function createEdgeStoreAstroHandler(config) {
59
57
  return new Response(JSON.stringify(body), {
60
58
  headers
61
59
  });
62
- } else if (utils.matchPath(url.pathname, 'request-upload')) {
60
+ } else if (matchPath(url.pathname, 'request-upload')) {
63
61
  const body = await request.json();
64
- const result = await shared.requestUpload({
62
+ const result = await requestUpload({
65
63
  provider,
66
64
  router: config.router,
67
65
  body,
@@ -72,9 +70,9 @@ function createEdgeStoreAstroHandler(config) {
72
70
  'Content-Type': 'application/json'
73
71
  }
74
72
  });
75
- } else if (utils.matchPath(url.pathname, 'request-upload-parts')) {
73
+ } else if (matchPath(url.pathname, 'request-upload-parts')) {
76
74
  const body = await request.json();
77
- const result = await shared.requestUploadParts({
75
+ const result = await requestUploadParts({
78
76
  provider,
79
77
  router: config.router,
80
78
  body,
@@ -85,9 +83,9 @@ function createEdgeStoreAstroHandler(config) {
85
83
  'Content-Type': 'application/json'
86
84
  }
87
85
  });
88
- } else if (utils.matchPath(url.pathname, 'complete-multipart-upload')) {
86
+ } else if (matchPath(url.pathname, 'complete-multipart-upload')) {
89
87
  const body = await request.json();
90
- await shared.completeMultipartUpload({
88
+ await completeMultipartUpload({
91
89
  provider,
92
90
  router: config.router,
93
91
  body,
@@ -96,9 +94,9 @@ function createEdgeStoreAstroHandler(config) {
96
94
  return new Response(null, {
97
95
  status: 200
98
96
  });
99
- } else if (utils.matchPath(url.pathname, 'confirm-upload')) {
97
+ } else if (matchPath(url.pathname, 'confirm-upload')) {
100
98
  const body = await request.json();
101
- const result = await shared.confirmUpload({
99
+ const result = await confirmUpload({
102
100
  provider,
103
101
  router: config.router,
104
102
  body,
@@ -109,9 +107,9 @@ function createEdgeStoreAstroHandler(config) {
109
107
  'Content-Type': 'application/json'
110
108
  }
111
109
  });
112
- } else if (utils.matchPath(url.pathname, 'delete-file')) {
110
+ } else if (matchPath(url.pathname, 'delete-file')) {
113
111
  const body = await request.json();
114
- const result = await shared.deleteFile({
112
+ const result = await deleteFile({
115
113
  provider,
116
114
  router: config.router,
117
115
  body,
@@ -122,10 +120,10 @@ function createEdgeStoreAstroHandler(config) {
122
120
  'Content-Type': 'application/json'
123
121
  }
124
122
  });
125
- } else if (utils.matchPath(url.pathname, 'proxy-file')) {
123
+ } else if (matchPath(url.pathname, 'proxy-file')) {
126
124
  const url = new URL(request.url).searchParams.get('url');
127
125
  if (typeof url === 'string') {
128
- const proxyRes = await shared.fetchProxyFile({
126
+ const proxyRes = await fetchProxyFile({
129
127
  cookieHeader: request.headers.get('cookie') ?? undefined,
130
128
  url
131
129
  });
@@ -146,18 +144,18 @@ function createEdgeStoreAstroHandler(config) {
146
144
  });
147
145
  }
148
146
  } catch (err) {
149
- if (err instanceof shared$1.EdgeStoreError) {
147
+ if (err instanceof EdgeStoreError) {
150
148
  log[err.level](err.formattedMessage());
151
149
  if (err.cause) log[err.level](err.cause);
152
150
  return new Response(JSON.stringify(err.formattedJson()), {
153
- status: shared$1.EDGE_STORE_ERROR_CODES[err.code],
151
+ status: EDGE_STORE_ERROR_CODES[err.code],
154
152
  headers: {
155
153
  'Content-Type': 'application/json'
156
154
  }
157
155
  });
158
156
  } else {
159
157
  log.error(err);
160
- return new Response(JSON.stringify(new shared$1.EdgeStoreError({
158
+ return new Response(JSON.stringify(new EdgeStoreError({
161
159
  message: 'Internal Server Error',
162
160
  code: 'SERVER_ERROR'
163
161
  }).formattedJson()), {
@@ -171,4 +169,4 @@ function createEdgeStoreAstroHandler(config) {
171
169
  };
172
170
  }
173
171
 
174
- exports.createEdgeStoreAstroHandler = createEdgeStoreAstroHandler;
172
+ export { createEdgeStoreAstroHandler };
@@ -1,7 +1,7 @@
1
1
  import { type EdgeStoreRouter, type MaybePromise, type Provider } from '@edgestore/shared';
2
2
  import { type Request, type Response } from 'express';
3
- import { type LogLevel } from '../../libs/logger';
4
- import { type CookieConfig } from '../shared';
3
+ import { type LogLevel } from '../../libs/logger.js';
4
+ import { type CookieConfig } from '../shared.js';
5
5
  export type CreateContextOptions = {
6
6
  req: Request;
7
7
  res: Response;
@@ -1,23 +1,21 @@
1
- 'use strict';
2
-
3
- var shared$1 = require('@edgestore/shared');
4
- var logger = require('../../libs/logger.js');
5
- var utils = require('../../libs/utils.js');
6
- var index = require('../../providers/edgestore/index.js');
7
- var shared = require('../shared.js');
1
+ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
2
+ import Logger from '../../libs/logger.js';
3
+ import { matchPath } from '../../libs/utils.js';
4
+ import { EdgeStoreProvider } from '../../providers/edgestore/index.js';
5
+ import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../shared.js';
8
6
 
9
7
  function createEdgeStoreExpressHandler(config) {
10
- const { provider = index.EdgeStoreProvider(), cookieConfig } = config;
11
- const log = new logger(config.logLevel);
8
+ const { provider = EdgeStoreProvider(), cookieConfig } = config;
9
+ const log = new Logger(config.logLevel);
12
10
  globalThis._EDGE_STORE_LOGGER = log;
13
11
  log.debug('Creating EdgeStore Express handler');
14
- const resolvedCookieConfig = shared.getCookieConfig(cookieConfig);
12
+ const resolvedCookieConfig = getCookieConfig(cookieConfig);
15
13
  return async (req, res)=>{
16
14
  try {
17
15
  const pathname = req.url ?? '';
18
- if (utils.matchPath(pathname, '/health')) {
16
+ if (matchPath(pathname, '/health')) {
19
17
  res.send('OK');
20
- } else if (utils.matchPath(pathname, '/init')) {
18
+ } else if (matchPath(pathname, '/init')) {
21
19
  let ctx = {};
22
20
  try {
23
21
  ctx = 'createContext' in config ? await config.createContext({
@@ -25,13 +23,13 @@ function createEdgeStoreExpressHandler(config) {
25
23
  res
26
24
  }) : {};
27
25
  } catch (err) {
28
- throw new shared$1.EdgeStoreError({
26
+ throw new EdgeStoreError({
29
27
  message: 'Error creating context',
30
28
  code: 'CREATE_CONTEXT_ERROR',
31
29
  cause: err instanceof Error ? err : undefined
32
30
  });
33
31
  }
34
- const { newCookies, ...body } = await shared.init({
32
+ const { newCookies, ...body } = await init({
35
33
  ctx,
36
34
  provider,
37
35
  router: config.router,
@@ -39,46 +37,46 @@ function createEdgeStoreExpressHandler(config) {
39
37
  });
40
38
  res.setHeader('Set-Cookie', newCookies);
41
39
  res.json(body);
42
- } else if (utils.matchPath(pathname, '/request-upload')) {
43
- res.json(await shared.requestUpload({
40
+ } else if (matchPath(pathname, '/request-upload')) {
41
+ res.json(await requestUpload({
44
42
  provider,
45
43
  router: config.router,
46
44
  body: req.body,
47
45
  ctxToken: req.cookies[resolvedCookieConfig.ctx.name]
48
46
  }));
49
- } else if (utils.matchPath(pathname, '/request-upload-parts')) {
50
- res.json(await shared.requestUploadParts({
47
+ } else if (matchPath(pathname, '/request-upload-parts')) {
48
+ res.json(await requestUploadParts({
51
49
  provider,
52
50
  router: config.router,
53
51
  body: req.body,
54
52
  ctxToken: req.cookies[resolvedCookieConfig.ctx.name]
55
53
  }));
56
- } else if (utils.matchPath(pathname, '/complete-multipart-upload')) {
57
- await shared.completeMultipartUpload({
54
+ } else if (matchPath(pathname, '/complete-multipart-upload')) {
55
+ await completeMultipartUpload({
58
56
  provider,
59
57
  router: config.router,
60
58
  body: req.body,
61
59
  ctxToken: req.cookies[resolvedCookieConfig.ctx.name]
62
60
  });
63
61
  res.status(200).end();
64
- } else if (utils.matchPath(pathname, '/confirm-upload')) {
65
- res.json(await shared.confirmUpload({
62
+ } else if (matchPath(pathname, '/confirm-upload')) {
63
+ res.json(await confirmUpload({
66
64
  provider,
67
65
  router: config.router,
68
66
  body: req.body,
69
67
  ctxToken: req.cookies[resolvedCookieConfig.ctx.name]
70
68
  }));
71
- } else if (utils.matchPath(pathname, '/delete-file')) {
72
- res.json(await shared.deleteFile({
69
+ } else if (matchPath(pathname, '/delete-file')) {
70
+ res.json(await deleteFile({
73
71
  provider,
74
72
  router: config.router,
75
73
  body: req.body,
76
74
  ctxToken: req.cookies[resolvedCookieConfig.ctx.name]
77
75
  }));
78
- } else if (utils.matchPath(pathname, '/proxy-file')) {
76
+ } else if (matchPath(pathname, '/proxy-file')) {
79
77
  const { url } = req.query;
80
78
  if (typeof url === 'string') {
81
- const proxyRes = await shared.fetchProxyFile({
79
+ const proxyRes = await fetchProxyFile({
82
80
  cookieHeader: req.headers.cookie,
83
81
  url
84
82
  });
@@ -92,13 +90,13 @@ function createEdgeStoreExpressHandler(config) {
92
90
  res.status(404).end();
93
91
  }
94
92
  } catch (err) {
95
- if (err instanceof shared$1.EdgeStoreError) {
93
+ if (err instanceof EdgeStoreError) {
96
94
  log[err.level](err.formattedMessage());
97
95
  if (err.cause) log[err.level](err.cause);
98
- res.status(shared$1.EDGE_STORE_ERROR_CODES[err.code]).json(err.formattedJson());
96
+ res.status(EDGE_STORE_ERROR_CODES[err.code]).json(err.formattedJson());
99
97
  } else {
100
98
  log.error(err);
101
- res.status(500).send(new shared$1.EdgeStoreError({
99
+ res.status(500).send(new EdgeStoreError({
102
100
  message: 'Internal Server Error',
103
101
  code: 'SERVER_ERROR'
104
102
  }).formattedJson());
@@ -107,4 +105,4 @@ function createEdgeStoreExpressHandler(config) {
107
105
  };
108
106
  }
109
107
 
110
- exports.createEdgeStoreExpressHandler = createEdgeStoreExpressHandler;
108
+ export { createEdgeStoreExpressHandler };
@@ -1,7 +1,7 @@
1
1
  import { type EdgeStoreRouter, type MaybePromise, type Provider } from '@edgestore/shared';
2
2
  import { type FastifyReply, type FastifyRequest } from 'fastify';
3
- import { type LogLevel } from '../../libs/logger';
4
- import { type CookieConfig } from '../shared';
3
+ import { type LogLevel } from '../../libs/logger.js';
4
+ import { type CookieConfig } from '../shared.js';
5
5
  export type CreateContextOptions = {
6
6
  req: FastifyRequest;
7
7
  reply: FastifyReply;
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
- var shared$1 = require('@edgestore/shared');
4
- var logger = require('../../libs/logger.js');
5
- var utils = require('../../libs/utils.js');
6
- var index = require('../../providers/edgestore/index.js');
7
- var shared = require('../shared.js');
1
+ import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
2
+ import Logger from '../../libs/logger.js';
3
+ import { matchPath } from '../../libs/utils.js';
4
+ import { EdgeStoreProvider } from '../../providers/edgestore/index.js';
5
+ import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile, fetchProxyFile } from '../shared.js';
8
6
 
9
7
  // Helper to safely get cookies from Fastify request
10
8
  function getCookie(req, name) {
@@ -24,18 +22,18 @@ function getCookie(req, name) {
24
22
  return cookies[name];
25
23
  }
26
24
  function createEdgeStoreFastifyHandler(config) {
27
- const { provider = index.EdgeStoreProvider(), cookieConfig } = config;
28
- const log = new logger(config.logLevel);
25
+ const { provider = EdgeStoreProvider(), cookieConfig } = config;
26
+ const log = new Logger(config.logLevel);
29
27
  globalThis._EDGE_STORE_LOGGER = log;
30
28
  log.debug('Creating EdgeStore Fastify handler');
31
- const resolvedCookieConfig = shared.getCookieConfig(cookieConfig);
29
+ const resolvedCookieConfig = getCookieConfig(cookieConfig);
32
30
  return async (req, reply)=>{
33
31
  try {
34
32
  // Get the URL from the request - simplified approach
35
33
  const pathname = req.url;
36
- if (utils.matchPath(pathname, '/health')) {
34
+ if (matchPath(pathname, '/health')) {
37
35
  return reply.send('OK');
38
- } else if (utils.matchPath(pathname, '/init')) {
36
+ } else if (matchPath(pathname, '/init')) {
39
37
  let ctx = {};
40
38
  try {
41
39
  ctx = 'createContext' in config ? await config.createContext({
@@ -43,13 +41,13 @@ function createEdgeStoreFastifyHandler(config) {
43
41
  reply
44
42
  }) : {};
45
43
  } catch (err) {
46
- throw new shared$1.EdgeStoreError({
44
+ throw new EdgeStoreError({
47
45
  message: 'Error creating context',
48
46
  code: 'CREATE_CONTEXT_ERROR',
49
47
  cause: err instanceof Error ? err : undefined
50
48
  });
51
49
  }
52
- const { newCookies, ...body } = await shared.init({
50
+ const { newCookies, ...body } = await init({
53
51
  ctx,
54
52
  provider,
55
53
  router: config.router,
@@ -67,46 +65,46 @@ function createEdgeStoreFastifyHandler(config) {
67
65
  void reply.header('Set-Cookie', newCookies);
68
66
  }
69
67
  return reply.send(body);
70
- } else if (utils.matchPath(pathname, '/request-upload')) {
71
- return reply.send(await shared.requestUpload({
68
+ } else if (matchPath(pathname, '/request-upload')) {
69
+ return reply.send(await requestUpload({
72
70
  provider,
73
71
  router: config.router,
74
72
  body: req.body,
75
73
  ctxToken: getCookie(req, resolvedCookieConfig.ctx.name)
76
74
  }));
77
- } else if (utils.matchPath(pathname, '/request-upload-parts')) {
78
- return reply.send(await shared.requestUploadParts({
75
+ } else if (matchPath(pathname, '/request-upload-parts')) {
76
+ return reply.send(await requestUploadParts({
79
77
  provider,
80
78
  router: config.router,
81
79
  body: req.body,
82
80
  ctxToken: getCookie(req, resolvedCookieConfig.ctx.name)
83
81
  }));
84
- } else if (utils.matchPath(pathname, '/complete-multipart-upload')) {
85
- await shared.completeMultipartUpload({
82
+ } else if (matchPath(pathname, '/complete-multipart-upload')) {
83
+ await completeMultipartUpload({
86
84
  provider,
87
85
  router: config.router,
88
86
  body: req.body,
89
87
  ctxToken: getCookie(req, resolvedCookieConfig.ctx.name)
90
88
  });
91
89
  return reply.status(200).send();
92
- } else if (utils.matchPath(pathname, '/confirm-upload')) {
93
- return reply.send(await shared.confirmUpload({
90
+ } else if (matchPath(pathname, '/confirm-upload')) {
91
+ return reply.send(await confirmUpload({
94
92
  provider,
95
93
  router: config.router,
96
94
  body: req.body,
97
95
  ctxToken: getCookie(req, resolvedCookieConfig.ctx.name)
98
96
  }));
99
- } else if (utils.matchPath(pathname, '/delete-file')) {
100
- return reply.send(await shared.deleteFile({
97
+ } else if (matchPath(pathname, '/delete-file')) {
98
+ return reply.send(await deleteFile({
101
99
  provider,
102
100
  router: config.router,
103
101
  body: req.body,
104
102
  ctxToken: getCookie(req, resolvedCookieConfig.ctx.name)
105
103
  }));
106
- } else if (utils.matchPath(pathname, '/proxy-file')) {
104
+ } else if (matchPath(pathname, '/proxy-file')) {
107
105
  const url = req.query ? req.query.url : undefined;
108
106
  if (typeof url === 'string') {
109
- const proxyRes = await shared.fetchProxyFile({
107
+ const proxyRes = await fetchProxyFile({
110
108
  cookieHeader: req.headers.cookie,
111
109
  url
112
110
  });
@@ -119,13 +117,13 @@ function createEdgeStoreFastifyHandler(config) {
119
117
  return reply.status(404).send();
120
118
  }
121
119
  } catch (err) {
122
- if (err instanceof shared$1.EdgeStoreError) {
120
+ if (err instanceof EdgeStoreError) {
123
121
  log[err.level](err.formattedMessage());
124
122
  if (err.cause) log[err.level](err.cause);
125
- return reply.status(shared$1.EDGE_STORE_ERROR_CODES[err.code]).send(err.formattedJson());
123
+ return reply.status(EDGE_STORE_ERROR_CODES[err.code]).send(err.formattedJson());
126
124
  } else {
127
125
  log.error(err);
128
- return reply.status(500).send(new shared$1.EdgeStoreError({
126
+ return reply.status(500).send(new EdgeStoreError({
129
127
  message: 'Internal Server Error',
130
128
  code: 'SERVER_ERROR'
131
129
  }).formattedJson());
@@ -134,4 +132,4 @@ function createEdgeStoreFastifyHandler(config) {
134
132
  };
135
133
  }
136
134
 
137
- exports.createEdgeStoreFastifyHandler = createEdgeStoreFastifyHandler;
135
+ export { createEdgeStoreFastifyHandler };
@@ -1,7 +1,7 @@
1
1
  import { type EdgeStoreRouter, type MaybePromise, type Provider } from '@edgestore/shared';
2
2
  import { type Context as HonoContext } from 'hono';
3
- import { type LogLevel } from '../../libs/logger';
4
- import { type CookieConfig } from '../shared';
3
+ import { type LogLevel } from '../../libs/logger.js';
4
+ import { type CookieConfig } from '../shared.js';
5
5
  export type CreateContextOptions = {
6
6
  c: HonoContext;
7
7
  };