@critical-path/server 0.13.5 → 0.15.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/CHANGELOG.md +63 -0
- package/README.md +68 -0
- package/dist/adapters/next.d.ts +18 -8
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +11 -4
- package/dist/adapters/next.js.map +1 -1
- package/dist/adapters/sveltekit.d.ts +18 -20
- package/dist/adapters/sveltekit.d.ts.map +1 -1
- package/dist/adapters/sveltekit.js +5 -4
- package/dist/adapters/sveltekit.js.map +1 -1
- package/dist/adapters/universal.d.ts +8 -0
- package/dist/adapters/universal.d.ts.map +1 -0
- package/dist/adapters/universal.js +12 -0
- package/dist/adapters/universal.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +284 -0
- package/dist/index.test.js.map +1 -1
- package/dist/router.d.ts +72 -3
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +274 -124
- package/dist/router.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/next.ts +27 -6
- package/src/adapters/sveltekit.ts +22 -5
- package/src/adapters/universal.ts +16 -0
- package/src/index.test.ts +342 -0
- package/src/index.ts +1 -0
- package/src/router.ts +326 -125
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# @critical-path/server
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6dd5529: Add request context, authentication hooks and actor attribution.
|
|
8
|
+
|
|
9
|
+
**@critical-path/core**
|
|
10
|
+
- New `engine.withActor(actor)` returns a per-request view that attributes every mutation (activity log, comment authors, reactions, time entries, attachment uploaders, task reporters) to the actor and ignores identity fields supplied in payloads. New exported `Actor` type.
|
|
11
|
+
|
|
12
|
+
**@critical-path/server**
|
|
13
|
+
- New router options, accepted by all adapters as a second argument: `getContext` (resolve the caller per request), `requireAuth` (401 without a user), `basePath` (exact mount path), and `cors` (origin allow-list, credentials, or `false`).
|
|
14
|
+
- With a resolved user, identity fields in request bodies (`actorId`, `authorId`, `userId`, `uploaderId`) are ignored. Reaction routes no longer require `userId` in the body when a user is resolved.
|
|
15
|
+
- `createSvelteKitHandler` options take `getContext(event)` so `event.locals` is available; `configOrRouter` is now optional.
|
|
16
|
+
- New `createUniversalHandler(config, options)` for Workers, Deno, Bun and Hono.
|
|
17
|
+
- `handleRequest(request, { getContext })` lets custom adapters supply a per-request resolver.
|
|
18
|
+
|
|
19
|
+
**@critical-path/mcp**
|
|
20
|
+
- CLI `--api` mode reads `CRITICAL_PATH_API_TOKEN` (sent as a Bearer token) and accepts repeatable `--header "Name: value"`, warning when credentials would go over plain http to a remote host.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [6dd5529]
|
|
25
|
+
- @critical-path/core@0.23.0
|
|
26
|
+
|
|
27
|
+
## 0.14.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- b243a37: Fix correctness and safety issues found in a code audit.
|
|
32
|
+
|
|
33
|
+
**@critical-path/core**
|
|
34
|
+
- `SQLiteStore` now loads `node:sqlite` via `process.getBuiltinModule`, fixing `require is not defined` when constructed from a filename in plain Node ESM.
|
|
35
|
+
- Removed the unused `better-sqlite3` runtime dependency.
|
|
36
|
+
- `engine.addDependency` now detects indirect cycles (e.g. A → B → C → D → A), not just cycles between direct neighbours.
|
|
37
|
+
- Fixed `generateKeyBetween` returning out-of-range, duplicate keys after repeated inserts after the same item. It now throws a `RangeError` when `a >= b`.
|
|
38
|
+
- Added `engine.deleteProject(id)`, which deletes a project's tasks through `deleteTask` and publishes a new `project.deleted` event and webhook.
|
|
39
|
+
- Added exported `ValidationError` and `NotFoundError` classes. `logTime` now rejects non-numeric hours.
|
|
40
|
+
|
|
41
|
+
**@critical-path/server**
|
|
42
|
+
- `DELETE /projects/:id`, `POST /tasks/:id/dependencies` and `POST /time-entries` now go through the engine, so cycle checks, hour validation, roll-ups, events and webhooks apply.
|
|
43
|
+
- Added `PATCH /projects/:id`.
|
|
44
|
+
- `DELETE` on a resource that does not exist now returns `404` instead of `200 { success: false }`.
|
|
45
|
+
- Malformed JSON returns `400`, validation errors `400`, `NotFoundError` `404`, and dependency cycles `409`. Unexpected errors return a generic `500` message outside development.
|
|
46
|
+
- `OPTIONS` preflight requests return `204` with CORS headers.
|
|
47
|
+
- New router/adapter options: `onError(error, request)` to report unexpected errors or return a custom response, and `exposeErrors` to include real messages in 500 responses (defaults to on only when `NODE_ENV === 'development'`).
|
|
48
|
+
- `createNextHandler` returns a callable handler that also exposes per-method properties, so `export { handler as GET }` works as documented.
|
|
49
|
+
|
|
50
|
+
**@critical-path/mcp**
|
|
51
|
+
- Tools excluded via the `tools` option can no longer be called by name.
|
|
52
|
+
- Tool arguments are validated with each tool's zod schema; undeclared fields are stripped.
|
|
53
|
+
- Tool listings include `title` and MCP `readOnlyHint` / `destructiveHint` annotations.
|
|
54
|
+
|
|
55
|
+
**@critical-path/svelte**
|
|
56
|
+
- Rebuilt with the bundled `@critical-path/mcp` WebMCP argument validation.
|
|
57
|
+
|
|
58
|
+
**@critical-path/client**
|
|
59
|
+
- Delete methods resolve to `false` when the server returns `404`, keeping their boolean contract with the new server behaviour.
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated dependencies [b243a37]
|
|
64
|
+
- @critical-path/core@0.22.0
|
|
65
|
+
|
|
3
66
|
## 0.13.5
|
|
4
67
|
|
|
5
68
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -30,6 +30,9 @@ const handler = createNextHandler({
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
export { handler as GET, handler as POST, handler as PUT, handler as PATCH, handler as DELETE, handler as OPTIONS };
|
|
33
|
+
|
|
34
|
+
// Equivalent: the handler also exposes one property per method
|
|
35
|
+
// export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = createNextHandler({ ... });
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
---
|
|
@@ -53,6 +56,71 @@ export const OPTIONS = handler.OPTIONS;
|
|
|
53
56
|
|
|
54
57
|
---
|
|
55
58
|
|
|
59
|
+
## 🔐 Authentication, CORS & Mount Path
|
|
60
|
+
|
|
61
|
+
Router options are the second argument to `createNextHandler`, `createSvelteKitHandler`, `createUniversalHandler` and `new CriticalPathRouter(config, options)`:
|
|
62
|
+
|
|
63
|
+
| Option | Default | Description |
|
|
64
|
+
| :--- | :--- | :--- |
|
|
65
|
+
| `getContext(request)` | none | Resolve the caller (`{ userId, userName?, actorType?, ...extra }`). With a `userId`, every mutation is attributed to that user and identity fields in bodies (`actorId`, `authorId`, `userId`, `uploaderId`) are ignored. For SvelteKit it receives the `RequestEvent`, so `event.locals` is available. |
|
|
66
|
+
| `requireAuth` | `false` | Return `401` unless `getContext` yields a `userId`. `OPTIONS` preflight is always allowed. |
|
|
67
|
+
| `basePath` | strip up to first `/critical-path` | Exact mount path, e.g. `/api/pm`. Requests outside it return `404`. |
|
|
68
|
+
| `cors` | `{ origins: '*' }` | `{ origins: string[] \| '*', credentials?, allowHeaders?, maxAge? }`, or `false` for no CORS headers. `credentials` cannot be combined with `'*'`. |
|
|
69
|
+
| `onError`, `exposeErrors` | see below | Unexpected error reporting. |
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = createNextHandler(
|
|
73
|
+
{ store },
|
|
74
|
+
{
|
|
75
|
+
getContext: async () => {
|
|
76
|
+
const session = await auth();
|
|
77
|
+
return session?.user ? { userId: session.user.id } : null;
|
|
78
|
+
},
|
|
79
|
+
requireAuth: true,
|
|
80
|
+
cors: { origins: ['https://app.example.com'], credentials: true }
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For other Fetch runtimes (Workers, Deno, Bun, Hono), use `createUniversalHandler(config, options)`, which returns `(request) => Promise<Response>`.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## ⚠️ Error Responses
|
|
90
|
+
|
|
91
|
+
| Status | When |
|
|
92
|
+
| :--- | :--- |
|
|
93
|
+
| `400` | Malformed JSON, `ValidationError`, workflow transition or custom field validation failures |
|
|
94
|
+
| `401` | `requireAuth` is set and no user was resolved |
|
|
95
|
+
| `404` | Unknown route, `NotFoundError`, or `DELETE` of a resource that does not exist (successful deletes return `{ "success": true }`) |
|
|
96
|
+
| `409` | `CircularDependencyError` (body includes `cyclePath`) |
|
|
97
|
+
| `500` | Unexpected errors. The body is always `{ "error": "Internal Server Error" }`; the real error is logged with `console.error`. |
|
|
98
|
+
|
|
99
|
+
`OPTIONS` preflight requests return `204` with CORS headers.
|
|
100
|
+
|
|
101
|
+
### Reporting & Exposing Unexpected Errors
|
|
102
|
+
|
|
103
|
+
Both adapters (and `new CriticalPathRouter(config, options)`) accept router options as a second argument:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = createNextHandler(
|
|
107
|
+
{ store },
|
|
108
|
+
{
|
|
109
|
+
// Called only for unexpected (500) errors. Return a Response to replace the default.
|
|
110
|
+
onError: (error, request) => {
|
|
111
|
+
Sentry.captureException(error, { extra: { url: request.url } });
|
|
112
|
+
},
|
|
113
|
+
// Include real error messages in 500 responses.
|
|
114
|
+
// Defaults to true only when NODE_ENV === 'development'.
|
|
115
|
+
exposeErrors: false
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Without `onError`, unexpected errors are logged with `console.error`. Expected errors (400, 404, 409) always include their message and never reach `onError`.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
56
124
|
## 📄 License
|
|
57
125
|
|
|
58
126
|
MIT © [Critical Path](https://github.com/Pixerate/Critical-Path)
|
package/dist/adapters/next.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import { CriticalPathRouter } from '../router.js';
|
|
1
|
+
import { CriticalPathRouter, type CriticalPathRouterOptions } from '../router.js';
|
|
2
2
|
import type { CriticalPathConfig } from '@critical-path/core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
type NextRouteHandler = (request: Request) => Promise<Response>;
|
|
4
|
+
export type CriticalPathNextHandler = NextRouteHandler & {
|
|
5
|
+
GET: NextRouteHandler;
|
|
6
|
+
POST: NextRouteHandler;
|
|
7
|
+
PUT: NextRouteHandler;
|
|
8
|
+
PATCH: NextRouteHandler;
|
|
9
|
+
DELETE: NextRouteHandler;
|
|
10
|
+
OPTIONS: NextRouteHandler;
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Next.js App Router route handler. The result is callable and also exposes one
|
|
14
|
+
* property per HTTP method, so both export styles work:
|
|
15
|
+
*
|
|
16
|
+
* export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = createNextHandler(config);
|
|
17
|
+
* export { handler as GET, handler as POST, ... };
|
|
18
|
+
*/
|
|
19
|
+
export declare function createNextHandler(configOrRouter: CriticalPathConfig | CriticalPathRouter, options?: CriticalPathRouterOptions): CriticalPathNextHandler;
|
|
20
|
+
export {};
|
|
11
21
|
//# sourceMappingURL=next.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/adapters/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/adapters/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEhE,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,GAAG;IACvD,GAAG,EAAE,gBAAgB,CAAC;IACtB,IAAI,EAAE,gBAAgB,CAAC;IACvB,GAAG,EAAE,gBAAgB,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,kBAAkB,GAAG,kBAAkB,EACvD,OAAO,CAAC,EAAE,yBAAyB,GAClC,uBAAuB,CAiBzB"}
|
package/dist/adapters/next.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { CriticalPathRouter } from '../router.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Next.js App Router route handler. The result is callable and also exposes one
|
|
4
|
+
* property per HTTP method, so both export styles work:
|
|
5
|
+
*
|
|
6
|
+
* export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = createNextHandler(config);
|
|
7
|
+
* export { handler as GET, handler as POST, ... };
|
|
8
|
+
*/
|
|
9
|
+
export function createNextHandler(configOrRouter, options) {
|
|
3
10
|
const router = configOrRouter instanceof CriticalPathRouter
|
|
4
11
|
? configOrRouter
|
|
5
|
-
: new CriticalPathRouter(configOrRouter);
|
|
12
|
+
: new CriticalPathRouter(configOrRouter, options);
|
|
6
13
|
const handler = async (request) => {
|
|
7
14
|
return router.handleRequest(request);
|
|
8
15
|
};
|
|
9
|
-
return {
|
|
16
|
+
return Object.assign(handler, {
|
|
10
17
|
GET: handler,
|
|
11
18
|
POST: handler,
|
|
12
19
|
PUT: handler,
|
|
13
20
|
PATCH: handler,
|
|
14
21
|
DELETE: handler,
|
|
15
22
|
OPTIONS: handler
|
|
16
|
-
};
|
|
23
|
+
});
|
|
17
24
|
}
|
|
18
25
|
//# sourceMappingURL=next.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../src/adapters/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../src/adapters/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkC,MAAM,cAAc,CAAC;AAclF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,cAAuD,EACvD,OAAmC;IAEnC,MAAM,MAAM,GAAG,cAAc,YAAY,kBAAkB;QACzD,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,IAAI,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEpD,MAAM,OAAO,GAAqB,KAAK,EAAE,OAAgB,EAAE,EAAE;QAC3D,OAAO,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC5B,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { CriticalPathRouter } from '../router.js';
|
|
1
|
+
import { CriticalPathRouter, type CriticalPathRouterOptions, type RequestContext } from '../router.js';
|
|
2
2
|
import type { CriticalPathConfig } from '@critical-path/core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
OPTIONS: (
|
|
20
|
-
request: Request;
|
|
21
|
-
}) => Promise<Response>;
|
|
3
|
+
/** The subset of a SvelteKit `RequestEvent` the adapter uses. */
|
|
4
|
+
export interface SvelteKitRequestEvent {
|
|
5
|
+
request: Request;
|
|
6
|
+
locals?: Record<string, any>;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface SvelteKitHandlerOptions<TEvent extends SvelteKitRequestEvent = SvelteKitRequestEvent> extends Omit<CriticalPathRouterOptions, 'getContext'> {
|
|
10
|
+
/** Resolves the caller from the SvelteKit event, e.g. `event.locals.user` set by a hook. */
|
|
11
|
+
getContext?: (event: TEvent) => RequestContext | null | undefined | Promise<RequestContext | null | undefined>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createSvelteKitHandler<TEvent extends SvelteKitRequestEvent = SvelteKitRequestEvent>(configOrRouter?: CriticalPathConfig | CriticalPathRouter, options?: SvelteKitHandlerOptions<TEvent>): {
|
|
14
|
+
GET: (event: TEvent) => Promise<Response>;
|
|
15
|
+
POST: (event: TEvent) => Promise<Response>;
|
|
16
|
+
PUT: (event: TEvent) => Promise<Response>;
|
|
17
|
+
PATCH: (event: TEvent) => Promise<Response>;
|
|
18
|
+
DELETE: (event: TEvent) => Promise<Response>;
|
|
19
|
+
OPTIONS: (event: TEvent) => Promise<Response>;
|
|
22
20
|
};
|
|
23
21
|
//# sourceMappingURL=sveltekit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit.d.ts","sourceRoot":"","sources":["../../src/adapters/sveltekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sveltekit.d.ts","sourceRoot":"","sources":["../../src/adapters/sveltekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB,CAAC,MAAM,SAAS,qBAAqB,GAAG,qBAAqB,CACnG,SAAQ,IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC;IACrD,4FAA4F;IAC5F,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CAChH;AAED,wBAAgB,sBAAsB,CAAC,MAAM,SAAS,qBAAqB,GAAG,qBAAqB,EACjG,cAAc,GAAE,kBAAkB,GAAG,kBAAuB,EAC5D,OAAO,GAAE,uBAAuB,CAAC,MAAM,CAAM;iBAOf,MAAM;kBAAN,MAAM;iBAAN,MAAM;mBAAN,MAAM;oBAAN,MAAM;qBAAN,MAAM;EAYrC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CriticalPathRouter } from '../router.js';
|
|
2
|
-
export function createSvelteKitHandler(configOrRouter) {
|
|
2
|
+
export function createSvelteKitHandler(configOrRouter = {}, options = {}) {
|
|
3
|
+
const { getContext, ...routerOptions } = options;
|
|
3
4
|
const router = configOrRouter instanceof CriticalPathRouter
|
|
4
5
|
? configOrRouter
|
|
5
|
-
: new CriticalPathRouter(configOrRouter);
|
|
6
|
-
const handler = async (
|
|
7
|
-
return router.handleRequest(request);
|
|
6
|
+
: new CriticalPathRouter(configOrRouter, routerOptions);
|
|
7
|
+
const handler = async (event) => {
|
|
8
|
+
return router.handleRequest(event.request, getContext ? { getContext: () => getContext(event) } : {});
|
|
8
9
|
};
|
|
9
10
|
return {
|
|
10
11
|
GET: handler,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit.js","sourceRoot":"","sources":["../../src/adapters/sveltekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"sveltekit.js","sourceRoot":"","sources":["../../src/adapters/sveltekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuD,MAAM,cAAc,CAAC;AAgBvG,MAAM,UAAU,sBAAsB,CACpC,iBAA0D,EAAE,EAC5D,UAA2C,EAAE;IAE7C,MAAM,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,MAAM,GAAG,cAAc,YAAY,kBAAkB;QACzD,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,IAAI,kBAAkB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IAE1D,MAAM,OAAO,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;QACtC,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxG,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,OAAO;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CriticalPathRouter, type CriticalPathRouterOptions } from '../router.js';
|
|
2
|
+
import type { CriticalPathConfig } from '@critical-path/core';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a plain `(request: Request) => Promise<Response>` handler for any Fetch-compatible
|
|
5
|
+
* runtime (Cloudflare Workers, Deno, Bun, Hono, or Node frameworks with a Request bridge).
|
|
6
|
+
*/
|
|
7
|
+
export declare function createUniversalHandler(configOrRouter?: CriticalPathConfig | CriticalPathRouter, options?: CriticalPathRouterOptions): (request: Request) => Promise<Response>;
|
|
8
|
+
//# sourceMappingURL=universal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal.d.ts","sourceRoot":"","sources":["../../src/adapters/universal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,GAAE,kBAAkB,GAAG,kBAAuB,EAC5D,OAAO,CAAC,EAAE,yBAAyB,GAClC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAKzC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CriticalPathRouter } from '../router.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a plain `(request: Request) => Promise<Response>` handler for any Fetch-compatible
|
|
4
|
+
* runtime (Cloudflare Workers, Deno, Bun, Hono, or Node frameworks with a Request bridge).
|
|
5
|
+
*/
|
|
6
|
+
export function createUniversalHandler(configOrRouter = {}, options) {
|
|
7
|
+
const router = configOrRouter instanceof CriticalPathRouter
|
|
8
|
+
? configOrRouter
|
|
9
|
+
: new CriticalPathRouter(configOrRouter, options);
|
|
10
|
+
return (request) => router.handleRequest(request);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=universal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal.js","sourceRoot":"","sources":["../../src/adapters/universal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkC,MAAM,cAAc,CAAC;AAGlF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,iBAA0D,EAAE,EAC5D,OAAmC;IAEnC,MAAM,MAAM,GAAG,cAAc,YAAY,kBAAkB;QACzD,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,IAAI,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,CAAC,OAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
|