@mokup/server 1.1.2 → 1.1.3
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/connect.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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 createConnectMiddleware(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 (req, res, next) => {
|
|
10
|
-
const runtimeRequest = await
|
|
11
|
-
const result = await runtime$
|
|
10
|
+
const runtimeRequest = await runtime$1.toRuntimeRequestFromNode(req);
|
|
11
|
+
const result = await runtime$2.handle(runtimeRequest);
|
|
12
12
|
if (!result) {
|
|
13
13
|
if (onNotFound === "response") {
|
|
14
14
|
res.statusCode = 404;
|
|
@@ -18,7 +18,7 @@ function createConnectMiddleware(options) {
|
|
|
18
18
|
next();
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
runtime$1.applyRuntimeResultToNode(res, result);
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
package/dist/connect.d.cts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.D0gAciOr.cjs';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.cjs';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
5
|
type NextFunction = (error?: unknown) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Create a Connect-style middleware from server options.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Server options.
|
|
10
|
+
* @returns Connect middleware handler.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { createConnectMiddleware } from '@mokup/server'
|
|
14
|
+
*
|
|
15
|
+
* const middleware = createConnectMiddleware({ manifest: { version: 1, routes: [] } })
|
|
16
|
+
*/
|
|
6
17
|
declare function createConnectMiddleware(options: ServerOptions): (req: NodeRequestLike, res: NodeResponseLike, next: NextFunction) => Promise<void>;
|
|
7
18
|
|
|
8
19
|
export { createConnectMiddleware };
|
package/dist/connect.d.mts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.D0gAciOr.mjs';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.mjs';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
5
|
type NextFunction = (error?: unknown) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Create a Connect-style middleware from server options.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Server options.
|
|
10
|
+
* @returns Connect middleware handler.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { createConnectMiddleware } from '@mokup/server'
|
|
14
|
+
*
|
|
15
|
+
* const middleware = createConnectMiddleware({ manifest: { version: 1, routes: [] } })
|
|
16
|
+
*/
|
|
6
17
|
declare function createConnectMiddleware(options: ServerOptions): (req: NodeRequestLike, res: NodeResponseLike, next: NextFunction) => Promise<void>;
|
|
7
18
|
|
|
8
19
|
export { createConnectMiddleware };
|
package/dist/connect.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.D0gAciOr.js';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.js';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
5
|
type NextFunction = (error?: unknown) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Create a Connect-style middleware from server options.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Server options.
|
|
10
|
+
* @returns Connect middleware handler.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { createConnectMiddleware } from '@mokup/server'
|
|
14
|
+
*
|
|
15
|
+
* const middleware = createConnectMiddleware({ manifest: { version: 1, routes: [] } })
|
|
16
|
+
*/
|
|
6
17
|
declare function createConnectMiddleware(options: ServerOptions): (req: NodeRequestLike, res: NodeResponseLike, next: NextFunction) => Promise<void>;
|
|
7
18
|
|
|
8
19
|
export { createConnectMiddleware };
|
package/dist/connect.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRuntime } from '@mokup/runtime';
|
|
2
|
-
import { t as toRuntimeOptions, a as toRuntimeRequestFromNode, b as applyRuntimeResultToNode } from './shared/server.
|
|
2
|
+
import { t as toRuntimeOptions, a as toRuntimeRequestFromNode, b as applyRuntimeResultToNode } from './shared/server.LbftO9Jh.mjs';
|
|
3
3
|
|
|
4
4
|
function createConnectMiddleware(options) {
|
|
5
5
|
const runtime = createRuntime(toRuntimeOptions(options));
|
package/dist/express.cjs
CHANGED
package/dist/express.d.cts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.D0gAciOr.cjs';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.cjs';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Create an Express middleware from server options.
|
|
7
|
+
*
|
|
8
|
+
* @param options - Server options.
|
|
9
|
+
* @returns Express middleware handler.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { createExpressMiddleware } from '@mokup/server'
|
|
13
|
+
*
|
|
14
|
+
* const middleware = createExpressMiddleware({ manifest: { version: 1, routes: [] } })
|
|
15
|
+
*/
|
|
5
16
|
declare function createExpressMiddleware(options: ServerOptions): (req: NodeRequestLike, res: NodeResponseLike, next: (error?: unknown) => void) => Promise<void>;
|
|
6
17
|
|
|
7
18
|
export { createExpressMiddleware };
|
package/dist/express.d.mts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.D0gAciOr.mjs';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.mjs';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Create an Express middleware from server options.
|
|
7
|
+
*
|
|
8
|
+
* @param options - Server options.
|
|
9
|
+
* @returns Express middleware handler.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { createExpressMiddleware } from '@mokup/server'
|
|
13
|
+
*
|
|
14
|
+
* const middleware = createExpressMiddleware({ manifest: { version: 1, routes: [] } })
|
|
15
|
+
*/
|
|
5
16
|
declare function createExpressMiddleware(options: ServerOptions): (req: NodeRequestLike, res: NodeResponseLike, next: (error?: unknown) => void) => Promise<void>;
|
|
6
17
|
|
|
7
18
|
export { createExpressMiddleware };
|
package/dist/express.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.
|
|
2
|
-
import { S as ServerOptions } from './shared/server.
|
|
1
|
+
import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.D0gAciOr.js';
|
|
2
|
+
import { S as ServerOptions } from './shared/server.DkerfsA-.js';
|
|
3
3
|
import '@mokup/runtime';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Create an Express middleware from server options.
|
|
7
|
+
*
|
|
8
|
+
* @param options - Server options.
|
|
9
|
+
* @returns Express middleware handler.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { createExpressMiddleware } from '@mokup/server'
|
|
13
|
+
*
|
|
14
|
+
* const middleware = createExpressMiddleware({ manifest: { version: 1, routes: [] } })
|
|
15
|
+
*/
|
|
5
16
|
declare function createExpressMiddleware(options: ServerOptions): (req: NodeRequestLike, res: NodeResponseLike, next: (error?: unknown) => void) => Promise<void>;
|
|
6
17
|
|
|
7
18
|
export { createExpressMiddleware };
|
package/dist/express.mjs
CHANGED
package/dist/fastify.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 createFastifyPlugin(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 (instance) => {
|
|
10
10
|
instance.addHook("onRequest", async (request, reply) => {
|
|
11
|
-
const runtimeRequest = await
|
|
11
|
+
const runtimeRequest = await runtime$1.toRuntimeRequestFromNode(
|
|
12
12
|
request.raw ?? request,
|
|
13
13
|
request.body
|
|
14
14
|
);
|
|
15
|
-
const result = await runtime$
|
|
15
|
+
const result = await runtime$2.handle(runtimeRequest);
|
|
16
16
|
if (!result) {
|
|
17
17
|
if (onNotFound === "response") {
|
|
18
18
|
reply.status(404).send();
|
|
@@ -31,7 +31,7 @@ function createFastifyPlugin(options) {
|
|
|
31
31
|
reply.send(result.body);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
reply.send(
|
|
34
|
+
reply.send(runtime$1.toBinaryBody(result.body));
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
}
|
package/dist/fastify.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 FastifyRequestLike extends NodeRequestLike {
|
|
@@ -13,6 +13,17 @@ interface FastifyReplyLike {
|
|
|
13
13
|
interface FastifyInstanceLike {
|
|
14
14
|
addHook: (name: 'onRequest' | 'preHandler', handler: (request: FastifyRequestLike, reply: FastifyReplyLike) => Promise<void> | void) => void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a Fastify plugin from server options.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Server options.
|
|
20
|
+
* @returns Fastify plugin handler.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { createFastifyPlugin } from '@mokup/server'
|
|
24
|
+
*
|
|
25
|
+
* const plugin = createFastifyPlugin({ manifest: { version: 1, routes: [] } })
|
|
26
|
+
*/
|
|
16
27
|
declare function createFastifyPlugin(options: ServerOptions): (instance: FastifyInstanceLike) => Promise<void>;
|
|
17
28
|
|
|
18
29
|
export { createFastifyPlugin };
|
package/dist/fastify.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 FastifyRequestLike extends NodeRequestLike {
|
|
@@ -13,6 +13,17 @@ interface FastifyReplyLike {
|
|
|
13
13
|
interface FastifyInstanceLike {
|
|
14
14
|
addHook: (name: 'onRequest' | 'preHandler', handler: (request: FastifyRequestLike, reply: FastifyReplyLike) => Promise<void> | void) => void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a Fastify plugin from server options.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Server options.
|
|
20
|
+
* @returns Fastify plugin handler.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { createFastifyPlugin } from '@mokup/server'
|
|
24
|
+
*
|
|
25
|
+
* const plugin = createFastifyPlugin({ manifest: { version: 1, routes: [] } })
|
|
26
|
+
*/
|
|
16
27
|
declare function createFastifyPlugin(options: ServerOptions): (instance: FastifyInstanceLike) => Promise<void>;
|
|
17
28
|
|
|
18
29
|
export { createFastifyPlugin };
|
package/dist/fastify.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 FastifyRequestLike extends NodeRequestLike {
|
|
@@ -13,6 +13,17 @@ interface FastifyReplyLike {
|
|
|
13
13
|
interface FastifyInstanceLike {
|
|
14
14
|
addHook: (name: 'onRequest' | 'preHandler', handler: (request: FastifyRequestLike, reply: FastifyReplyLike) => Promise<void> | void) => void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a Fastify plugin from server options.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Server options.
|
|
20
|
+
* @returns Fastify plugin handler.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { createFastifyPlugin } from '@mokup/server'
|
|
24
|
+
*
|
|
25
|
+
* const plugin = createFastifyPlugin({ manifest: { version: 1, routes: [] } })
|
|
26
|
+
*/
|
|
16
27
|
declare function createFastifyPlugin(options: ServerOptions): (instance: FastifyInstanceLike) => Promise<void>;
|
|
17
28
|
|
|
18
29
|
export { createFastifyPlugin };
|
package/dist/fastify.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 createFastifyPlugin(options) {
|
|
5
5
|
const runtime = createRuntime(toRuntimeOptions(options));
|