shokupan 0.1.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.
- package/README.md +1 -0
- package/dist/benchmarking/advanced-cases/elysia.d.ts +1 -0
- package/dist/benchmarking/advanced-cases/express.d.ts +1 -0
- package/dist/benchmarking/advanced-cases/fastify.d.ts +1 -0
- package/dist/benchmarking/advanced-cases/hapi.d.ts +1 -0
- package/dist/benchmarking/advanced-cases/hono.d.ts +1 -0
- package/dist/benchmarking/advanced-cases/koa.d.ts +1 -0
- package/dist/benchmarking/advanced-cases/nest.d.ts +1 -0
- package/dist/benchmarking/advanced-cases/shokupan.d.ts +1 -0
- package/dist/benchmarking/advanced-data.d.ts +33 -0
- package/dist/benchmarking/advanced-runner.d.ts +1 -0
- package/dist/benchmarking/advanced-worker.d.ts +0 -0
- package/dist/benchmarking/cases/elysia.d.ts +1 -0
- package/dist/benchmarking/cases/express.d.ts +1 -0
- package/dist/benchmarking/cases/fastify.d.ts +1 -0
- package/dist/benchmarking/cases/hapi.d.ts +1 -0
- package/dist/benchmarking/cases/hono.d.ts +1 -0
- package/dist/benchmarking/cases/koa.d.ts +1 -0
- package/dist/benchmarking/cases/nest.d.ts +1 -0
- package/dist/benchmarking/cases/shokupan.d.ts +1 -0
- package/dist/benchmarking/data.d.ts +15 -0
- package/dist/benchmarking/quick_bench.d.ts +1 -0
- package/dist/benchmarking/runner.d.ts +1 -0
- package/dist/benchmarking/worker.d.ts +0 -0
- package/dist/buntest.d.ts +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/context.d.ts +25 -8
- package/dist/decorators.d.ts +47 -0
- package/dist/index.cjs +1538 -655
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1532 -651
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts +2 -0
- package/dist/{openapi-analyzer-cjdGeQ5a.js → openapi-analyzer-BtIaHIfe.js} +14 -6
- package/dist/openapi-analyzer-BtIaHIfe.js.map +1 -0
- package/dist/{openapi-analyzer-CFqgSLNK.cjs → openapi-analyzer-D9YB3IkV.cjs} +14 -6
- package/dist/openapi-analyzer-D9YB3IkV.cjs.map +1 -0
- package/dist/plugins/auth.d.ts +1 -1
- package/dist/plugins/debugview/plugin.d.ts +28 -0
- package/dist/plugins/failed-request-recorder.d.ts +14 -0
- package/dist/plugins/idempotency/plugin.d.ts +14 -0
- package/dist/plugins/openapi-validator.d.ts +30 -0
- package/dist/plugins/proxy.d.ts +9 -0
- package/dist/plugins/rate-limit.d.ts +3 -1
- package/dist/plugins/serve-static.d.ts +2 -3
- package/dist/response.d.ts +4 -0
- package/dist/router/trie.d.ts +14 -0
- package/dist/router.d.ts +50 -3
- package/dist/server-adapter-BWrEJbKL.js +64 -0
- package/dist/server-adapter-BWrEJbKL.js.map +1 -0
- package/dist/server-adapter-fVKP60e0.cjs +81 -0
- package/dist/server-adapter-fVKP60e0.cjs.map +1 -0
- package/dist/shokupan.d.ts +16 -3
- package/dist/types.d.ts +108 -4
- package/dist/util/cpu-monitor.d.ts +11 -0
- package/dist/util/stack.d.ts +8 -0
- package/package.json +8 -3
- package/dist/openapi-analyzer-CFqgSLNK.cjs.map +0 -1
- package/dist/openapi-analyzer-cjdGeQ5a.js.map +0 -1
package/README.md
CHANGED
|
@@ -1632,6 +1632,7 @@ Container.clear();
|
|
|
1632
1632
|
- ✅ **Deep Introspection** - Type analysis for enhanced OpenAPI generation
|
|
1633
1633
|
- ✅ **Controller Mode** - Option for controller-only mode
|
|
1634
1634
|
- ✅ **Supports Node/Deno** - Shokupan can run on Node.js or Deno
|
|
1635
|
+
- ✅ **OpenAPI Validation** - Built-in [OpenAPI](https://www.openapis.org/) validation
|
|
1635
1636
|
|
|
1636
1637
|
### Future Features
|
|
1637
1638
|
|
|
@@ -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 @@
|
|
|
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-
|
|
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-
|
|
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
|
@@ -4,15 +4,34 @@ import { ShokupanResponse } from './response';
|
|
|
4
4
|
import { Shokupan } from './shokupan';
|
|
5
5
|
import { CookieOptions, JSXRenderer } from './types';
|
|
6
6
|
type HeadersInit = Headers | Record<string, string> | [string, string][];
|
|
7
|
+
export interface HandlerStackItem {
|
|
8
|
+
name: string;
|
|
9
|
+
file: string;
|
|
10
|
+
line: number;
|
|
11
|
+
stateChanges?: Record<string, any>;
|
|
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
|
+
}
|
|
7
19
|
export declare class ShokupanContext<State extends Record<string, any> = Record<string, any>> {
|
|
8
20
|
readonly request: ShokupanRequest<any>;
|
|
9
|
-
readonly server?: Server
|
|
21
|
+
readonly server?: Server<any>;
|
|
10
22
|
readonly app?: Shokupan;
|
|
11
|
-
readonly
|
|
23
|
+
readonly signal?: AbortSignal;
|
|
24
|
+
private _url;
|
|
12
25
|
params: Record<string, string>;
|
|
13
26
|
state: State;
|
|
27
|
+
handlerStack: HandlerStackItem[];
|
|
14
28
|
readonly response: ShokupanResponse;
|
|
15
|
-
|
|
29
|
+
_debug?: DebugCollector;
|
|
30
|
+
_finalResponse?: Response;
|
|
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);
|
|
34
|
+
get url(): URL;
|
|
16
35
|
/**
|
|
17
36
|
* Base request
|
|
18
37
|
*/
|
|
@@ -24,13 +43,11 @@ export declare class ShokupanContext<State extends Record<string, any> = Record<
|
|
|
24
43
|
/**
|
|
25
44
|
* Request path
|
|
26
45
|
*/
|
|
27
|
-
get path():
|
|
46
|
+
get path(): any;
|
|
28
47
|
/**
|
|
29
48
|
* Request query params
|
|
30
49
|
*/
|
|
31
|
-
get query():
|
|
32
|
-
[k: string]: string;
|
|
33
|
-
};
|
|
50
|
+
get query(): Record<string, any>;
|
|
34
51
|
/**
|
|
35
52
|
* Client IP address
|
|
36
53
|
*/
|
|
@@ -117,7 +134,7 @@ export declare class ShokupanContext<State extends Record<string, any> = Record<
|
|
|
117
134
|
/**
|
|
118
135
|
* Respond with a file
|
|
119
136
|
*/
|
|
120
|
-
file(path: string, fileOptions?: BlobPropertyBag, responseOptions?: ResponseInit): Response
|
|
137
|
+
file(path: string, fileOptions?: BlobPropertyBag, responseOptions?: ResponseInit): Promise<Response>;
|
|
121
138
|
/**
|
|
122
139
|
* JSX Rendering Function
|
|
123
140
|
*/
|
package/dist/decorators.d.ts
CHANGED
|
@@ -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;
|