@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.
Files changed (73) hide show
  1. package/dist/connect.cjs +5 -5
  2. package/dist/connect.d.cts +13 -2
  3. package/dist/connect.d.mts +13 -2
  4. package/dist/connect.d.ts +13 -2
  5. package/dist/connect.mjs +1 -1
  6. package/dist/express.cjs +1 -1
  7. package/dist/express.d.cts +13 -2
  8. package/dist/express.d.mts +13 -2
  9. package/dist/express.d.ts +13 -2
  10. package/dist/express.mjs +1 -1
  11. package/dist/fastify.cjs +5 -5
  12. package/dist/fastify.d.cts +13 -2
  13. package/dist/fastify.d.mts +13 -2
  14. package/dist/fastify.d.ts +13 -2
  15. package/dist/fastify.mjs +1 -1
  16. package/dist/fetch-server.cjs +599 -447
  17. package/dist/fetch-server.d.cts +81 -27
  18. package/dist/fetch-server.d.mts +81 -27
  19. package/dist/fetch-server.d.ts +81 -27
  20. package/dist/fetch-server.mjs +601 -449
  21. package/dist/fetch.cjs +5 -5
  22. package/dist/fetch.d.cts +12 -1
  23. package/dist/fetch.d.mts +12 -1
  24. package/dist/fetch.d.ts +12 -1
  25. package/dist/fetch.mjs +1 -1
  26. package/dist/hono.cjs +1 -1
  27. package/dist/hono.d.cts +12 -1
  28. package/dist/hono.d.mts +12 -1
  29. package/dist/hono.d.ts +12 -1
  30. package/dist/hono.mjs +1 -1
  31. package/dist/index.cjs +34 -2
  32. package/dist/index.d.cts +40 -1
  33. package/dist/index.d.mts +40 -1
  34. package/dist/index.d.ts +40 -1
  35. package/dist/index.mjs +36 -1
  36. package/dist/koa.cjs +5 -5
  37. package/dist/koa.d.cts +13 -2
  38. package/dist/koa.d.mts +13 -2
  39. package/dist/koa.d.ts +13 -2
  40. package/dist/koa.mjs +1 -1
  41. package/dist/node.cjs +3 -3
  42. package/dist/node.d.cts +3 -2
  43. package/dist/node.d.mts +3 -2
  44. package/dist/node.d.ts +3 -2
  45. package/dist/node.mjs +3 -3
  46. package/dist/shared/server.CyVIKPsp.d.cts +214 -0
  47. package/dist/shared/server.CyVIKPsp.d.mts +214 -0
  48. package/dist/shared/server.CyVIKPsp.d.ts +214 -0
  49. package/dist/shared/server.D0gAciOr.d.cts +46 -0
  50. package/dist/shared/server.D0gAciOr.d.mts +46 -0
  51. package/dist/shared/server.D0gAciOr.d.ts +46 -0
  52. package/dist/shared/server.DkerfsA-.d.cts +73 -0
  53. package/dist/shared/server.DkerfsA-.d.mts +73 -0
  54. package/dist/shared/server.DkerfsA-.d.ts +73 -0
  55. package/dist/shared/{server.tZ4R8aB2.mjs → server.LbftO9Jh.mjs} +57 -54
  56. package/dist/shared/{server.3GcmR3Ev.cjs → server.aaygIV2Q.cjs} +57 -54
  57. package/dist/worker-node.cjs +1 -1
  58. package/dist/worker-node.d.cts +29 -1
  59. package/dist/worker-node.d.mts +29 -1
  60. package/dist/worker-node.d.ts +29 -1
  61. package/dist/worker-node.mjs +1 -1
  62. package/dist/worker.cjs +1 -1
  63. package/dist/worker.d.cts +23 -1
  64. package/dist/worker.d.mts +23 -1
  65. package/dist/worker.d.ts +23 -1
  66. package/dist/worker.mjs +1 -1
  67. package/package.json +4 -4
  68. package/dist/shared/server.B82hrXoo.d.cts +0 -15
  69. package/dist/shared/server.B82hrXoo.d.mts +0 -15
  70. package/dist/shared/server.B82hrXoo.d.ts +0 -15
  71. package/dist/shared/server.Cb2eiCU2.d.cts +0 -17
  72. package/dist/shared/server.Cb2eiCU2.d.mts +0 -17
  73. 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 internal = require('./shared/server.3GcmR3Ev.cjs');
4
+ const runtime$1 = require('./shared/server.aaygIV2Q.cjs');
5
5
 
6
6
  function createConnectMiddleware(options) {
7
- const runtime$1 = runtime.createRuntime(internal.toRuntimeOptions(options));
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 internal.toRuntimeRequestFromNode(req);
11
- const result = await runtime$1.handle(runtimeRequest);
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
- internal.applyRuntimeResultToNode(res, result);
21
+ runtime$1.applyRuntimeResultToNode(res, result);
22
22
  };
23
23
  }
24
24
 
@@ -1,8 +1,19 @@
1
- import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.Cb2eiCU2.cjs';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.cjs';
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 };
@@ -1,8 +1,19 @@
1
- import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.Cb2eiCU2.mjs';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.mjs';
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.Cb2eiCU2.js';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.js';
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.tZ4R8aB2.mjs';
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  const connect = require('./connect.cjs');
4
4
  require('@mokup/runtime');
5
- require('./shared/server.3GcmR3Ev.cjs');
5
+ require('./shared/server.aaygIV2Q.cjs');
6
6
 
7
7
  function createExpressMiddleware(options) {
8
8
  return connect.createConnectMiddleware(options);
@@ -1,7 +1,18 @@
1
- import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.Cb2eiCU2.cjs';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.cjs';
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 };
@@ -1,7 +1,18 @@
1
- import { N as NodeRequestLike, a as NodeResponseLike } from './shared/server.Cb2eiCU2.mjs';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.mjs';
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.Cb2eiCU2.js';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.js';
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
@@ -1,6 +1,6 @@
1
1
  import { createConnectMiddleware } from './connect.mjs';
2
2
  import '@mokup/runtime';
3
- import './shared/server.tZ4R8aB2.mjs';
3
+ import './shared/server.LbftO9Jh.mjs';
4
4
 
5
5
  function createExpressMiddleware(options) {
6
6
  return createConnectMiddleware(options);
package/dist/fastify.cjs CHANGED
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  const runtime = require('@mokup/runtime');
4
- const internal = require('./shared/server.3GcmR3Ev.cjs');
4
+ const runtime$1 = require('./shared/server.aaygIV2Q.cjs');
5
5
 
6
6
  function createFastifyPlugin(options) {
7
- const runtime$1 = runtime.createRuntime(internal.toRuntimeOptions(options));
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 internal.toRuntimeRequestFromNode(
11
+ const runtimeRequest = await runtime$1.toRuntimeRequestFromNode(
12
12
  request.raw ?? request,
13
13
  request.body
14
14
  );
15
- const result = await runtime$1.handle(runtimeRequest);
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(internal.toBinaryBody(result.body));
34
+ reply.send(runtime$1.toBinaryBody(result.body));
35
35
  });
36
36
  };
37
37
  }
@@ -1,5 +1,5 @@
1
- import { N as NodeRequestLike } from './shared/server.Cb2eiCU2.cjs';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.cjs';
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 };
@@ -1,5 +1,5 @@
1
- import { N as NodeRequestLike } from './shared/server.Cb2eiCU2.mjs';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.mjs';
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.Cb2eiCU2.js';
2
- import { S as ServerOptions } from './shared/server.B82hrXoo.js';
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.tZ4R8aB2.mjs';
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));