shokupan 0.2.0 → 0.3.0

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 (58) hide show
  1. package/dist/benchmarking/advanced-cases/elysia.d.ts +1 -0
  2. package/dist/benchmarking/advanced-cases/express.d.ts +1 -0
  3. package/dist/benchmarking/advanced-cases/fastify.d.ts +1 -0
  4. package/dist/benchmarking/advanced-cases/hapi.d.ts +1 -0
  5. package/dist/benchmarking/advanced-cases/hono.d.ts +1 -0
  6. package/dist/benchmarking/advanced-cases/koa.d.ts +1 -0
  7. package/dist/benchmarking/advanced-cases/nest.d.ts +1 -0
  8. package/dist/benchmarking/advanced-cases/shokupan.d.ts +1 -0
  9. package/dist/benchmarking/advanced-data.d.ts +33 -0
  10. package/dist/benchmarking/advanced-runner.d.ts +1 -0
  11. package/dist/benchmarking/advanced-worker.d.ts +0 -0
  12. package/dist/benchmarking/cases/elysia.d.ts +1 -0
  13. package/dist/benchmarking/cases/express.d.ts +1 -0
  14. package/dist/benchmarking/cases/fastify.d.ts +1 -0
  15. package/dist/benchmarking/cases/hapi.d.ts +1 -0
  16. package/dist/benchmarking/cases/hono.d.ts +1 -0
  17. package/dist/benchmarking/cases/koa.d.ts +1 -0
  18. package/dist/benchmarking/cases/nest.d.ts +1 -0
  19. package/dist/benchmarking/cases/shokupan.d.ts +1 -0
  20. package/dist/benchmarking/data.d.ts +15 -0
  21. package/dist/benchmarking/quick_bench.d.ts +1 -0
  22. package/dist/benchmarking/runner.d.ts +1 -0
  23. package/dist/benchmarking/worker.d.ts +0 -0
  24. package/dist/buntest.d.ts +1 -0
  25. package/dist/cli.cjs +1 -1
  26. package/dist/cli.js +1 -1
  27. package/dist/context.d.ts +14 -6
  28. package/dist/decorators.d.ts +47 -0
  29. package/dist/index.cjs +895 -379
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.js +887 -373
  32. package/dist/index.js.map +1 -1
  33. package/dist/{openapi-analyzer-BTExMLX4.js → openapi-analyzer-BtIaHIfe.js} +11 -6
  34. package/dist/openapi-analyzer-BtIaHIfe.js.map +1 -0
  35. package/dist/{openapi-analyzer-BN0wFCML.cjs → openapi-analyzer-D9YB3IkV.cjs} +11 -6
  36. package/dist/openapi-analyzer-D9YB3IkV.cjs.map +1 -0
  37. package/dist/plugins/auth.d.ts +1 -1
  38. package/dist/plugins/debugview/plugin.d.ts +6 -12
  39. package/dist/plugins/failed-request-recorder.d.ts +14 -0
  40. package/dist/plugins/idempotency/plugin.d.ts +14 -0
  41. package/dist/plugins/openapi-validator.d.ts +28 -0
  42. package/dist/plugins/rate-limit.d.ts +3 -1
  43. package/dist/plugins/serve-static.d.ts +2 -3
  44. package/dist/router/trie.d.ts +14 -0
  45. package/dist/router.d.ts +48 -3
  46. package/dist/{server-adapter-CnQFr4P7.js → server-adapter-BWrEJbKL.js} +5 -5
  47. package/dist/server-adapter-BWrEJbKL.js.map +1 -0
  48. package/dist/{server-adapter-BD6oKEto.cjs → server-adapter-fVKP60e0.cjs} +5 -5
  49. package/dist/server-adapter-fVKP60e0.cjs.map +1 -0
  50. package/dist/shokupan.d.ts +14 -3
  51. package/dist/types.d.ts +96 -4
  52. package/dist/util/cpu-monitor.d.ts +11 -0
  53. package/dist/util/stack.d.ts +8 -0
  54. package/package.json +4 -2
  55. package/dist/openapi-analyzer-BN0wFCML.cjs.map +0 -1
  56. package/dist/openapi-analyzer-BTExMLX4.js.map +0 -1
  57. package/dist/server-adapter-BD6oKEto.cjs.map +0 -1
  58. package/dist/server-adapter-CnQFr4P7.js.map +0 -1
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function startAdvanced(port: number, scenario: string): Promise<() => Promise<void>>;
@@ -0,0 +1,33 @@
1
+ export declare const LARGE_JSON: {
2
+ total: number;
3
+ items: any[];
4
+ metadata: {
5
+ generated: string;
6
+ size: string;
7
+ purpose: string;
8
+ };
9
+ };
10
+ export declare const LARGE_REQUEST_BODY: string;
11
+ export declare const LARGE_HEADERS: Record<string, string>;
12
+ /**
13
+ * Calculate MD5 hash of a string
14
+ */
15
+ export declare function md5(input: string): string;
16
+ /**
17
+ * Serialize request data for hashing
18
+ */
19
+ export declare function serializeRequest(url: string, headers: Record<string, string>, body: string): string;
20
+ /**
21
+ * Get the actual byte size of the LARGE_JSON
22
+ */
23
+ export declare function getLargeJSONSize(): number;
24
+ /**
25
+ * Smaller compressible response (100KB) for compression testing
26
+ */
27
+ export declare const COMPRESSIBLE_JSON: {
28
+ data: {
29
+ id: number;
30
+ text: string;
31
+ timestamp: string;
32
+ }[];
33
+ };
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1 @@
1
+ export declare function start(port: number): Promise<() => Promise<void>>;
@@ -0,0 +1,15 @@
1
+ export declare const MEDIUM_JSON: {
2
+ id: number;
3
+ name: string;
4
+ timestamp: string;
5
+ tags: string[];
6
+ nested: {
7
+ layer1: {
8
+ layer2: {
9
+ value: string;
10
+ numbers: number[];
11
+ };
12
+ };
13
+ };
14
+ description: string;
15
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.cjs CHANGED
@@ -4,7 +4,7 @@ const p = require("@clack/prompts");
4
4
  const fs = require("node:fs");
5
5
  const path = require("node:path");
6
6
  const promises = require("node:timers/promises");
7
- const openapiAnalyzer = require("./openapi-analyzer-BN0wFCML.cjs");
7
+ const openapiAnalyzer = require("./openapi-analyzer-D9YB3IkV.cjs");
8
8
  function _interopNamespaceDefault(e) {
9
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
10
  if (e) {
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import * as p from "@clack/prompts";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { setTimeout } from "node:timers/promises";
6
- import { analyzeDirectory } from "./openapi-analyzer-BTExMLX4.js";
6
+ import { analyzeDirectory } from "./openapi-analyzer-BtIaHIfe.js";
7
7
  const templates = {
8
8
  controller: (name) => `import { Controller, Get, Ctx } from 'shokupan';
9
9
  import { ShokupanContext } from 'shokupan';
package/dist/context.d.ts CHANGED
@@ -10,17 +10,27 @@ export interface HandlerStackItem {
10
10
  line: number;
11
11
  stateChanges?: Record<string, any>;
12
12
  }
13
+ export interface DebugCollector {
14
+ trackStep(id: string | undefined, type: string, duration: number, status: 'success' | 'error', error?: any): void;
15
+ trackEdge(fromId: string | undefined, toId: string | undefined): void;
16
+ setNode(id: string): void;
17
+ getCurrentNode(): string | undefined;
18
+ }
13
19
  export declare class ShokupanContext<State extends Record<string, any> = Record<string, any>> {
14
20
  readonly request: ShokupanRequest<any>;
15
- readonly server?: Server;
21
+ readonly server?: Server<any>;
16
22
  readonly app?: Shokupan;
23
+ readonly signal?: AbortSignal;
17
24
  private _url;
18
25
  params: Record<string, string>;
19
26
  state: State;
20
27
  handlerStack: HandlerStackItem[];
21
28
  readonly response: ShokupanResponse;
29
+ _debug?: DebugCollector;
22
30
  _finalResponse?: Response;
23
- constructor(request: ShokupanRequest<any>, server?: Server, state?: State, app?: Shokupan, enableMiddlewareTracking?: boolean);
31
+ _rawBody?: string | ArrayBuffer | Uint8Array;
32
+ constructor(request: ShokupanRequest<any>, server?: Server<any>, state?: State, app?: Shokupan, signal?: AbortSignal, // Optional as it might not be provided in tests or simple creates
33
+ enableMiddlewareTracking?: boolean);
24
34
  get url(): URL;
25
35
  /**
26
36
  * Base request
@@ -37,9 +47,7 @@ export declare class ShokupanContext<State extends Record<string, any> = Record<
37
47
  /**
38
48
  * Request query params
39
49
  */
40
- get query(): {
41
- [k: string]: string;
42
- };
50
+ get query(): Record<string, any>;
43
51
  /**
44
52
  * Client IP address
45
53
  */
@@ -126,7 +134,7 @@ export declare class ShokupanContext<State extends Record<string, any> = Record<
126
134
  /**
127
135
  * Respond with a file
128
136
  */
129
- file(path: string, fileOptions?: BlobPropertyBag, responseOptions?: ResponseInit): Response;
137
+ file(path: string, fileOptions?: BlobPropertyBag, responseOptions?: ResponseInit): Promise<Response>;
130
138
  /**
131
139
  * JSX Rendering Function
132
140
  */
@@ -1,3 +1,4 @@
1
+ import { RateLimitOptions } from './plugins/rate-limit';
1
2
  import { GuardAPISpec, MethodAPISpec, Middleware } from './types';
2
3
  /**
3
4
  * Class Decorator: Defines the base path for a controller.
@@ -7,21 +8,67 @@ export declare function Controller(path?: string): (target: any) => void;
7
8
  * Decorator: Applies middleware to a class or method.
8
9
  */
9
10
  export declare function Use(...middleware: Middleware[]): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void;
11
+ /**
12
+ * Decorator: Binds a parameter to the request body.
13
+ */
10
14
  export declare const Body: (name?: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
15
+ /**
16
+ * Decorator: Binds a parameter to the request parameters.
17
+ */
11
18
  export declare const Param: (name?: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
19
+ /**
20
+ * Decorator: Binds a parameter to the request query string.
21
+ */
12
22
  export declare const Query: (name?: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
23
+ /**
24
+ * Decorator: Binds a parameter to the request headers.
25
+ */
13
26
  export declare const Headers: (name?: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
27
+ /**
28
+ * Decorator: Binds a parameter to the request object.
29
+ */
14
30
  export declare const Req: (name?: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
31
+ /**
32
+ * Decorator: Binds a parameter to the request context.
33
+ */
15
34
  export declare const Ctx: (name?: string) => (target: any, propertyKey: string, parameterIndex: number) => void;
16
35
  /**
17
36
  * Decorator: Overrides the OpenAPI specification for a route.
18
37
  */
19
38
  export declare function Spec(spec: MethodAPISpec | GuardAPISpec): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
39
+ /**
40
+ * Decorator: Binds a method to the GET HTTP verb.
41
+ */
20
42
  export declare const Get: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
43
+ /**
44
+ * Decorator: Binds a method to the POST HTTP verb.
45
+ */
21
46
  export declare const Post: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
47
+ /**
48
+ * Decorator: Binds a method to the PUT HTTP verb.
49
+ */
22
50
  export declare const Put: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
51
+ /**
52
+ * Decorator: Binds a method to the DELETE HTTP verb.
53
+ */
23
54
  export declare const Delete: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
55
+ /**
56
+ * Decorator: Binds a method to the PATCH HTTP verb.
57
+ */
24
58
  export declare const Patch: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
59
+ /**
60
+ * Decorator: Binds a method to the OPTIONS HTTP verb.
61
+ */
25
62
  export declare const Options: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
63
+ /**
64
+ * Decorator: Binds a method to the HEAD HTTP verb.
65
+ */
26
66
  export declare const Head: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
67
+ /**
68
+ * Decorator: Binds a method to ANY HTTP verb.
69
+ */
27
70
  export declare const All: (path?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
71
+ /**
72
+ * Decorator: Applies a rate limit to a class or method.
73
+ */
74
+ export declare function RateLimit(options: RateLimitOptions): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void;