@mokup/server 1.1.2 → 1.1.4
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/dist/connect.cjs +5 -5
- package/dist/connect.d.cts +13 -2
- package/dist/connect.d.mts +13 -2
- package/dist/connect.d.ts +13 -2
- package/dist/connect.mjs +1 -1
- package/dist/express.cjs +1 -1
- package/dist/express.d.cts +13 -2
- package/dist/express.d.mts +13 -2
- package/dist/express.d.ts +13 -2
- package/dist/express.mjs +1 -1
- package/dist/fastify.cjs +5 -5
- package/dist/fastify.d.cts +13 -2
- package/dist/fastify.d.mts +13 -2
- package/dist/fastify.d.ts +13 -2
- package/dist/fastify.mjs +1 -1
- package/dist/fetch-server.cjs +599 -447
- package/dist/fetch-server.d.cts +81 -27
- package/dist/fetch-server.d.mts +81 -27
- package/dist/fetch-server.d.ts +81 -27
- package/dist/fetch-server.mjs +601 -449
- package/dist/fetch.cjs +5 -5
- package/dist/fetch.d.cts +12 -1
- package/dist/fetch.d.mts +12 -1
- package/dist/fetch.d.ts +12 -1
- package/dist/fetch.mjs +1 -1
- package/dist/hono.cjs +1 -1
- package/dist/hono.d.cts +12 -1
- package/dist/hono.d.mts +12 -1
- package/dist/hono.d.ts +12 -1
- package/dist/hono.mjs +1 -1
- package/dist/index.cjs +34 -2
- package/dist/index.d.cts +40 -1
- package/dist/index.d.mts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.mjs +36 -1
- package/dist/koa.cjs +5 -5
- package/dist/koa.d.cts +13 -2
- package/dist/koa.d.mts +13 -2
- package/dist/koa.d.ts +13 -2
- package/dist/koa.mjs +1 -1
- package/dist/node.cjs +3 -3
- package/dist/node.d.cts +3 -2
- package/dist/node.d.mts +3 -2
- package/dist/node.d.ts +3 -2
- package/dist/node.mjs +3 -3
- package/dist/shared/server.CyVIKPsp.d.cts +214 -0
- package/dist/shared/server.CyVIKPsp.d.mts +214 -0
- package/dist/shared/server.CyVIKPsp.d.ts +214 -0
- package/dist/shared/server.D0gAciOr.d.cts +46 -0
- package/dist/shared/server.D0gAciOr.d.mts +46 -0
- package/dist/shared/server.D0gAciOr.d.ts +46 -0
- package/dist/shared/server.DkerfsA-.d.cts +73 -0
- package/dist/shared/server.DkerfsA-.d.mts +73 -0
- package/dist/shared/server.DkerfsA-.d.ts +73 -0
- package/dist/shared/{server.tZ4R8aB2.mjs → server.LbftO9Jh.mjs} +57 -54
- package/dist/shared/{server.3GcmR3Ev.cjs → server.aaygIV2Q.cjs} +57 -54
- package/dist/worker-node.cjs +1 -1
- package/dist/worker-node.d.cts +29 -1
- package/dist/worker-node.d.mts +29 -1
- package/dist/worker-node.d.ts +29 -1
- package/dist/worker-node.mjs +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +23 -1
- package/dist/worker.d.mts +23 -1
- package/dist/worker.d.ts +23 -1
- package/dist/worker.mjs +1 -1
- package/package.json +4 -4
- package/dist/shared/server.B82hrXoo.d.cts +0 -15
- package/dist/shared/server.B82hrXoo.d.mts +0 -15
- package/dist/shared/server.B82hrXoo.d.ts +0 -15
- package/dist/shared/server.Cb2eiCU2.d.cts +0 -17
- package/dist/shared/server.Cb2eiCU2.d.mts +0 -17
- package/dist/shared/server.Cb2eiCU2.d.ts +0 -17
package/dist/fetch.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const runtime = require('@mokup/runtime');
|
|
4
|
-
const
|
|
4
|
+
const runtime$1 = require('./shared/server.aaygIV2Q.cjs');
|
|
5
5
|
|
|
6
6
|
function createFetchHandler(options) {
|
|
7
|
-
const runtime$
|
|
7
|
+
const runtime$2 = runtime.createRuntime(runtime$1.toRuntimeOptions(options));
|
|
8
8
|
const onNotFound = options.onNotFound ?? "next";
|
|
9
9
|
return async (request) => {
|
|
10
|
-
const runtimeRequest = await
|
|
11
|
-
const result = await runtime$
|
|
10
|
+
const runtimeRequest = await runtime$1.toRuntimeRequestFromFetch(request);
|
|
11
|
+
const result = await runtime$2.handle(runtimeRequest);
|
|
12
12
|
if (!result) {
|
|
13
13
|
if (onNotFound === "response") {
|
|
14
14
|
return new Response(null, { status: 404 });
|
|
15
15
|
}
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
const responseBody = result.body === null ? null : typeof result.body === "string" ? result.body :
|
|
18
|
+
const responseBody = result.body === null ? null : typeof result.body === "string" ? result.body : runtime$1.toArrayBuffer(result.body);
|
|
19
19
|
return new Response(responseBody, {
|
|
20
20
|
status: result.status,
|
|
21
21
|
headers: result.headers
|
package/dist/fetch.d.cts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { S as ServerOptions, F as FetchHandler } from './shared/server.
|
|
1
|
+
import { S as ServerOptions, F as FetchHandler } from './shared/server.DkerfsA-.cjs';
|
|
2
2
|
import '@mokup/runtime';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Create a fetch handler that executes mokup routes.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Server options.
|
|
8
|
+
* @returns Fetch handler for use in adapters.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { createFetchHandler } from '@mokup/server/fetch'
|
|
12
|
+
*
|
|
13
|
+
* const handler = createFetchHandler({ manifest: { version: 1, routes: [] } })
|
|
14
|
+
*/
|
|
4
15
|
declare function createFetchHandler(options: ServerOptions): FetchHandler;
|
|
5
16
|
|
|
6
17
|
export { createFetchHandler };
|
package/dist/fetch.d.mts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { S as ServerOptions, F as FetchHandler } from './shared/server.
|
|
1
|
+
import { S as ServerOptions, F as FetchHandler } from './shared/server.DkerfsA-.mjs';
|
|
2
2
|
import '@mokup/runtime';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Create a fetch handler that executes mokup routes.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Server options.
|
|
8
|
+
* @returns Fetch handler for use in adapters.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { createFetchHandler } from '@mokup/server/fetch'
|
|
12
|
+
*
|
|
13
|
+
* const handler = createFetchHandler({ manifest: { version: 1, routes: [] } })
|
|
14
|
+
*/
|
|
4
15
|
declare function createFetchHandler(options: ServerOptions): FetchHandler;
|
|
5
16
|
|
|
6
17
|
export { createFetchHandler };
|
package/dist/fetch.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { S as ServerOptions, F as FetchHandler } from './shared/server.
|
|
1
|
+
import { S as ServerOptions, F as FetchHandler } from './shared/server.DkerfsA-.js';
|
|
2
2
|
import '@mokup/runtime';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Create a fetch handler that executes mokup routes.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Server options.
|
|
8
|
+
* @returns Fetch handler for use in adapters.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { createFetchHandler } from '@mokup/server/fetch'
|
|
12
|
+
*
|
|
13
|
+
* const handler = createFetchHandler({ manifest: { version: 1, routes: [] } })
|
|
14
|
+
*/
|
|
4
15
|
declare function createFetchHandler(options: ServerOptions): FetchHandler;
|
|
5
16
|
|
|
6
17
|
export { createFetchHandler };
|
package/dist/fetch.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRuntime } from '@mokup/runtime';
|
|
2
|
-
import { t as toRuntimeOptions, d as toRuntimeRequestFromFetch, e as toArrayBuffer } from './shared/server.
|
|
2
|
+
import { t as toRuntimeOptions, d as toRuntimeRequestFromFetch, e as toArrayBuffer } from './shared/server.LbftO9Jh.mjs';
|
|
3
3
|
|
|
4
4
|
function createFetchHandler(options) {
|
|
5
5
|
const runtime = createRuntime(toRuntimeOptions(options));
|
package/dist/hono.cjs
CHANGED
package/dist/hono.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.cjs';
|
|
2
2
|
import '@mokup/runtime';
|
|
3
3
|
|
|
4
4
|
interface HonoContextLike {
|
|
@@ -14,6 +14,17 @@ interface HonoRouteLike {
|
|
|
14
14
|
method: string;
|
|
15
15
|
handler: HonoMiddleware;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a Hono middleware from server options.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Server options.
|
|
21
|
+
* @returns Hono middleware handler.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { createHonoMiddleware } from '@mokup/server'
|
|
25
|
+
*
|
|
26
|
+
* const middleware = createHonoMiddleware({ manifest: { version: 1, routes: [] } })
|
|
27
|
+
*/
|
|
17
28
|
declare function createHonoMiddleware(options: ServerOptions): HonoMiddleware & {
|
|
18
29
|
routes: HonoRouteLike[];
|
|
19
30
|
};
|
package/dist/hono.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.mjs';
|
|
2
2
|
import '@mokup/runtime';
|
|
3
3
|
|
|
4
4
|
interface HonoContextLike {
|
|
@@ -14,6 +14,17 @@ interface HonoRouteLike {
|
|
|
14
14
|
method: string;
|
|
15
15
|
handler: HonoMiddleware;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a Hono middleware from server options.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Server options.
|
|
21
|
+
* @returns Hono middleware handler.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { createHonoMiddleware } from '@mokup/server'
|
|
25
|
+
*
|
|
26
|
+
* const middleware = createHonoMiddleware({ manifest: { version: 1, routes: [] } })
|
|
27
|
+
*/
|
|
17
28
|
declare function createHonoMiddleware(options: ServerOptions): HonoMiddleware & {
|
|
18
29
|
routes: HonoRouteLike[];
|
|
19
30
|
};
|
package/dist/hono.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.js';
|
|
2
2
|
import '@mokup/runtime';
|
|
3
3
|
|
|
4
4
|
interface HonoContextLike {
|
|
@@ -14,6 +14,17 @@ interface HonoRouteLike {
|
|
|
14
14
|
method: string;
|
|
15
15
|
handler: HonoMiddleware;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a Hono middleware from server options.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Server options.
|
|
21
|
+
* @returns Hono middleware handler.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { createHonoMiddleware } from '@mokup/server'
|
|
25
|
+
*
|
|
26
|
+
* const middleware = createHonoMiddleware({ manifest: { version: 1, routes: [] } })
|
|
27
|
+
*/
|
|
17
28
|
declare function createHonoMiddleware(options: ServerOptions): HonoMiddleware & {
|
|
18
29
|
routes: HonoRouteLike[];
|
|
19
30
|
};
|
package/dist/hono.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3,9 +3,41 @@
|
|
|
3
3
|
const fetch = require('./fetch.cjs');
|
|
4
4
|
const worker = require('./worker.cjs');
|
|
5
5
|
require('@mokup/runtime');
|
|
6
|
-
require('./shared/server.
|
|
7
|
-
|
|
6
|
+
require('./shared/server.aaygIV2Q.cjs');
|
|
8
7
|
|
|
8
|
+
const middlewareSymbol = Symbol.for("mokup.config.middlewares");
|
|
9
|
+
function createRegistry(list) {
|
|
10
|
+
return {
|
|
11
|
+
use: (...handlers) => {
|
|
12
|
+
list.push(...handlers);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function attachMetadata(config, meta) {
|
|
17
|
+
Object.defineProperty(config, middlewareSymbol, {
|
|
18
|
+
value: meta,
|
|
19
|
+
enumerable: false
|
|
20
|
+
});
|
|
21
|
+
return config;
|
|
22
|
+
}
|
|
23
|
+
function defineConfig(input) {
|
|
24
|
+
if (typeof input === "function") {
|
|
25
|
+
const pre = [];
|
|
26
|
+
const normal = [];
|
|
27
|
+
const post = [];
|
|
28
|
+
const context = {
|
|
29
|
+
pre: createRegistry(pre),
|
|
30
|
+
normal: createRegistry(normal),
|
|
31
|
+
post: createRegistry(post)
|
|
32
|
+
};
|
|
33
|
+
const result = input(context);
|
|
34
|
+
const config2 = result && typeof result === "object" ? result : {};
|
|
35
|
+
return attachMetadata(config2, { pre, normal, post });
|
|
36
|
+
}
|
|
37
|
+
const config = input && typeof input === "object" ? input : {};
|
|
38
|
+
return attachMetadata(config, { pre: [], normal: [], post: [] });
|
|
39
|
+
}
|
|
9
40
|
|
|
10
41
|
exports.createFetchHandler = fetch.createFetchHandler;
|
|
11
42
|
exports.createMokupWorker = worker.createMokupWorker;
|
|
43
|
+
exports.defineConfig = defineConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
+
import { R as RouteDirectoryConfig, M as MiddlewareRegistry } from './shared/server.CyVIKPsp.cjs';
|
|
2
|
+
export { a as MiddlewarePosition, b as ResolvedMiddleware, c as RouteRule } from './shared/server.CyVIKPsp.cjs';
|
|
1
3
|
export { createFetchHandler } from './fetch.cjs';
|
|
2
|
-
export { F as FetchHandler, S as ServerOptions, W as WorkerBundle, a as WorkerInput } from './shared/server.
|
|
4
|
+
export { F as FetchHandler, S as ServerOptions, W as WorkerBundle, a as WorkerInput } from './shared/server.DkerfsA-.cjs';
|
|
3
5
|
export { createMokupWorker } from './worker.cjs';
|
|
4
6
|
export { Manifest, ManifestRoute, ModuleMap, RuntimeOptions } from '@mokup/runtime';
|
|
7
|
+
export { MiddlewareHandler } from '@mokup/shared/hono';
|
|
8
|
+
|
|
9
|
+
type DefineConfigFactory = (context: {
|
|
10
|
+
pre: MiddlewareRegistry;
|
|
11
|
+
normal: MiddlewareRegistry;
|
|
12
|
+
post: MiddlewareRegistry;
|
|
13
|
+
}) => RouteDirectoryConfig | void;
|
|
14
|
+
/**
|
|
15
|
+
* Define a directory config with Hono-style middleware registration.
|
|
16
|
+
*
|
|
17
|
+
* @param input - Config object or factory callback.
|
|
18
|
+
* @returns Route directory config with middleware metadata.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import { defineConfig } from '@mokup/server'
|
|
22
|
+
*
|
|
23
|
+
* export default defineConfig(({ pre, normal, post }) => {
|
|
24
|
+
* pre.use(async (c, next) => {
|
|
25
|
+
* c.header('x-before', '1')
|
|
26
|
+
* await next()
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* normal.use(async (_c, next) => {
|
|
30
|
+
* await next()
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* post.use(async (c, next) => {
|
|
34
|
+
* await next()
|
|
35
|
+
* c.header('x-after', '1')
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* return { delay: 120 }
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
|
|
42
|
+
|
|
43
|
+
export { MiddlewareRegistry, RouteDirectoryConfig, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
+
import { R as RouteDirectoryConfig, M as MiddlewareRegistry } from './shared/server.CyVIKPsp.mjs';
|
|
2
|
+
export { a as MiddlewarePosition, b as ResolvedMiddleware, c as RouteRule } from './shared/server.CyVIKPsp.mjs';
|
|
1
3
|
export { createFetchHandler } from './fetch.mjs';
|
|
2
|
-
export { F as FetchHandler, S as ServerOptions, W as WorkerBundle, a as WorkerInput } from './shared/server.
|
|
4
|
+
export { F as FetchHandler, S as ServerOptions, W as WorkerBundle, a as WorkerInput } from './shared/server.DkerfsA-.mjs';
|
|
3
5
|
export { createMokupWorker } from './worker.mjs';
|
|
4
6
|
export { Manifest, ManifestRoute, ModuleMap, RuntimeOptions } from '@mokup/runtime';
|
|
7
|
+
export { MiddlewareHandler } from '@mokup/shared/hono';
|
|
8
|
+
|
|
9
|
+
type DefineConfigFactory = (context: {
|
|
10
|
+
pre: MiddlewareRegistry;
|
|
11
|
+
normal: MiddlewareRegistry;
|
|
12
|
+
post: MiddlewareRegistry;
|
|
13
|
+
}) => RouteDirectoryConfig | void;
|
|
14
|
+
/**
|
|
15
|
+
* Define a directory config with Hono-style middleware registration.
|
|
16
|
+
*
|
|
17
|
+
* @param input - Config object or factory callback.
|
|
18
|
+
* @returns Route directory config with middleware metadata.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import { defineConfig } from '@mokup/server'
|
|
22
|
+
*
|
|
23
|
+
* export default defineConfig(({ pre, normal, post }) => {
|
|
24
|
+
* pre.use(async (c, next) => {
|
|
25
|
+
* c.header('x-before', '1')
|
|
26
|
+
* await next()
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* normal.use(async (_c, next) => {
|
|
30
|
+
* await next()
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* post.use(async (c, next) => {
|
|
34
|
+
* await next()
|
|
35
|
+
* c.header('x-after', '1')
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* return { delay: 120 }
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
|
|
42
|
+
|
|
43
|
+
export { MiddlewareRegistry, RouteDirectoryConfig, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
+
import { R as RouteDirectoryConfig, M as MiddlewareRegistry } from './shared/server.CyVIKPsp.js';
|
|
2
|
+
export { a as MiddlewarePosition, b as ResolvedMiddleware, c as RouteRule } from './shared/server.CyVIKPsp.js';
|
|
1
3
|
export { createFetchHandler } from './fetch.js';
|
|
2
|
-
export { F as FetchHandler, S as ServerOptions, W as WorkerBundle, a as WorkerInput } from './shared/server.
|
|
4
|
+
export { F as FetchHandler, S as ServerOptions, W as WorkerBundle, a as WorkerInput } from './shared/server.DkerfsA-.js';
|
|
3
5
|
export { createMokupWorker } from './worker.js';
|
|
4
6
|
export { Manifest, ManifestRoute, ModuleMap, RuntimeOptions } from '@mokup/runtime';
|
|
7
|
+
export { MiddlewareHandler } from '@mokup/shared/hono';
|
|
8
|
+
|
|
9
|
+
type DefineConfigFactory = (context: {
|
|
10
|
+
pre: MiddlewareRegistry;
|
|
11
|
+
normal: MiddlewareRegistry;
|
|
12
|
+
post: MiddlewareRegistry;
|
|
13
|
+
}) => RouteDirectoryConfig | void;
|
|
14
|
+
/**
|
|
15
|
+
* Define a directory config with Hono-style middleware registration.
|
|
16
|
+
*
|
|
17
|
+
* @param input - Config object or factory callback.
|
|
18
|
+
* @returns Route directory config with middleware metadata.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import { defineConfig } from '@mokup/server'
|
|
22
|
+
*
|
|
23
|
+
* export default defineConfig(({ pre, normal, post }) => {
|
|
24
|
+
* pre.use(async (c, next) => {
|
|
25
|
+
* c.header('x-before', '1')
|
|
26
|
+
* await next()
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* normal.use(async (_c, next) => {
|
|
30
|
+
* await next()
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* post.use(async (c, next) => {
|
|
34
|
+
* await next()
|
|
35
|
+
* c.header('x-after', '1')
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* return { delay: 120 }
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
declare function defineConfig(input: RouteDirectoryConfig | DefineConfigFactory): RouteDirectoryConfig;
|
|
42
|
+
|
|
43
|
+
export { MiddlewareRegistry, RouteDirectoryConfig, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
export { createFetchHandler } from './fetch.mjs';
|
|
2
2
|
export { createMokupWorker } from './worker.mjs';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
|
-
import './shared/server.
|
|
4
|
+
import './shared/server.LbftO9Jh.mjs';
|
|
5
|
+
|
|
6
|
+
const middlewareSymbol = Symbol.for("mokup.config.middlewares");
|
|
7
|
+
function createRegistry(list) {
|
|
8
|
+
return {
|
|
9
|
+
use: (...handlers) => {
|
|
10
|
+
list.push(...handlers);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function attachMetadata(config, meta) {
|
|
15
|
+
Object.defineProperty(config, middlewareSymbol, {
|
|
16
|
+
value: meta,
|
|
17
|
+
enumerable: false
|
|
18
|
+
});
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
function defineConfig(input) {
|
|
22
|
+
if (typeof input === "function") {
|
|
23
|
+
const pre = [];
|
|
24
|
+
const normal = [];
|
|
25
|
+
const post = [];
|
|
26
|
+
const context = {
|
|
27
|
+
pre: createRegistry(pre),
|
|
28
|
+
normal: createRegistry(normal),
|
|
29
|
+
post: createRegistry(post)
|
|
30
|
+
};
|
|
31
|
+
const result = input(context);
|
|
32
|
+
const config2 = result && typeof result === "object" ? result : {};
|
|
33
|
+
return attachMetadata(config2, { pre, normal, post });
|
|
34
|
+
}
|
|
35
|
+
const config = input && typeof input === "object" ? input : {};
|
|
36
|
+
return attachMetadata(config, { pre: [], normal: [], post: [] });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { defineConfig };
|
package/dist/koa.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const runtime = require('@mokup/runtime');
|
|
4
|
-
const
|
|
4
|
+
const runtime$1 = require('./shared/server.aaygIV2Q.cjs');
|
|
5
5
|
|
|
6
6
|
function createKoaMiddleware(options) {
|
|
7
|
-
const runtime$
|
|
7
|
+
const runtime$2 = runtime.createRuntime(runtime$1.toRuntimeOptions(options));
|
|
8
8
|
const onNotFound = options.onNotFound ?? "next";
|
|
9
9
|
return async (ctx, next) => {
|
|
10
|
-
const runtimeRequest = await
|
|
10
|
+
const runtimeRequest = await runtime$1.toRuntimeRequestFromNode(
|
|
11
11
|
ctx.req,
|
|
12
12
|
ctx.request?.body
|
|
13
13
|
);
|
|
14
|
-
const result = await runtime$
|
|
14
|
+
const result = await runtime$2.handle(runtimeRequest);
|
|
15
15
|
if (!result) {
|
|
16
16
|
if (onNotFound === "response") {
|
|
17
17
|
ctx.status = 404;
|
|
@@ -31,7 +31,7 @@ function createKoaMiddleware(options) {
|
|
|
31
31
|
ctx.body = result.body;
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
ctx.body =
|
|
34
|
+
ctx.body = runtime$1.toBinaryBody(result.body);
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
|
package/dist/koa.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NodeRequestLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike } from './shared/server.D0gAciOr.cjs';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.cjs';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
5
|
interface KoaContextLike {
|
|
@@ -13,6 +13,17 @@ interface KoaContextLike {
|
|
|
13
13
|
set: (header: Record<string, string>) => void;
|
|
14
14
|
}
|
|
15
15
|
type KoaNext = () => Promise<unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a Koa middleware from server options.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Server options.
|
|
20
|
+
* @returns Koa middleware handler.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { createKoaMiddleware } from '@mokup/server'
|
|
24
|
+
*
|
|
25
|
+
* const middleware = createKoaMiddleware({ manifest: { version: 1, routes: [] } })
|
|
26
|
+
*/
|
|
16
27
|
declare function createKoaMiddleware(options: ServerOptions): (ctx: KoaContextLike, next: KoaNext) => Promise<void>;
|
|
17
28
|
|
|
18
29
|
export { createKoaMiddleware };
|
package/dist/koa.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NodeRequestLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike } from './shared/server.D0gAciOr.mjs';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.mjs';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
5
|
interface KoaContextLike {
|
|
@@ -13,6 +13,17 @@ interface KoaContextLike {
|
|
|
13
13
|
set: (header: Record<string, string>) => void;
|
|
14
14
|
}
|
|
15
15
|
type KoaNext = () => Promise<unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a Koa middleware from server options.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Server options.
|
|
20
|
+
* @returns Koa middleware handler.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { createKoaMiddleware } from '@mokup/server'
|
|
24
|
+
*
|
|
25
|
+
* const middleware = createKoaMiddleware({ manifest: { version: 1, routes: [] } })
|
|
26
|
+
*/
|
|
16
27
|
declare function createKoaMiddleware(options: ServerOptions): (ctx: KoaContextLike, next: KoaNext) => Promise<void>;
|
|
17
28
|
|
|
18
29
|
export { createKoaMiddleware };
|
package/dist/koa.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NodeRequestLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike } from './shared/server.D0gAciOr.js';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.js';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
5
|
interface KoaContextLike {
|
|
@@ -13,6 +13,17 @@ interface KoaContextLike {
|
|
|
13
13
|
set: (header: Record<string, string>) => void;
|
|
14
14
|
}
|
|
15
15
|
type KoaNext = () => Promise<unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a Koa middleware from server options.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Server options.
|
|
20
|
+
* @returns Koa middleware handler.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { createKoaMiddleware } from '@mokup/server'
|
|
24
|
+
*
|
|
25
|
+
* const middleware = createKoaMiddleware({ manifest: { version: 1, routes: [] } })
|
|
26
|
+
*/
|
|
16
27
|
declare function createKoaMiddleware(options: ServerOptions): (ctx: KoaContextLike, next: KoaNext) => Promise<void>;
|
|
17
28
|
|
|
18
29
|
export { createKoaMiddleware };
|
package/dist/koa.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRuntime } from '@mokup/runtime';
|
|
2
|
-
import { t as toRuntimeOptions, a as toRuntimeRequestFromNode, c as toBinaryBody } from './shared/server.
|
|
2
|
+
import { t as toRuntimeOptions, a as toRuntimeRequestFromNode, c as toBinaryBody } from './shared/server.LbftO9Jh.mjs';
|
|
3
3
|
|
|
4
4
|
function createKoaMiddleware(options) {
|
|
5
5
|
const runtime = createRuntime(toRuntimeOptions(options));
|
package/dist/node.cjs
CHANGED
|
@@ -9,16 +9,16 @@ const koa = require('./koa.cjs');
|
|
|
9
9
|
const workerNode = require('./worker-node.cjs');
|
|
10
10
|
const nodeServer = require('@hono/node-server');
|
|
11
11
|
require('@mokup/runtime');
|
|
12
|
-
require('./shared/server.
|
|
13
|
-
require('node:process');
|
|
14
|
-
require('@mokup/shared/hono');
|
|
12
|
+
require('./shared/server.aaygIV2Q.cjs');
|
|
15
13
|
require('@mokup/shared/pathe');
|
|
16
14
|
require('node:fs');
|
|
17
15
|
require('node:module');
|
|
16
|
+
require('node:process');
|
|
18
17
|
require('node:buffer');
|
|
19
18
|
require('node:url');
|
|
20
19
|
require('@mokup/shared/esbuild');
|
|
21
20
|
require('@mokup/shared/jsonc-parser');
|
|
21
|
+
require('@mokup/shared/hono');
|
|
22
22
|
require('./fetch.cjs');
|
|
23
23
|
|
|
24
24
|
|
package/dist/node.d.cts
CHANGED
|
@@ -6,8 +6,9 @@ export { createHonoMiddleware } from './hono.cjs';
|
|
|
6
6
|
export { createKoaMiddleware } from './koa.cjs';
|
|
7
7
|
export { NodeWorkerInput, createMokupWorker } from './worker-node.cjs';
|
|
8
8
|
export { serve } from '@hono/node-server';
|
|
9
|
-
import './shared/server.
|
|
10
|
-
import './shared/server.
|
|
9
|
+
import './shared/server.D0gAciOr.cjs';
|
|
10
|
+
import './shared/server.DkerfsA-.cjs';
|
|
11
11
|
import '@mokup/runtime';
|
|
12
|
+
import './shared/server.CyVIKPsp.cjs';
|
|
12
13
|
import '@mokup/shared/hono';
|
|
13
14
|
import '@mokup/shared';
|
package/dist/node.d.mts
CHANGED
|
@@ -6,8 +6,9 @@ export { createHonoMiddleware } from './hono.mjs';
|
|
|
6
6
|
export { createKoaMiddleware } from './koa.mjs';
|
|
7
7
|
export { NodeWorkerInput, createMokupWorker } from './worker-node.mjs';
|
|
8
8
|
export { serve } from '@hono/node-server';
|
|
9
|
-
import './shared/server.
|
|
10
|
-
import './shared/server.
|
|
9
|
+
import './shared/server.D0gAciOr.mjs';
|
|
10
|
+
import './shared/server.DkerfsA-.mjs';
|
|
11
11
|
import '@mokup/runtime';
|
|
12
|
+
import './shared/server.CyVIKPsp.mjs';
|
|
12
13
|
import '@mokup/shared/hono';
|
|
13
14
|
import '@mokup/shared';
|
package/dist/node.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export { createHonoMiddleware } from './hono.js';
|
|
|
6
6
|
export { createKoaMiddleware } from './koa.js';
|
|
7
7
|
export { NodeWorkerInput, createMokupWorker } from './worker-node.js';
|
|
8
8
|
export { serve } from '@hono/node-server';
|
|
9
|
-
import './shared/server.
|
|
10
|
-
import './shared/server.
|
|
9
|
+
import './shared/server.D0gAciOr.js';
|
|
10
|
+
import './shared/server.DkerfsA-.js';
|
|
11
11
|
import '@mokup/runtime';
|
|
12
|
+
import './shared/server.CyVIKPsp.js';
|
|
12
13
|
import '@mokup/shared/hono';
|
|
13
14
|
import '@mokup/shared';
|
package/dist/node.mjs
CHANGED
|
@@ -7,14 +7,14 @@ export { createKoaMiddleware } from './koa.mjs';
|
|
|
7
7
|
export { createMokupWorker } from './worker-node.mjs';
|
|
8
8
|
export { serve } from '@hono/node-server';
|
|
9
9
|
import '@mokup/runtime';
|
|
10
|
-
import './shared/server.
|
|
11
|
-
import 'node:process';
|
|
12
|
-
import '@mokup/shared/hono';
|
|
10
|
+
import './shared/server.LbftO9Jh.mjs';
|
|
13
11
|
import '@mokup/shared/pathe';
|
|
14
12
|
import 'node:fs';
|
|
15
13
|
import 'node:module';
|
|
14
|
+
import 'node:process';
|
|
16
15
|
import 'node:buffer';
|
|
17
16
|
import 'node:url';
|
|
18
17
|
import '@mokup/shared/esbuild';
|
|
19
18
|
import '@mokup/shared/jsonc-parser';
|
|
19
|
+
import '@mokup/shared/hono';
|
|
20
20
|
import './fetch.mjs';
|