@evjs/runtime 0.0.1-rc.2 → 0.0.1-rc.5
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/AGENT.md +8 -8
- package/README.md +96 -40
- package/esm/client/create-app.d.ts +5 -0
- package/esm/client/create-app.d.ts.map +1 -1
- package/esm/client/create-app.js +5 -1
- package/esm/client/create-app.js.map +1 -1
- package/esm/client/index.d.ts +8 -3
- package/esm/client/index.d.ts.map +1 -1
- package/esm/client/index.js +5 -3
- package/esm/client/index.js.map +1 -1
- package/esm/client/query.d.ts +19 -5
- package/esm/client/query.d.ts.map +1 -1
- package/esm/client/query.js +52 -14
- package/esm/client/query.js.map +1 -1
- package/esm/client/transport.d.ts +11 -3
- package/esm/client/transport.d.ts.map +1 -1
- package/esm/client/transport.js +36 -12
- package/esm/client/transport.js.map +1 -1
- package/esm/codec.d.ts +31 -0
- package/esm/codec.d.ts.map +1 -0
- package/esm/codec.js +7 -0
- package/esm/codec.js.map +1 -0
- package/esm/constants.d.ts +6 -2
- package/esm/constants.d.ts.map +1 -1
- package/esm/constants.js +6 -2
- package/esm/constants.js.map +1 -1
- package/esm/errors.d.ts +37 -0
- package/esm/errors.d.ts.map +1 -0
- package/esm/errors.js +45 -0
- package/esm/errors.js.map +1 -0
- package/esm/serializer.d.ts +31 -0
- package/esm/serializer.d.ts.map +1 -0
- package/esm/serializer.js +7 -0
- package/esm/serializer.js.map +1 -0
- package/esm/server/app.d.ts +7 -5
- package/esm/server/app.d.ts.map +1 -1
- package/esm/server/app.js +7 -10
- package/esm/server/app.js.map +1 -1
- package/esm/server/dispatch.d.ts +71 -0
- package/esm/server/dispatch.d.ts.map +1 -0
- package/esm/server/dispatch.js +80 -0
- package/esm/server/dispatch.js.map +1 -0
- package/esm/server/environments/ecma.d.ts +2 -2
- package/esm/server/environments/ecma.d.ts.map +1 -1
- package/esm/server/environments/ecma.js +2 -2
- package/esm/server/environments/ecma.js.map +1 -1
- package/esm/server/environments/node.d.ts +2 -3
- package/esm/server/environments/node.d.ts.map +1 -1
- package/esm/server/environments/node.js +4 -5
- package/esm/server/environments/node.js.map +1 -1
- package/esm/server/handler.d.ts +12 -8
- package/esm/server/handler.d.ts.map +1 -1
- package/esm/server/handler.js +25 -28
- package/esm/server/handler.js.map +1 -1
- package/esm/server/index.d.ts +7 -1
- package/esm/server/index.d.ts.map +1 -1
- package/esm/server/index.js +4 -1
- package/esm/server/index.js.map +1 -1
- package/esm/server/register.d.ts +2 -2
- package/esm/server/register.js +2 -2
- package/package.json +1 -1
package/esm/client/transport.js
CHANGED
|
@@ -5,30 +5,35 @@
|
|
|
5
5
|
* bundle, each exported function is replaced with a stub that calls
|
|
6
6
|
* `__ev_call(fnId, args)`. This module provides that helper.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { jsonCodec } from "../codec";
|
|
9
|
+
import { DEFAULT_CONTENT_TYPE, DEFAULT_ENDPOINT, DEFAULT_ERROR_STATUS, } from "../constants";
|
|
10
|
+
import { ServerFunctionError } from "../errors";
|
|
9
11
|
/**
|
|
10
12
|
* Default fetch-based transport.
|
|
11
13
|
*/
|
|
12
|
-
function createFetchTransport(baseUrl, endpoint) {
|
|
14
|
+
function createFetchTransport(baseUrl, endpoint, codec = jsonCodec) {
|
|
13
15
|
return {
|
|
14
16
|
async send(fnId, args, context) {
|
|
15
17
|
const url = `${baseUrl}${endpoint}`;
|
|
16
18
|
const res = await fetch(url, {
|
|
17
19
|
method: "POST",
|
|
18
20
|
headers: {
|
|
19
|
-
"Content-Type":
|
|
21
|
+
"Content-Type": codec.contentType ?? DEFAULT_CONTENT_TYPE,
|
|
20
22
|
...context?.headers,
|
|
21
23
|
},
|
|
22
|
-
body:
|
|
24
|
+
body: codec.serialize({ fnId, args }),
|
|
23
25
|
signal: context?.signal,
|
|
24
26
|
});
|
|
25
27
|
if (!res.ok) {
|
|
26
28
|
const text = await res.text().catch(() => res.statusText);
|
|
27
|
-
|
|
29
|
+
const name = getFnName(fnId);
|
|
30
|
+
throw new ServerFunctionError(`Server function "${name}" failed (${res.status}): ${text}`, fnId, res.status);
|
|
28
31
|
}
|
|
29
|
-
const
|
|
32
|
+
const raw = await res.text();
|
|
33
|
+
const payload = codec.deserialize(raw);
|
|
30
34
|
if (payload.error) {
|
|
31
|
-
|
|
35
|
+
const name = getFnName(fnId);
|
|
36
|
+
throw new ServerFunctionError(`Server function "${name}" threw: ${payload.error}`, payload.fnId ?? fnId, DEFAULT_ERROR_STATUS, { data: payload.data });
|
|
32
37
|
}
|
|
33
38
|
return payload.result;
|
|
34
39
|
},
|
|
@@ -37,7 +42,7 @@ function createFetchTransport(baseUrl, endpoint) {
|
|
|
37
42
|
let _transport = null;
|
|
38
43
|
function getTransport() {
|
|
39
44
|
if (!_transport) {
|
|
40
|
-
_transport = createFetchTransport("",
|
|
45
|
+
_transport = createFetchTransport("", DEFAULT_ENDPOINT);
|
|
41
46
|
}
|
|
42
47
|
return _transport;
|
|
43
48
|
}
|
|
@@ -45,12 +50,16 @@ function getTransport() {
|
|
|
45
50
|
* Configure the server transport. Call once at app startup if you need to
|
|
46
51
|
* customise the endpoint URL or provide a custom transport.
|
|
47
52
|
*/
|
|
48
|
-
export function
|
|
53
|
+
export function initTransport(options) {
|
|
54
|
+
if (process.env.NODE_ENV !== "production" && _transport !== null) {
|
|
55
|
+
console.warn("[ev] initTransport() was called more than once. " +
|
|
56
|
+
"This overwrites the previous transport configuration.");
|
|
57
|
+
}
|
|
49
58
|
if (options.transport) {
|
|
50
59
|
_transport = options.transport;
|
|
51
60
|
}
|
|
52
61
|
else {
|
|
53
|
-
_transport = createFetchTransport(options.baseUrl ?? "", options.endpoint ??
|
|
62
|
+
_transport = createFetchTransport(options.baseUrl ?? "", options.endpoint ?? DEFAULT_ENDPOINT, options.codec);
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
65
|
/**
|
|
@@ -69,13 +78,28 @@ export async function __ev_call(fnId, args, context) {
|
|
|
69
78
|
// biome-ignore lint/suspicious/noExplicitAny: must accept any function shape
|
|
70
79
|
const fnIdRegistry = new WeakMap();
|
|
71
80
|
/**
|
|
72
|
-
*
|
|
81
|
+
* Internal registry mapping function IDs to human-readable export names.
|
|
82
|
+
*/
|
|
83
|
+
const fnNameRegistry = new Map();
|
|
84
|
+
/**
|
|
85
|
+
* Look up the human-readable export name for a function ID.
|
|
86
|
+
* Falls back to the fnId itself if no name is registered.
|
|
87
|
+
*/
|
|
88
|
+
export function getFnName(fnId) {
|
|
89
|
+
return fnNameRegistry.get(fnId) ?? fnId;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Register a server function stub with its ID and optional export name.
|
|
73
93
|
*
|
|
74
94
|
* @internal Called by build-tools codegen. Do not use directly.
|
|
75
95
|
*/
|
|
96
|
+
export function __ev_register(
|
|
76
97
|
// biome-ignore lint/suspicious/noExplicitAny: must accept any function shape
|
|
77
|
-
|
|
98
|
+
fn, fnId, exportName) {
|
|
78
99
|
fnIdRegistry.set(fn, fnId);
|
|
100
|
+
if (exportName) {
|
|
101
|
+
fnNameRegistry.set(fnId, exportName);
|
|
102
|
+
}
|
|
79
103
|
}
|
|
80
104
|
/**
|
|
81
105
|
* Look up the internal function ID for a server function stub.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/client/transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/client/transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAc,SAAS,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAqDhD;;GAEG;AACH,SAAS,oBAAoB,CAC3B,OAAe,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I,CAAC,IAAI,IAAI,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;AAC3B,6EAA6E;AAC7E,EAA2B,EAC3B,IAAY,EACZ,UAAmB;IAEnB,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3B,IAAI,UAAU,EAAE,CAAC;QACf,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,6EAA6E;AAC7E,MAAM,UAAU,OAAO,CAAC,EAA2B;IACjD,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC9B,CAAC"}
|
package/esm/codec.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable codec interface for serialization/deserialization.
|
|
3
|
+
*
|
|
4
|
+
* By default the framework uses JSON. Implement this interface to use
|
|
5
|
+
* a custom codec (e.g. protobuf, msgpack, superjson, devalue).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import superjson from "superjson";
|
|
10
|
+
*
|
|
11
|
+
* const superJsonCodec: Codec = {
|
|
12
|
+
* contentType: "application/json",
|
|
13
|
+
* serialize: (data) => superjson.stringify(data),
|
|
14
|
+
* deserialize: (raw) => superjson.parse(raw as string),
|
|
15
|
+
* };
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface Codec {
|
|
19
|
+
/**
|
|
20
|
+
* Content-Type header value for the serialized format.
|
|
21
|
+
* Defaults to `"application/json"` when not specified.
|
|
22
|
+
*/
|
|
23
|
+
contentType?: string;
|
|
24
|
+
/** Serialize a JS value for transmission. */
|
|
25
|
+
serialize(data: unknown): string | ArrayBuffer;
|
|
26
|
+
/** Deserialize a raw payload back to a JS value. */
|
|
27
|
+
deserialize(raw: string | ArrayBuffer): unknown;
|
|
28
|
+
}
|
|
29
|
+
/** Built-in JSON codec (the default). */
|
|
30
|
+
export declare const jsonCodec: Codec;
|
|
31
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC;IAE/C,oDAAoD;IACpD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;CACjD;AAED,yCAAyC;AACzC,eAAO,MAAM,SAAS,EAAE,KAIvB,CAAC"}
|
package/esm/codec.js
ADDED
package/esm/codec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AA+BA,yCAAyC;AACzC,MAAM,CAAC,MAAM,SAAS,GAAU;IAC9B,WAAW,EAAE,kBAAkB;IAC/B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IACzC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAa,CAAC;CAChD,CAAC"}
|
package/esm/constants.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared constants for the ev runtime.
|
|
3
3
|
*/
|
|
4
|
-
/** Default
|
|
5
|
-
export declare const
|
|
4
|
+
/** Default server function endpoint path, shared between client and server. */
|
|
5
|
+
export declare const DEFAULT_ENDPOINT = "/api/fn";
|
|
6
|
+
/** Default HTTP status code for server function errors. */
|
|
7
|
+
export declare const DEFAULT_ERROR_STATUS = 500;
|
|
8
|
+
/** Default content type for server function requests/responses. */
|
|
9
|
+
export declare const DEFAULT_CONTENT_TYPE = "application/json";
|
|
6
10
|
//# sourceMappingURL=constants.d.ts.map
|
package/esm/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,qBAAqB,CAAC"}
|
package/esm/constants.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared constants for the ev runtime.
|
|
3
3
|
*/
|
|
4
|
-
/** Default
|
|
5
|
-
export const
|
|
4
|
+
/** Default server function endpoint path, shared between client and server. */
|
|
5
|
+
export const DEFAULT_ENDPOINT = "/api/fn";
|
|
6
|
+
/** Default HTTP status code for server function errors. */
|
|
7
|
+
export const DEFAULT_ERROR_STATUS = 500;
|
|
8
|
+
/** Default content type for server function requests/responses. */
|
|
9
|
+
export const DEFAULT_CONTENT_TYPE = "application/json";
|
|
6
10
|
//# sourceMappingURL=constants.js.map
|
package/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAE1C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC"}
|
package/esm/errors.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a server function call fails.
|
|
3
|
+
* Available on both client and server.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ServerFunctionError extends Error {
|
|
6
|
+
/** The unique function ID. */
|
|
7
|
+
readonly fnId: string;
|
|
8
|
+
/** HTTP status code from the server. */
|
|
9
|
+
readonly status: number;
|
|
10
|
+
/** Structured error data from the server (if any). */
|
|
11
|
+
readonly data?: unknown;
|
|
12
|
+
constructor(message: string, fnId: string, status: number, options?: {
|
|
13
|
+
cause?: Error;
|
|
14
|
+
data?: unknown;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Throwable error for server functions to return structured error data.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* export async function getUser(id: string) {
|
|
23
|
+
* const user = db.find(id);
|
|
24
|
+
* if (!user) throw new ServerError("User not found", { status: 404, data: { id } });
|
|
25
|
+
* return user;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class ServerError extends Error {
|
|
30
|
+
readonly status: number;
|
|
31
|
+
readonly data?: unknown;
|
|
32
|
+
constructor(message: string, options?: {
|
|
33
|
+
status?: number;
|
|
34
|
+
data?: unknown;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;gBAGtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;CAS9C;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;CAM3E"}
|
package/esm/errors.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DEFAULT_ERROR_STATUS } from "./constants";
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when a server function call fails.
|
|
4
|
+
* Available on both client and server.
|
|
5
|
+
*/
|
|
6
|
+
export class ServerFunctionError extends Error {
|
|
7
|
+
/** The unique function ID. */
|
|
8
|
+
fnId;
|
|
9
|
+
/** HTTP status code from the server. */
|
|
10
|
+
status;
|
|
11
|
+
/** Structured error data from the server (if any). */
|
|
12
|
+
data;
|
|
13
|
+
constructor(message, fnId, status, options) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "ServerFunctionError";
|
|
16
|
+
this.fnId = fnId;
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.data = options?.data;
|
|
19
|
+
if (options?.cause)
|
|
20
|
+
this.cause = options.cause;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Throwable error for server functions to return structured error data.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* export async function getUser(id: string) {
|
|
29
|
+
* const user = db.find(id);
|
|
30
|
+
* if (!user) throw new ServerError("User not found", { status: 404, data: { id } });
|
|
31
|
+
* return user;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export class ServerError extends Error {
|
|
36
|
+
status;
|
|
37
|
+
data;
|
|
38
|
+
constructor(message, options) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.name = "ServerError";
|
|
41
|
+
this.status = options?.status ?? DEFAULT_ERROR_STATUS;
|
|
42
|
+
this.data = options?.data;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,8BAA8B;IACrB,IAAI,CAAS;IACtB,wCAAwC;IAC/B,MAAM,CAAS;IACxB,sDAAsD;IAC7C,IAAI,CAAW;IAExB,YACE,OAAe,EACf,IAAY,EACZ,MAAc,EACd,OAA2C;QAE3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAC1B,IAAI,OAAO,EAAE,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IACjD,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,MAAM,CAAS;IACf,IAAI,CAAW;IAExB,YAAY,OAAe,EAAE,OAA6C;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,oBAAoB,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable serialization interface.
|
|
3
|
+
*
|
|
4
|
+
* By default the framework uses JSON. Implement this interface to use
|
|
5
|
+
* a custom serializer (e.g. protobuf, msgpack, superjson, devalue).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import superjson from "superjson";
|
|
10
|
+
*
|
|
11
|
+
* const superJsonSerializer: Serializer = {
|
|
12
|
+
* contentType: "application/json",
|
|
13
|
+
* serialize: (data) => superjson.stringify(data),
|
|
14
|
+
* deserialize: (raw) => superjson.parse(raw as string),
|
|
15
|
+
* };
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface Serializer {
|
|
19
|
+
/**
|
|
20
|
+
* Content-Type header value for the serialized format.
|
|
21
|
+
* Defaults to `"application/json"` when not specified.
|
|
22
|
+
*/
|
|
23
|
+
contentType?: string;
|
|
24
|
+
/** Serialize a JS value for transmission. */
|
|
25
|
+
serialize(data: unknown): string | ArrayBuffer;
|
|
26
|
+
/** Deserialize a raw payload back to a JS value. */
|
|
27
|
+
deserialize(raw: string | ArrayBuffer): unknown;
|
|
28
|
+
}
|
|
29
|
+
/** Built-in JSON serializer (the default). */
|
|
30
|
+
export declare const jsonSerializer: Serializer;
|
|
31
|
+
//# sourceMappingURL=serializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC;IAE/C,oDAAoD;IACpD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;CACjD;AAED,8CAA8C;AAC9C,eAAO,MAAM,cAAc,EAAE,UAI5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AA+BA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,WAAW,EAAE,kBAAkB;IAC/B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IACzC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAa,CAAC;CAChD,CAAC"}
|
package/esm/server/app.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server application factory.
|
|
3
3
|
*
|
|
4
|
-
* Creates a Hono app with
|
|
4
|
+
* Creates a Hono app with server function handler.
|
|
5
5
|
* This app is runtime-agnostic and can be mounted in Node, Edge, or Bun.
|
|
6
6
|
*/
|
|
7
7
|
import { Hono } from "hono";
|
|
8
|
+
import type { Codec } from "../codec";
|
|
8
9
|
/** Options for createApp. */
|
|
9
10
|
export interface CreateAppOptions {
|
|
10
|
-
/**
|
|
11
|
-
|
|
11
|
+
/** server function endpoint path. Defaults to "/api/fn". */
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
/** Custom codec for the server function endpoint. Defaults to JSON. */
|
|
14
|
+
codec?: Codec;
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
17
|
* Create an ev API server application.
|
|
15
18
|
*
|
|
16
|
-
* Mounts the
|
|
17
|
-
* In Stage 3, this will be extended with SSR middleware.
|
|
19
|
+
* Mounts the server function handler at the configured endpoint.
|
|
18
20
|
*
|
|
19
21
|
* @param options - Application configuration.
|
|
20
22
|
* @returns A runtime-agnostic Hono app instance.
|
package/esm/server/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAItC,6BAA6B;AAC7B,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAS1D"}
|
package/esm/server/app.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server application factory.
|
|
3
3
|
*
|
|
4
|
-
* Creates a Hono app with
|
|
4
|
+
* Creates a Hono app with server function handler.
|
|
5
5
|
* This app is runtime-agnostic and can be mounted in Node, Edge, or Bun.
|
|
6
6
|
*/
|
|
7
7
|
import { Hono } from "hono";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { DEFAULT_ENDPOINT } from "../constants";
|
|
9
|
+
import { createHandler } from "./handler";
|
|
10
10
|
/**
|
|
11
11
|
* Create an ev API server application.
|
|
12
12
|
*
|
|
13
|
-
* Mounts the
|
|
14
|
-
* In Stage 3, this will be extended with SSR middleware.
|
|
13
|
+
* Mounts the server function handler at the configured endpoint.
|
|
15
14
|
*
|
|
16
15
|
* @param options - Application configuration.
|
|
17
16
|
* @returns A runtime-agnostic Hono app instance.
|
|
18
17
|
*/
|
|
19
18
|
export function createApp(options) {
|
|
20
|
-
const {
|
|
19
|
+
const { endpoint = DEFAULT_ENDPOINT, codec } = options ?? {};
|
|
21
20
|
const app = new Hono();
|
|
22
|
-
//
|
|
23
|
-
app.
|
|
24
|
-
// Mount RPC endpoint
|
|
25
|
-
app.route(rpcEndpoint, createRpcMiddleware());
|
|
21
|
+
// Mount server function endpoint
|
|
22
|
+
app.route(endpoint, createHandler({ codec }));
|
|
26
23
|
return app;
|
|
27
24
|
}
|
|
28
25
|
//# sourceMappingURL=app.js.map
|
package/esm/server/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAU1C;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,OAA0B;IAClD,MAAM,EAAE,QAAQ,GAAG,gBAAgB,EAAE,KAAK,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE7D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,iCAAiC;IACjC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAE9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol-agnostic server function dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* Looks up a registered server function by ID, invokes it with the
|
|
5
|
+
* given arguments, and returns a structured result. This is the core
|
|
6
|
+
* dispatch logic used by the HTTP handler and can be used directly
|
|
7
|
+
* to build custom transport adapters (WebSocket, IPC, etc.).
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Context passed to middleware functions.
|
|
11
|
+
*/
|
|
12
|
+
export interface MiddlewareContext {
|
|
13
|
+
/** The function ID being called. */
|
|
14
|
+
fnId: string;
|
|
15
|
+
/** The arguments passed to the function. */
|
|
16
|
+
args: unknown[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Middleware function type.
|
|
20
|
+
* Call `next()` to proceed to the next middleware or the function itself.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* registerMiddleware(async (ctx, next) => {
|
|
25
|
+
* console.log(`Calling ${ctx.fnId}`);
|
|
26
|
+
* const start = Date.now();
|
|
27
|
+
* const result = await next();
|
|
28
|
+
* console.log(`${ctx.fnId} took ${Date.now() - start}ms`);
|
|
29
|
+
* return result;
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type Middleware = (ctx: MiddlewareContext, next: () => Promise<unknown>) => Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Register a middleware that wraps all server function calls.
|
|
36
|
+
* Middleware functions run in registration order.
|
|
37
|
+
*/
|
|
38
|
+
export declare function registerMiddleware(fn: Middleware): void;
|
|
39
|
+
/** Successful dispatch result. */
|
|
40
|
+
export interface DispatchSuccess {
|
|
41
|
+
result: unknown;
|
|
42
|
+
}
|
|
43
|
+
/** Failed dispatch result. */
|
|
44
|
+
export interface DispatchError {
|
|
45
|
+
error: string;
|
|
46
|
+
fnId: string;
|
|
47
|
+
/** HTTP-equivalent status code for the error. */
|
|
48
|
+
status: number;
|
|
49
|
+
/** Structured error data (if thrown via ServerError). */
|
|
50
|
+
data?: unknown;
|
|
51
|
+
}
|
|
52
|
+
export type DispatchResult = DispatchSuccess | DispatchError;
|
|
53
|
+
/**
|
|
54
|
+
* Dispatch an server function call to a registered server function.
|
|
55
|
+
*
|
|
56
|
+
* @param fnId - The unique function ID.
|
|
57
|
+
* @param args - The arguments to pass to the function.
|
|
58
|
+
* @returns A structured result: `{ result }` on success, `{ error, fnId, status }` on failure.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* // WebSocket adapter
|
|
63
|
+
* ws.on("message", async (data) => {
|
|
64
|
+
* const { fnId, args } = JSON.parse(data);
|
|
65
|
+
* const response = await dispatch(fnId, args);
|
|
66
|
+
* ws.send(JSON.stringify(response));
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function dispatch(fnId: string, args: unknown[]): Promise<DispatchResult>;
|
|
71
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/server/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,KACzB,OAAO,CAAC,OAAO,CAAC,CAAC;AAItB;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAEvD;AAED,kCAAkC;AAClC,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,8BAA8B;AAC9B,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,aAAa,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EAAE,GACd,OAAO,CAAC,cAAc,CAAC,CA4CzB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol-agnostic server function dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* Looks up a registered server function by ID, invokes it with the
|
|
5
|
+
* given arguments, and returns a structured result. This is the core
|
|
6
|
+
* dispatch logic used by the HTTP handler and can be used directly
|
|
7
|
+
* to build custom transport adapters (WebSocket, IPC, etc.).
|
|
8
|
+
*/
|
|
9
|
+
import { DEFAULT_ERROR_STATUS } from "../constants";
|
|
10
|
+
import { ServerError } from "../errors";
|
|
11
|
+
import { registry } from "./register";
|
|
12
|
+
const middlewares = [];
|
|
13
|
+
/**
|
|
14
|
+
* Register a middleware that wraps all server function calls.
|
|
15
|
+
* Middleware functions run in registration order.
|
|
16
|
+
*/
|
|
17
|
+
export function registerMiddleware(fn) {
|
|
18
|
+
middlewares.push(fn);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Dispatch an server function call to a registered server function.
|
|
22
|
+
*
|
|
23
|
+
* @param fnId - The unique function ID.
|
|
24
|
+
* @param args - The arguments to pass to the function.
|
|
25
|
+
* @returns A structured result: `{ result }` on success, `{ error, fnId, status }` on failure.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // WebSocket adapter
|
|
30
|
+
* ws.on("message", async (data) => {
|
|
31
|
+
* const { fnId, args } = JSON.parse(data);
|
|
32
|
+
* const response = await dispatch(fnId, args);
|
|
33
|
+
* ws.send(JSON.stringify(response));
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export async function dispatch(fnId, args) {
|
|
38
|
+
if (!fnId || typeof fnId !== "string") {
|
|
39
|
+
return {
|
|
40
|
+
error: "Missing or invalid 'fnId' in request body",
|
|
41
|
+
fnId: fnId ?? "",
|
|
42
|
+
status: 400,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const fn = registry.get(fnId);
|
|
46
|
+
if (!fn) {
|
|
47
|
+
return {
|
|
48
|
+
error: `Server function "${fnId}" not found`,
|
|
49
|
+
fnId,
|
|
50
|
+
status: 404,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
// Build middleware chain
|
|
55
|
+
let index = 0;
|
|
56
|
+
const runFn = () => fn(...args);
|
|
57
|
+
const next = () => {
|
|
58
|
+
if (index < middlewares.length) {
|
|
59
|
+
const mw = middlewares[index++];
|
|
60
|
+
return mw({ fnId, args }, next);
|
|
61
|
+
}
|
|
62
|
+
return runFn();
|
|
63
|
+
};
|
|
64
|
+
const result = await next();
|
|
65
|
+
return { result };
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err instanceof ServerError) {
|
|
69
|
+
return {
|
|
70
|
+
error: err.message,
|
|
71
|
+
fnId,
|
|
72
|
+
status: err.status,
|
|
73
|
+
data: err.data,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
77
|
+
return { error: message, fnId, status: DEFAULT_ERROR_STATUS };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=disp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OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,WAAW,EAAE,CAAC;YAC/B,OAAO;gBACL,KAAK,EAAE,GAAG,CAAC,OAAO;gBAClB,IAAI;gBACJ,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,IAAI,EAAE,GAAG,CAAC,IAAI;aACf,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -4,7 +4,7 @@ import type { Hono } from "hono";
|
|
|
4
4
|
*
|
|
5
5
|
* Exports the Hono app's fetch handler as a standard ECMA-compatible
|
|
6
6
|
* module. Works in any runtime that supports the Fetch API standard
|
|
7
|
-
* (Deno, Bun,
|
|
7
|
+
* (Deno, Bun, or any Fetch-compatible runtime.).
|
|
8
8
|
*
|
|
9
9
|
* Usage:
|
|
10
10
|
* ```ts
|
|
@@ -13,7 +13,7 @@ import type { Hono } from "hono";
|
|
|
13
13
|
* export default createHandler(app);
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function createFetchHandler(app: Hono): {
|
|
17
17
|
fetch: (request: Request, Env?: unknown, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=ecma.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecma.d.ts","sourceRoot":"","sources":["../../../src/server/environments/ecma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"ecma.d.ts","sourceRoot":"","sources":["../../../src/server/environments/ecma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI;;EAI3C"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exports the Hono app's fetch handler as a standard ECMA-compatible
|
|
5
5
|
* module. Works in any runtime that supports the Fetch API standard
|
|
6
|
-
* (Deno, Bun,
|
|
6
|
+
* (Deno, Bun, or any Fetch-compatible runtime.).
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
9
|
* ```ts
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* export default createHandler(app);
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
-
export function
|
|
15
|
+
export function createFetchHandler(app) {
|
|
16
16
|
return {
|
|
17
17
|
fetch: app.fetch,
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecma.js","sourceRoot":"","sources":["../../../src/server/environments/ecma.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"ecma.js","sourceRoot":"","sources":["../../../src/server/environments/ecma.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAS;IAC1C,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -4,11 +4,10 @@ export interface NodeRunnerOptions {
|
|
|
4
4
|
host?: string;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* Takes a compiled Hono app and starts a native Node HTTP server.
|
|
7
|
+
* Start a Node.js HTTP server for the given Hono app.
|
|
9
8
|
*
|
|
10
9
|
* Port resolution order: options.port → PORT env → 3001 default.
|
|
11
10
|
* Registers SIGTERM/SIGINT handlers for graceful shutdown.
|
|
12
11
|
*/
|
|
13
|
-
export declare function
|
|
12
|
+
export declare function serve(app: Hono, options?: NodeRunnerOptions): import("@hono/node-server").ServerType;
|
|
14
13
|
//# sourceMappingURL=node.d.ts.map
|