@mokup/server 1.1.0 → 1.1.2
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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/dist/connect.cjs +25 -0
- package/dist/connect.d.cts +8 -0
- package/dist/connect.d.mts +8 -0
- package/dist/connect.d.ts +8 -0
- package/dist/connect.mjs +23 -0
- package/dist/express.cjs +11 -0
- package/dist/express.d.cts +7 -0
- package/dist/express.d.mts +7 -0
- package/dist/express.d.ts +7 -0
- package/dist/express.mjs +9 -0
- package/dist/fastify.cjs +39 -0
- package/dist/fastify.d.cts +18 -0
- package/dist/fastify.d.mts +18 -0
- package/dist/fastify.d.ts +18 -0
- package/dist/fastify.mjs +37 -0
- package/dist/fetch-server.cjs +1507 -0
- package/dist/fetch-server.d.cts +54 -0
- package/dist/fetch-server.d.mts +54 -0
- package/dist/fetch-server.d.ts +54 -0
- package/dist/fetch-server.mjs +1500 -0
- package/dist/fetch.cjs +26 -0
- package/dist/fetch.d.cts +6 -0
- package/dist/fetch.d.mts +6 -0
- package/dist/fetch.d.ts +6 -0
- package/dist/fetch.mjs +24 -0
- package/dist/hono.cjs +27 -0
- package/dist/hono.d.cts +21 -0
- package/dist/hono.d.mts +21 -0
- package/dist/hono.d.ts +21 -0
- package/dist/hono.mjs +25 -0
- package/dist/index.cjs +5 -1593
- package/dist/index.d.cts +3 -134
- package/dist/index.d.mts +3 -134
- package/dist/index.d.ts +3 -134
- package/dist/index.mjs +4 -1585
- package/dist/koa.cjs +38 -0
- package/dist/koa.d.cts +18 -0
- package/dist/koa.d.mts +18 -0
- package/dist/koa.d.ts +18 -0
- package/dist/koa.mjs +36 -0
- package/dist/node.cjs +26 -0
- package/dist/node.d.cts +12 -0
- package/dist/node.d.mts +12 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.mjs +19 -0
- package/dist/shared/{server.BdTl0qJd.cjs → server.3GcmR3Ev.cjs} +2 -23
- package/dist/shared/{server.DNITwCtQ.d.cts → server.B82hrXoo.d.cts} +2 -2
- package/dist/shared/{server.DNITwCtQ.d.mts → server.B82hrXoo.d.mts} +2 -2
- package/dist/shared/{server.DNITwCtQ.d.ts → server.B82hrXoo.d.ts} +2 -2
- package/dist/shared/server.Cb2eiCU2.d.cts +17 -0
- package/dist/shared/server.Cb2eiCU2.d.mts +17 -0
- package/dist/shared/server.Cb2eiCU2.d.ts +17 -0
- package/dist/shared/{server.Dje1y79O.mjs → server.tZ4R8aB2.mjs} +1 -23
- package/dist/worker-node.cjs +74 -0
- package/dist/worker-node.d.cts +12 -0
- package/dist/worker-node.d.mts +12 -0
- package/dist/worker-node.d.ts +12 -0
- package/dist/worker-node.mjs +72 -0
- package/dist/worker.cjs +6 -2
- package/dist/worker.d.cts +2 -2
- package/dist/worker.d.mts +2 -2
- package/dist/worker.d.ts +2 -2
- package/dist/worker.mjs +6 -2
- package/package.json +44 -4
package/dist/fetch.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const runtime = require('@mokup/runtime');
|
|
4
|
+
const internal = require('./shared/server.3GcmR3Ev.cjs');
|
|
5
|
+
|
|
6
|
+
function createFetchHandler(options) {
|
|
7
|
+
const runtime$1 = runtime.createRuntime(internal.toRuntimeOptions(options));
|
|
8
|
+
const onNotFound = options.onNotFound ?? "next";
|
|
9
|
+
return async (request) => {
|
|
10
|
+
const runtimeRequest = await internal.toRuntimeRequestFromFetch(request);
|
|
11
|
+
const result = await runtime$1.handle(runtimeRequest);
|
|
12
|
+
if (!result) {
|
|
13
|
+
if (onNotFound === "response") {
|
|
14
|
+
return new Response(null, { status: 404 });
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const responseBody = result.body === null ? null : typeof result.body === "string" ? result.body : internal.toArrayBuffer(result.body);
|
|
19
|
+
return new Response(responseBody, {
|
|
20
|
+
status: result.status,
|
|
21
|
+
headers: result.headers
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.createFetchHandler = createFetchHandler;
|
package/dist/fetch.d.cts
ADDED
package/dist/fetch.d.mts
ADDED
package/dist/fetch.d.ts
ADDED
package/dist/fetch.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRuntime } from '@mokup/runtime';
|
|
2
|
+
import { t as toRuntimeOptions, d as toRuntimeRequestFromFetch, e as toArrayBuffer } from './shared/server.tZ4R8aB2.mjs';
|
|
3
|
+
|
|
4
|
+
function createFetchHandler(options) {
|
|
5
|
+
const runtime = createRuntime(toRuntimeOptions(options));
|
|
6
|
+
const onNotFound = options.onNotFound ?? "next";
|
|
7
|
+
return async (request) => {
|
|
8
|
+
const runtimeRequest = await toRuntimeRequestFromFetch(request);
|
|
9
|
+
const result = await runtime.handle(runtimeRequest);
|
|
10
|
+
if (!result) {
|
|
11
|
+
if (onNotFound === "response") {
|
|
12
|
+
return new Response(null, { status: 404 });
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const responseBody = result.body === null ? null : typeof result.body === "string" ? result.body : toArrayBuffer(result.body);
|
|
17
|
+
return new Response(responseBody, {
|
|
18
|
+
status: result.status,
|
|
19
|
+
headers: result.headers
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { createFetchHandler };
|
package/dist/hono.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fetch = require('./fetch.cjs');
|
|
4
|
+
require('@mokup/runtime');
|
|
5
|
+
require('./shared/server.3GcmR3Ev.cjs');
|
|
6
|
+
|
|
7
|
+
function createHonoMiddleware(options) {
|
|
8
|
+
const handler = fetch.createFetchHandler(options);
|
|
9
|
+
const middleware = async (context, next) => {
|
|
10
|
+
const response = await handler(context.req.raw);
|
|
11
|
+
if (!response) {
|
|
12
|
+
return await next();
|
|
13
|
+
}
|
|
14
|
+
return response;
|
|
15
|
+
};
|
|
16
|
+
const route = {
|
|
17
|
+
basePath: "",
|
|
18
|
+
path: "*",
|
|
19
|
+
method: "ALL",
|
|
20
|
+
handler: middleware
|
|
21
|
+
};
|
|
22
|
+
const bridge = middleware;
|
|
23
|
+
bridge.routes = [route];
|
|
24
|
+
return bridge;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.createHonoMiddleware = createHonoMiddleware;
|
package/dist/hono.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { S as ServerOptions } from './shared/server.B82hrXoo.cjs';
|
|
2
|
+
import '@mokup/runtime';
|
|
3
|
+
|
|
4
|
+
interface HonoContextLike {
|
|
5
|
+
req: {
|
|
6
|
+
raw: Request;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
type HonoNext = () => Promise<Response | void>;
|
|
10
|
+
type HonoMiddleware = (context: HonoContextLike, next: HonoNext) => Promise<Response | void>;
|
|
11
|
+
interface HonoRouteLike {
|
|
12
|
+
basePath: string;
|
|
13
|
+
path: string;
|
|
14
|
+
method: string;
|
|
15
|
+
handler: HonoMiddleware;
|
|
16
|
+
}
|
|
17
|
+
declare function createHonoMiddleware(options: ServerOptions): HonoMiddleware & {
|
|
18
|
+
routes: HonoRouteLike[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { createHonoMiddleware };
|
package/dist/hono.d.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { S as ServerOptions } from './shared/server.B82hrXoo.mjs';
|
|
2
|
+
import '@mokup/runtime';
|
|
3
|
+
|
|
4
|
+
interface HonoContextLike {
|
|
5
|
+
req: {
|
|
6
|
+
raw: Request;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
type HonoNext = () => Promise<Response | void>;
|
|
10
|
+
type HonoMiddleware = (context: HonoContextLike, next: HonoNext) => Promise<Response | void>;
|
|
11
|
+
interface HonoRouteLike {
|
|
12
|
+
basePath: string;
|
|
13
|
+
path: string;
|
|
14
|
+
method: string;
|
|
15
|
+
handler: HonoMiddleware;
|
|
16
|
+
}
|
|
17
|
+
declare function createHonoMiddleware(options: ServerOptions): HonoMiddleware & {
|
|
18
|
+
routes: HonoRouteLike[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { createHonoMiddleware };
|
package/dist/hono.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { S as ServerOptions } from './shared/server.B82hrXoo.js';
|
|
2
|
+
import '@mokup/runtime';
|
|
3
|
+
|
|
4
|
+
interface HonoContextLike {
|
|
5
|
+
req: {
|
|
6
|
+
raw: Request;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
type HonoNext = () => Promise<Response | void>;
|
|
10
|
+
type HonoMiddleware = (context: HonoContextLike, next: HonoNext) => Promise<Response | void>;
|
|
11
|
+
interface HonoRouteLike {
|
|
12
|
+
basePath: string;
|
|
13
|
+
path: string;
|
|
14
|
+
method: string;
|
|
15
|
+
handler: HonoMiddleware;
|
|
16
|
+
}
|
|
17
|
+
declare function createHonoMiddleware(options: ServerOptions): HonoMiddleware & {
|
|
18
|
+
routes: HonoRouteLike[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { createHonoMiddleware };
|
package/dist/hono.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createFetchHandler } from './fetch.mjs';
|
|
2
|
+
import '@mokup/runtime';
|
|
3
|
+
import './shared/server.tZ4R8aB2.mjs';
|
|
4
|
+
|
|
5
|
+
function createHonoMiddleware(options) {
|
|
6
|
+
const handler = createFetchHandler(options);
|
|
7
|
+
const middleware = async (context, next) => {
|
|
8
|
+
const response = await handler(context.req.raw);
|
|
9
|
+
if (!response) {
|
|
10
|
+
return await next();
|
|
11
|
+
}
|
|
12
|
+
return response;
|
|
13
|
+
};
|
|
14
|
+
const route = {
|
|
15
|
+
basePath: "",
|
|
16
|
+
path: "*",
|
|
17
|
+
method: "ALL",
|
|
18
|
+
handler: middleware
|
|
19
|
+
};
|
|
20
|
+
const bridge = middleware;
|
|
21
|
+
bridge.routes = [route];
|
|
22
|
+
return bridge;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { createHonoMiddleware };
|