Shokupan
Defined in: src/shokupan.ts:114
Shokupan Application
The main application class for creating a Shokupan web server.
Template
Section titled “Template”The shape of ctx.state for all routes in the application.
Use this to provide type safety for state management across middleware and handlers.
Examples
Section titled “Examples”const app = new Shokupan();app.get('/hello', (ctx) => ctx.json({ message: 'Hello' }));await app.listen(3000);interface AppState { userId: string; tenant: string; requestId: string;}
const app = new Shokupan<AppState>();
// Middleware has typed state accessapp.use((ctx, next) => { ctx.state.userId = 'user-123'; // ✓ Type-safe ctx.state.requestId = crypto.randomUUID(); return next();});
// Handlers have typed state accessapp.get('/profile', (ctx) => { const { userId, tenant } = ctx.state; // ✓ TypeScript knows these exist return ctx.json({ userId, tenant });});import { EmptyState } from 'shokupan';
const app = new Shokupan<EmptyState>();// ctx.state will be an empty object with no propertiesinterface RequestState { userId: string; permissions: string[];}
const app = new Shokupan<RequestState>();
app.get('/users/:userId/posts/:postId', (ctx) => { // Both params and state are fully typed! const { userId, postId } = ctx.params; // ✓ Path params typed const { permissions } = ctx.state; // ✓ State typed return ctx.json({ userId, postId, permissions });});Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”T extends Record<string, any> = GlobalShokupanState
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Shokupan<
T>(applicationConfig):Shokupan<T>
Defined in: src/shokupan.ts:147
Parameters
Section titled “Parameters”applicationConfig
Section titled “applicationConfig”ShokupanConfig = {}
Returns
Section titled “Returns”Shokupan<T>
Overrides
Section titled “Overrides”Properties
Section titled “Properties”[$childControllers]
Section titled “[$childControllers]”[$childControllers]:
ShokupanController[] =[]
Defined in: src/router.ts:101
Inherited from
Section titled “Inherited from”ShokupanRouter.[$childControllers]
[$childRouters]
Section titled “[$childRouters]”[$childRouters]:
ShokupanRouter<T>[] =[]
Defined in: src/router.ts:100
Inherited from
Section titled “Inherited from”ShokupanRouter.[$childRouters]
[$mountPath]
Section titled “[$mountPath]”[$mountPath]:
string="/"
Defined in: src/router.ts:97
Inherited from
Section titled “Inherited from”[$routes]
Section titled “[$routes]”[$routes]:
ShokupanRoute[] =[]
Defined in: src/router.ts:146
Inherited from
Section titled “Inherited from”applicationConfig
Section titled “applicationConfig”
readonlyapplicationConfig:ShokupanConfig={}
Defined in: src/shokupan.ts:115
asyncApiSpec?
Section titled “asyncApiSpec?”
optionalasyncApiSpec:any
Defined in: src/shokupan.ts:117
config?
Section titled “config?”
readonlyoptionalconfig:object
Defined in: src/router.ts:297
autoBackpressureFeedback?
Section titled “autoBackpressureFeedback?”
optionalautoBackpressureFeedback:boolean
Whether to enable automatic backpressure based on system CPU load.
Default
Section titled “Default”falseautoBackpressureLevel?
Section titled “autoBackpressureLevel?”
optionalautoBackpressureLevel:number
The CPU usage percentage threshold (0-100) at which to start rejecting requests.
fileAccessCheck()?
Section titled “fileAccessCheck()?”
optionalfileAccessCheck: (ctx,path) =>boolean
Custom file access check for routes that use ctx.file(). Return true to allow access to the file, false to deny.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
group?
Section titled “group?”
optionalgroup:string
hooks?
Section titled “hooks?”
optionalhooks: {afterValidate?: (ctx,data) =>void|Promise<void>;beforeValidate?: (ctx,data) =>void|Promise<void>;onError?: (ctx,error) =>void|Promise<void>;onReadTimeout?: (ctx) =>void|Promise<void>;onRequestEnd?: (ctx) =>void|Promise<void>;onRequestStart?: (ctx) =>void|Promise<void>;onRequestTimeout?: (ctx) =>void|Promise<void>;onResponseEnd?: (ctx,response) =>void|Promise<void>;onResponseStart?: (ctx,response) =>void|Promise<void>;onStop?: () =>void|Promise<void>;onWriteTimeout?: (ctx) =>void|Promise<void>; } | ({afterValidate?: (ctx,data) =>void|Promise<void>;beforeValidate?: (ctx,data) =>void|Promise<void>;onError?: (ctx,error) =>void|Promise<void>;onReadTimeout?: (ctx) =>void|Promise<void>;onRequestEnd?: (ctx) =>void|Promise<void>;onRequestStart?: (ctx) =>void|Promise<void>;onRequestTimeout?: (ctx) =>void|Promise<void>;onResponseEnd?: (ctx,response) =>void|Promise<void>;onResponseStart?: (ctx,response) =>void|Promise<void>;onStop?: () =>void|Promise<void>;onWriteTimeout?: (ctx) =>void|Promise<void>; } |undefined)[]
Hooks for this route/router.
optionalname:string
openapi?
Section titled “openapi?”
optionalopenapi: {[key:`x-${string}`]:any; [key:string]:any;consumes?: (string|undefined)[];deprecated?:boolean;description?:string;externalDocs?: {[key:string]:any;description?:string;url?:string; };operationId?:string;parameters?: ({[key:`x-${string}`]:any; [key:string]:any;$ref?:string; } | {[key:string]:any;description?:string;in?:ParameterLocation;name?:string;required?:boolean;schema?: {[key:`x-${(...)}`]:any; [key:string]:any;$ref?: … | …; } | {[key:string]:any; [key:`x-${(...)}`]:any;$ref?: … | …;$schema?: … | …;additionalItems?: … | … | … | …;additionalProperties?: … | … | … | …;allOf?: … | …;anyOf?: … | …;default?:any;definitions?: … | …;dependencies?: … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;externalDocs?: … | …;id?: … | …;items?: … | … | … | … | …;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | … | …;uniqueItems?: … | … | …;xml?: … | …; }; } | {[key:string]:any;$ref?:string;allowEmptyValue?:boolean;collectionFormat?:string;default?:any;description?:string;enum?:any[];exclusiveMaximum?:boolean;exclusiveMinimum?:boolean;format?:string;in?:ParameterLocation;items?: {[key:`x-${(...)}`]:any; [key:string]:any;$ref?: … | …; } | {$ref?: … | …;collectionFormat?: … | …;default?:any;enum?: … | …;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;format?: … | …;items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | { type?: string | undefined; format?: string | undefined; items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | … | undefined; … 14 more …; $ref?: string | undefined; } | undefined;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;multipleOf?: … | …;pattern?: … | …;type?: … | …;uniqueItems?: … | … | …; };maximum?:number;maxItems?:number;maxLength?:number;minimum?:number;minItems?:number;minLength?:number;multipleOf?:number;name?:string;pattern?:string;required?:boolean;type?:string;uniqueItems?:boolean; } |undefined)[];produces?: (string|undefined)[];responses?: {[key:string]: {[key:`x-${string}`]:any; [key:string]:any;$ref?:string; } | {[key:`x-${string}`]:any; [key:string]:any;description?:string;examples?: {[key:string]:any; };headers?: {[key:string]: … | …; };schema?: {[key:`x-${(...)}`]:any; [key:string]:any;$ref?: … | …; } | {[key:string]:any; [key:`x-${(...)}`]:any;$ref?: … | …;$schema?: … | …;additionalItems?: … | … | … | …;additionalProperties?: … | … | … | …;allOf?: … | …;anyOf?: … | …;default?:any;definitions?: … | …;dependencies?: … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;externalDocs?: … | …;id?: … | …;items?: … | … | … | … | …;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | … | …;uniqueItems?: … | … | …;xml?: … | …; }; } |undefined;default?: {[key:`x-${string}`]:any; [key:string]:any;$ref?:string; } | {[key:`x-${string}`]:any; [key:string]:any;description?:string;examples?: {[key:string]:any; };headers?: {[key:string]: … | …; };schema?: {[key:`x-${(...)}`]:any; [key:string]:any;$ref?: … | …; } | {[key:string]:any; [key:`x-${(...)}`]:any;$ref?: … | …;$schema?: … | …;additionalItems?: … | … | … | …;additionalProperties?: … | … | … | …;allOf?: … | …;anyOf?: … | …;default?:any;definitions?: … | …;dependencies?: … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;externalDocs?: … | …;id?: … | …;items?: … | … | … | … | …;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | … | …;uniqueItems?: … | … | …;xml?: … | …; }; }; };schemes?: (string|undefined)[];security?: ({[key:string]: (… | …)[] |undefined; } |undefined)[];summary?:string;tags?: (string|undefined)[]; } | {[key:`x-${string}`]:any; [key:string]:any;callbacks?: {[key:string]: {[key:`x-${string}`]:any; [key:string]:any;$ref?:string; } | {[key:string]: {[key:`x-${(...)}`]:any; [key:string]:any;$ref?: … | …;delete?: … | …;description?: … | …;get?: … | …;head?: … | …;options?: … | …;parameters?: … | …;patch?: … | …;post?: … | …;put?: … | …;servers?: … | …;summary?: … | …;trace?: … | …; } |undefined; } |undefined; };deprecated?:boolean;description?:string;externalDocs?: {description?:string;url?:string; };operationId?:string;parameters?: ({[key:`x-${string}`]:any; [key:string]:any;$ref?:string; } | {allowEmptyValue?:boolean;allowReserved?:boolean;content?: {[key:string]: … | …; };deprecated?:boolean;description?:string;example?:any;examples?: {[key:string]: … | … | …; };explode?:boolean;in?:ParameterLocation;name?:string;required?:boolean;schema?: {[key:`x-${(...)}`]:any; [key:string]:any;$ref?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;additionalProperties?: … | … | … | … | … | …;allOf?: … | …;anyOf?: … | …;default?:any;deprecated?: … | … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;externalDocs?: … | …;format?: … | …;items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; type?: “array” | undefined; items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | … | { …; } | undefined; … 33 more …; deprecated?: boolean | undefined; } | {…;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; type?: “array” | undefined; items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | … | { …; } | undefined; … 33 more …; deprecated?: boolean | undefined; } | {…;nullable?: … | … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | …;uniqueItems?: … | … | …;writeOnly?: … | … | …;xml?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;additionalProperties?: … | … | … | … | … | …;allOf?: … | …;anyOf?: … | …;default?:any;deprecated?: … | … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;externalDocs?: … | …;format?: … | …;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; type?: “array” | undefined; items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | … | { …; } | undefined; … 33 more …; deprecated?: boolean | undefined; } | {…;nullable?: … | … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | …;uniqueItems?: … | … | …;writeOnly?: … | … | …;xml?: … | …; };style?:ParameterStyle; } |undefined)[];requestBody?: {[key:`x-${string}`]:any; [key:string]:any;$ref?:string; } | {content?: {[key:string]: {encoding?: … | …;example?:any;examples?: … | …;schema?: … | … | … | …; } |undefined; };description?:string;required?:boolean; };responses?: {[key:string]: {[key:`x-${string}`]:any; [key:string]:any;$ref?:string; } | {[key:`x-${string}`]:any; [key:string]:any;content?: {[key:string]: … | …; };description?:string;headers?: {[key:string]: … | … | …; };links?: {[key:string]: … | … | …; }; } |undefined; };security?: ({[key:string]: (… | …)[] |undefined; } |undefined)[];servers?: ({description?:string;url?:string;variables?: {[key:string]: … | …; }; } |undefined)[];summary?:string;tags?: (string|undefined)[]; } | {[key:string]:any; [key:number]:any;callbacks?: {[key:string]: {[key:string]:any; [key:number]:any;description?:string;summary?:string; } | {[key:string]: {[key:string]:any; [key:number]:any;description?: … | …;summary?: … | …; } | {[key:string]:any; [key:number]:any;delete?: … | …;get?: … | …;head?: … | …;options?: … | …;parameters?: … | …;patch?: … | …;post?: … | …;put?: … | …;servers?: … | …;trace?: … | …; } |undefined; } |undefined; };parameters?: ({allowEmptyValue?:boolean;allowReserved?:boolean;content?: {[key:string]: … | …; };deprecated?:boolean;description?:string;example?:any;examples?: {[key:string]: … | … | …; };explode?:boolean;in?:ParameterLocation;name?:string;required?:boolean;schema?: {[key:`x-${(...)}`]:any; [key:string]:any;$ref?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;additionalProperties?: … | … | … | … | … | …;allOf?: … | …;anyOf?: … | …;default?:any;deprecated?: … | … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;externalDocs?: … | …;format?: … | …;items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; type?: “array” | undefined; items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | … | { …; } | undefined; … 33 more …; deprecated?: boolean | undefined; } | {…;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; type?: “array” | undefined; items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | … | { …; } | undefined; … 33 more …; deprecated?: boolean | undefined; } | {…;nullable?: … | … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | …;uniqueItems?: … | … | …;writeOnly?: … | … | …;xml?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;additionalProperties?: … | … | … | … | … | …;allOf?: … | …;anyOf?: … | …;default?:any;deprecated?: … | … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;exclusiveMaximum?: … | … | …;exclusiveMinimum?: … | … | …;externalDocs?: … | …;format?: … | …;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; type?: “array” | undefined; items?: { [x: `x-${string}`]: any; [x: string]: any; $ref?: string | undefined; } | … | { …; } | undefined; … 33 more …; deprecated?: boolean | undefined; } | {…;nullable?: … | … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | …;uniqueItems?: … | … | …;writeOnly?: … | … | …;xml?: … | …; };style?:ParameterStyle; } | {[key:string]:any; [key:number]:any;description?:string;summary?:string; } |undefined)[];requestBody?: {[key:string]:any; [key:number]:any;description?:string;summary?:string; } | {content?: {[key:string]: {encoding?: … | …;example?:any;examples?: … | …;schema?: … | … | … | … | … | … | …; } |undefined; };description?:string;required?:boolean; };responses?: {[key:string]: {[key:string]:any; [key:number]:any;description?:string;summary?:string; } | {[key:string]:any; [key:number]:any;content?: {[key:string]: … | …; };headers?: {[key:string]: … | … | …; };links?: {[key:string]: … | … | …; }; } |undefined; };servers?: ({description?:string;url?:string;variables?: {[key:string]: … | …; }; } |undefined)[]; } | {[key:string]:any; [key:number]:any;callbacks?: {[key:string]: {[key:string]:any; [key:number]:any;description?:string;summary?:string; } | {[key:string]: {[key:string]:any; [key:number]:any;description?: … | …;summary?: … | …; } | {[key:string]:any; [key:number]:any;additionalOperations?: … | …;delete?: … | …;get?: … | …;head?: … | …;options?: … | …;parameters?: … | …;patch?: … | …;post?: … | …;put?: … | …;query?: … | …;trace?: … | …; } |undefined; } |undefined; };parameters?: ({[key:string]:any; [key:number]:any;description?:string;summary?:string; } | {allowEmptyValue?:boolean;allowReserved?:boolean;content?: {[key:string]: … | …; };deprecated?:boolean;description?:string;example?:any;examples?: {[key:string]: … | … | …; };explode?:boolean;in?:ParameterLocation;name?:string;required?:boolean;schema?: {[key:string]:any; [key:number]:any;description?: … | …;summary?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;valueOf?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;valueOf?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;$schema?: … | …;additionalProperties?: … | … | … | … | … | … | … | … | …;allOf?: … | …;anyOf?: … | …;const?:any;contentMediaType?: … | …;default?:any;deprecated?: … | … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;examples?: … | …;exclusiveMaximum?: … | …;exclusiveMinimum?: … | …;externalDocs?: … | …;format?: … | …;items?: { [x: string]: any; [x: number]: any; summary?: string | undefined; description?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; valueOf?: (() => boolean) | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; valueOf?: (() => boolean) | undefined; } | { …; } | { …; } | { …; } | un…;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: … | … | … | … | … | … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | …;uniqueItems?: … | … | …;writeOnly?: … | … | …;xml?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;$schema?: … | …;additionalProperties?: … | … | … | … | … | … | … | … | …;allOf?: … | …;anyOf?: … | …;const?:any;contentMediaType?: … | …;default?:any;deprecated?: … | … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;examples?: … | …;exclusiveMaximum?: … | …;exclusiveMinimum?: … | …;externalDocs?: … | …;format?: … | …;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: … | … | … | … | … | … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | …;uniqueItems?: … | … | …;writeOnly?: … | … | …;xml?: … | …; } | {[key:`x-${(...)}`]:any; [key:string]:any;$schema?: … | …;additionalProperties?: … | … | … | … | … | … | … | … | …;allOf?: … | …;anyOf?: … | …;const?:any;contentMediaType?: … | …;default?:any;deprecated?: … | … | …;description?: … | …;discriminator?: … | …;enum?: … | …;example?:any;examples?: … | …;exclusiveMaximum?: … | …;exclusiveMinimum?: … | …;externalDocs?: … | …;format?: … | …;items?: { [x: string]: any; [x: number]: any; summary?: string | undefined; description?: string | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; valueOf?: (() => boolean) | undefined; } | { [x: `x-${string}`]: any; [x: string]: any; valueOf?: (() => boolean) | undefined; } | { …; } | { …; } | { …; } | un…;maximum?: … | …;maxItems?: … | …;maxLength?: … | …;maxProperties?: … | …;minimum?: … | …;minItems?: … | …;minLength?: … | …;minProperties?: … | …;multipleOf?: … | …;not?: … | … | … | … | … | … | …;oneOf?: … | …;pattern?: … | …;patternProperties?: … | …;properties?: … | …;readOnly?: … | … | …;required?: … | …;title?: … | …;type?: … | …;uniqueItems?: … | … | …;writeOnly?: … | … | …;xml?: … | …; };style?:ParameterStyle; } |undefined)[];requestBody?: {[key:string]:any; [key:number]:any;description?:string;summary?:string; } | {content?: {[key:string]: {[key:string]:any; [key:number]:any;description?: … | …;summary?: … | …; } | {encoding?: … | …;example?:any;examples?: … | …;itemEncoding?: … | …;itemSchema?: … | … | … | … | … | … | …;prefixEncoding?: … | …;schema?: … | … | … | … | … | … | …; } |undefined; };description?:string;required?:boolean; };responses?: {[key:string]: {[key:string]:any; [key:number]:any;description?:string;summary?:string; } | {[key:string]:any; [key:number]:any;content?: {[key:string]: … | … | …; };headers?: {[key:string]: … | … | …; };links?: {[key:string]: … | … | …; };summary?:string; } |undefined; };servers?: ({description?:string;name?:string;url?:string;variables?: {[key:string]: … | …; }; } |undefined)[]; }
renderer?
Section titled “renderer?”
optionalrenderer:JSXRenderer
Custom renderer for this route.
requestTimeout?
Section titled “requestTimeout?”
optionalrequestTimeout:number
Timeout for this specific route (milliseconds).
Inherited from
Section titled “Inherited from”dbPromise?
Section titled “dbPromise?”
optionaldbPromise:Promise<any>
Defined in: src/shokupan.ts:125
mcpProtocol
Section titled “mcpProtocol”mcpProtocol:
McpProtocol
Defined in: src/router.ts:150
Inherited from
Section titled “Inherited from”metadata?
Section titled “metadata?”
optionalmetadata:RouteMetadata
Defined in: src/router.ts:148
Inherited from
Section titled “Inherited from”middleware
Section titled “middleware”middleware:
Middleware[] =[]
Defined in: src/router.ts:133
Inherited from
Section titled “Inherited from”openApiSpec?
Section titled “openApiSpec?”
optionalopenApiSpec:any
Defined in: src/shokupan.ts:116
requestTimeout?
Section titled “requestTimeout?”
optionalrequestTimeout:number
Defined in: src/router.ts:126
Inherited from
Section titled “Inherited from”responseTransformerRegistry
Section titled “responseTransformerRegistry”responseTransformerRegistry:
ResponseTransformerRegistry
Defined in: src/shokupan.ts:126
server?
Section titled “server?”
optionalserver:Server<any>
Defined in: src/shokupan.ts:122
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get db():
DatastoreAdapter|undefined
Defined in: src/shokupan.ts:139
Returns
Section titled “Returns”DatastoreAdapter | undefined
hasAfterValidateHook
Section titled “hasAfterValidateHook”Get Signature
Section titled “Get Signature”get hasAfterValidateHook():
boolean
Defined in: src/router.ts:124
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasAfterValidateHook
hasBeforeValidateHook
Section titled “hasBeforeValidateHook”Get Signature
Section titled “Get Signature”get hasBeforeValidateHook():
boolean
Defined in: src/router.ts:123
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasBeforeValidateHook
hasOnErrorHook
Section titled “hasOnErrorHook”Get Signature
Section titled “Get Signature”get hasOnErrorHook():
boolean
Defined in: src/router.ts:119
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”hasOnReadTimeoutHook
Section titled “hasOnReadTimeoutHook”Get Signature
Section titled “Get Signature”get hasOnReadTimeoutHook():
boolean
Defined in: src/router.ts:121
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasOnReadTimeoutHook
hasOnRequestEndHook
Section titled “hasOnRequestEndHook”Get Signature
Section titled “Get Signature”get hasOnRequestEndHook():
boolean
Defined in: src/router.ts:117
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasOnRequestEndHook
hasOnRequestStartHook
Section titled “hasOnRequestStartHook”Get Signature
Section titled “Get Signature”get hasOnRequestStartHook():
boolean
Defined in: src/router.ts:116
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasOnRequestStartHook
hasOnRequestTimeoutHook
Section titled “hasOnRequestTimeoutHook”Get Signature
Section titled “Get Signature”get hasOnRequestTimeoutHook():
boolean
Defined in: src/router.ts:120
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasOnRequestTimeoutHook
hasOnResponseEndHook
Section titled “hasOnResponseEndHook”Get Signature
Section titled “Get Signature”get hasOnResponseEndHook():
boolean
Defined in: src/router.ts:115
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasOnResponseEndHook
hasOnResponseStartHook
Section titled “hasOnResponseStartHook”Get Signature
Section titled “Get Signature”get hasOnResponseStartHook():
boolean
Defined in: src/router.ts:118
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasOnResponseStartHook
hasOnStopHook
Section titled “hasOnStopHook”Get Signature
Section titled “Get Signature”get hasOnStopHook():
boolean
Defined in: src/router.ts:114
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”hasOnWriteTimeoutHook
Section titled “hasOnWriteTimeoutHook”Get Signature
Section titled “Get Signature”get hasOnWriteTimeoutHook():
boolean
Defined in: src/router.ts:122
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ShokupanRouter.hasOnWriteTimeoutHook
logger
Section titled “logger”Get Signature
Section titled “Get Signature”get logger():
Logger|undefined
Defined in: src/shokupan.ts:143
Returns
Section titled “Returns”Logger | undefined
Overrides
Section titled “Overrides”registry
Section titled “registry”Get Signature
Section titled “Get Signature”get registry():
object
Defined in: src/router.ts:208
Returns
Section titled “Returns”object
controllers
Section titled “controllers”controllers:
object[]
events
Section titled “events”events:
object[]
metadata
Section titled “metadata”metadata:
RouteMetadata|undefined
middleware
Section titled “middleware”middleware:
object[]
routers
Section titled “routers”routers:
object[]
routes
Section titled “routes”routes:
object[]
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get root():
Shokupan<any>
Defined in: src/router.ts:138
Returns
Section titled “Returns”Shokupan<any>
Inherited from
Section titled “Inherited from”rootConfig
Section titled “rootConfig”Get Signature
Section titled “Get Signature”get rootConfig():
Partial<{adapter?:ServerAdapter|"bun"|"node"|"wintercg";aiPlugin?: {api?: {is_user_authenticated?:boolean;type:"openapi";url?:string; };auth?: {[key:string]:any;type:"none"|"service_http"|"user_http"|"oauth"; };contact_email?:string;description_for_human?:string;description_for_model?:string;enabled?:boolean;legal_info_url?:string;logo_url?:string;name_for_human?:string;name_for_model?:string; };allowChunkedBody?:boolean;allowedStaticFilePaths?:string[];apiCatalog?: {enabled?:boolean;versions?:object[]; };astAnalysisTimeout?:number;astFilePath?:string;autoBackpressureFeedback?:boolean;autoBackpressureLevel?:number;blockOnAsyncApiGen:boolean;blockOnOpenApiGen:boolean;datastore?: {adapter:"surreal"|"sqlite"|"level";options?:any; };defaultResponseTransformer?:string;defaultSecurityHeaders?:any;development:boolean;disableBodyParsing?:boolean;enableAbortController?:boolean;enableAsyncApiGen:boolean;enableAsyncAstScanning?:boolean;enableAsyncLocalStorage:boolean;enableAutoContentNegotiation?:boolean;enableHTTPBridge?:boolean;enableMiddlewareTracking:boolean;enableOpenApiGen:boolean;enablePromiseMonkeypatch:boolean;enableTracing?:boolean;enableWebSocketTracking?:boolean;fileAccessCheck?: (ctx,path) =>boolean;fileSystem?:FileSystemAdapter;hooks:ShokupanHooks<Record<string,any>> |ShokupanHooks<Record<string,any>>[];hostname:string;httpLogger: (ctx) =>void;ide?:string;idGenerator?: () =>string;jsonParser?:"native"|"parse-json"|"secure-json-parse";logger:Logger;maxBodySize?:number;middlewareTrackingMaxCapacity?:number;middlewareTrackingTTL?:number;port:number;queryParserMode?:"strict"|"extended"|"simple";readTimeout:number;renderer:JSXRenderer;requestTimeout:number;reusePort:boolean;tls: {[key:string]:any;cert:string;key:string; };validateStatusCodes:boolean;websocketErrorHandler?: (err,ctx) =>void|Promise<void>;writeTimeout:number; }>
Defined in: src/router.ts:135
Returns
Section titled “Returns”Partial<{ adapter?: ServerAdapter | "bun" | "node" | "wintercg"; aiPlugin?: { api?: { is_user_authenticated?: boolean; type: "openapi"; url?: string; }; auth?: {[key: string]: any; type: "none" | "service_http" | "user_http" | "oauth"; }; contact_email?: string; description_for_human?: string; description_for_model?: string; enabled?: boolean; legal_info_url?: string; logo_url?: string; name_for_human?: string; name_for_model?: string; }; allowChunkedBody?: boolean; allowedStaticFilePaths?: string[]; apiCatalog?: { enabled?: boolean; versions?: object[]; }; astAnalysisTimeout?: number; astFilePath?: string; autoBackpressureFeedback?: boolean; autoBackpressureLevel?: number; blockOnAsyncApiGen: boolean; blockOnOpenApiGen: boolean; datastore?: { adapter: "surreal" | "sqlite" | "level"; options?: any; }; defaultResponseTransformer?: string; defaultSecurityHeaders?: any; development: boolean; disableBodyParsing?: boolean; enableAbortController?: boolean; enableAsyncApiGen: boolean; enableAsyncAstScanning?: boolean; enableAsyncLocalStorage: boolean; enableAutoContentNegotiation?: boolean; enableHTTPBridge?: boolean; enableMiddlewareTracking: boolean; enableOpenApiGen: boolean; enablePromiseMonkeypatch: boolean; enableTracing?: boolean; enableWebSocketTracking?: boolean; fileAccessCheck?: (ctx, path) => boolean; fileSystem?: FileSystemAdapter; hooks: ShokupanHooks<Record<string, any>> | ShokupanHooks<Record<string, any>>[]; hostname: string; httpLogger: (ctx) => void; ide?: string; idGenerator?: () => string; jsonParser?: "native" | "parse-json" | "secure-json-parse"; logger: Logger; maxBodySize?: number; middlewareTrackingMaxCapacity?: number; middlewareTrackingTTL?: number; port: number; queryParserMode?: "strict" | "extended" | "simple"; readTimeout: number; renderer: JSXRenderer; requestTimeout: number; reusePort: boolean; tls: {[key: string]: any; cert: string; key: string; }; validateStatusCodes: boolean; websocketErrorHandler?: (err, ctx) => void | Promise<void>; writeTimeout: number; }>
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”[$dispatch]()
Section titled “[$dispatch]()”[$dispatch](
req):Promise<Response|undefined>
Defined in: src/shokupan.ts:689
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<Response | undefined>
add(
arg):Shokupan<T>
Defined in: src/router.ts:1160
Adds a route to the router.
Parameters
Section titled “Parameters”Route configuration object
controller?
Section titled “controller?”any
Controller for the route
group?
Section titled “group?”string
Group for the route
handler
Section titled “handler”Route handler function
metadata?
Section titled “metadata?”{ file: string; line: number; }
metadata.file
Section titled “metadata.file”string
metadata.line
Section titled “metadata.line”number
method
Section titled “method”HTTP method
middleware?
Section titled “middleware?”string
URL path
regex?
Section titled “regex?”RegExp
Custom regex for path matching
renderer?
Section titled “renderer?”JSX renderer for the route
requestTimeout?
Section titled “requestTimeout?”number
Timeout for this route in milliseconds
OpenAPI specification for the route
Returns
Section titled “Returns”Shokupan<T>
Inherited from
Section titled “Inherited from”bindController()
Section titled “bindController()”bindController(
controller):void
Defined in: src/router.ts:402
Registers a controller instance to the router.
Parameters
Section titled “Parameters”controller
Section titled “controller”any
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”compile()
Section titled “compile()”compile():
void
Defined in: src/shokupan.ts:1136
Compiles all routes into a master Trie for O(1) router lookup. Use this if adding routes dynamically after start (not recommended but possible).
Returns
Section titled “Returns”void
delete()
Section titled “delete()”Call Signature
Section titled “Call Signature”delete<
Path>(path,handler, …handlers):this
Defined in: src/router.ts:1368
Adds a DELETE route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”delete<
Path>(path,spec,handler, …handlers):this
Defined in: src/router.ts:1376
Adds a DELETE route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
OpenAPI specification for the route
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”fetch()
Section titled “fetch()”fetch(
req,server?):Promise<Response|undefined>
Defined in: src/shokupan.ts:762
Handles an incoming request (Bun.serve interface). This logic contains the middleware chain and router dispatch.
Parameters
Section titled “Parameters”any
The request to handle.
server?
Section titled “server?”Server<any>
The server instance.
Returns
Section titled “Returns”Promise<Response | undefined>
The response to send.
find()
Section titled “find()”find(
method,path): {handler:ShokupanHandler<T>;params:Record<string,string>;route?:any; } |null
Defined in: src/shokupan.ts:1226
Find a route matching the given method and path. Wraps handler with router middleware if present.
Parameters
Section titled “Parameters”method
Section titled “method”string
HTTP method
string
Request path
Returns
Section titled “Returns”{ handler: ShokupanHandler<T>; params: Record<string, string>; route?: any; } | null
Route handler and parameters if found, otherwise null
Overrides
Section titled “Overrides”findEvent()
Section titled “findEvent()”findEvent(
name):ShokupanHandler<T>[] |null
Defined in: src/router.ts:383
Finds an event handler(s) by name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”ShokupanHandler<T>[] | null
Inherited from
Section titled “Inherited from”generateApiSpec()
Section titled “generateApiSpec()”generateApiSpec(
options):Promise<any>
Defined in: src/router.ts:1652
Generates an OpenAPI 3.1 Document by recursing through the router and its descendants. Now includes runtime analysis of handler functions to infer request/response types.
Parameters
Section titled “Parameters”options
Section titled “options”OpenAPIOptions = {}
Returns
Section titled “Returns”Promise<any>
Inherited from
Section titled “Inherited from”ShokupanRouter.generateApiSpec
Call Signature
Section titled “Call Signature”get<
Path>(path,handler, …handlers):this
Defined in: src/router.ts:1308
Adds a GET route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”get<
Path>(path,spec,handler, …handlers):this
Defined in: src/router.ts:1316
Adds a GET route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
OpenAPI specification for the route
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”getEventHandlers()
Section titled “getEventHandlers()”getEventHandlers():
Map<string,ShokupanHandler<T>[]>
Defined in: src/router.ts:409
Returns all registered event handlers.
Returns
Section titled “Returns”Map<string, ShokupanHandler<T>[]>
Inherited from
Section titled “Inherited from”ShokupanRouter.getEventHandlers
getRoutes()
Section titled “getRoutes()”getRoutes():
object[]
Defined in: src/router.ts:801
Returns all routes attached to this router and its descendants.
Returns
Section titled “Returns”object[]
Inherited from
Section titled “Inherited from”guard()
Section titled “guard()”Call Signature
Section titled “Call Signature”guard(
handler):void
Defined in: src/router.ts:1509
Adds a guard to the router that applies to all routes added after this point.
Guards must return true or call ctx.next() to allow the request to continue.
Parameters
Section titled “Parameters”handler
Section titled “handler”Guard handler function
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”guard(
spec,handler):void
Defined in: src/router.ts:1517
Adds a guard to the router that applies to all routes added after this point.
Guards must return true or call ctx.next() to allow the request to continue.
Parameters
Section titled “Parameters”OpenAPI specification for the guard
handler
Section titled “handler”Guard handler function
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”hasHooks()
Section titled “hasHooks()”hasHooks(
name):boolean
Defined in: src/router.ts:1657
Parameters
Section titled “Parameters”keyof ShokupanHooks<any>
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”head()
Section titled “head()”Call Signature
Section titled “Call Signature”head<
Path>(path,handler, …handlers):this
Defined in: src/router.ts:1428
Adds a HEAD route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”head<
Path>(path,spec,handler, …handlers):this
Defined in: src/router.ts:1436
Adds a HEAD route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
OpenAPI specification for the route
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”hook()
Section titled “hook()”hook(
name,handler):Shokupan<T>
Defined in: src/router.ts:317
Registers a lifecycle hook dynamically.
Parameters
Section titled “Parameters”keyof ShokupanHooks<any>
handler
Section titled “handler”Function
Returns
Section titled “Returns”Shokupan<T>
Inherited from
Section titled “Inherited from”internalRequest()
Section titled “internalRequest()”internalRequest(
arg):Promise<Response|undefined>
Defined in: src/router.ts:833
Makes an internal request through this router’s full routing pipeline. This is useful for calling other routes internally and supports streaming responses.
Parameters
Section titled “Parameters”string | { body?: any; headers?: HeadersInit; method?: Method; path: string; }
Returns
Section titled “Returns”Promise<Response | undefined>
The raw Response object.
Inherited from
Section titled “Inherited from”ShokupanRouter.internalRequest
listen()
Section titled “listen()”listen(
port?,callback?):Promise<Server<any> |undefined>
Defined in: src/shokupan.ts:633
Starts the application server.
Parameters
Section titled “Parameters”number
The port to listen on. If not specified, the port from the configuration is used. If that is not specified, port 3000 is used.
callback?
Section titled “callback?”() => void
Returns
Section titled “Returns”Promise<Server<any> | undefined>
The server instance.
mount()
Section titled “mount()”mount(
prefix,controller):Shokupan<T>
Defined in: src/router.ts:423
Mounts a controller instance or WebSocket router to a path prefix.
Controller can be a convention router, WebSocket router, or an arbitrary class.
Routes are derived from method names:
- get(ctx) -> GET /prefix/
- getUsers(ctx) -> GET /prefix/users
- postCreate(ctx) -> POST /prefix/create
Parameters
Section titled “Parameters”prefix
Section titled “prefix”string
controller
Section titled “controller”Record<string, any> | ShokupanRouter<T> | ShokupanRouter<GlobalShokupanState> | ShokupanController | ShokupanController<T>
Returns
Section titled “Returns”Shokupan<T>
Inherited from
Section titled “Inherited from”onSpecAvailable()
Section titled “onSpecAvailable()”onSpecAvailable(
callback):Shokupan<T>
Defined in: src/shokupan.ts:421
Registers a callback to be executed when the OpenAPI spec is available. This happens after generateOpenApi() but before the server starts listening (or at least before it finishes startup if async).
Parameters
Section titled “Parameters”callback
Section titled “callback”(spec) => void | Promise<void>
Returns
Section titled “Returns”Shokupan<T>
onStart()
Section titled “onStart()”onStart(
callback):Shokupan<T>
Defined in: src/shokupan.ts:412
Registers a callback to be executed before the server starts listening.
Parameters
Section titled “Parameters”callback
Section titled “callback”() => void | Promise<void>
Returns
Section titled “Returns”Shokupan<T>
onStrictError()
Section titled “onStrictError()”onStrictError<
T>(type,handler):this
Defined in: src/shokupan.ts:276
Register a global error handler for a specific error type. Handlers are checked in reverse order of registration (LIFO).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”(…args) => T
The error class constructor (e.g., Error, CustomError)
handler
Section titled “handler”ErrorHandler<T>
The handler function
Returns
Section titled “Returns”this
options()
Section titled “options()”Call Signature
Section titled “Call Signature”options<
Path>(path,handler, …handlers):this
Defined in: src/router.ts:1408
Adds a OPTIONS route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”options<
Path>(path,spec,handler, …handlers):this
Defined in: src/router.ts:1416
Adds a OPTIONS route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
OpenAPI specification for the route
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”patch()
Section titled “patch()”Call Signature
Section titled “Call Signature”patch<
Path>(path,handler, …handlers):this
Defined in: src/router.ts:1388
Adds a PATCH route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”patch<
Path>(path,spec,handler, …handlers):this
Defined in: src/router.ts:1396
Adds a PATCH route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
OpenAPI specification for the route
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”post()
Section titled “post()”Call Signature
Section titled “Call Signature”post<
Path>(path,handler, …handlers):this
Defined in: src/router.ts:1328
Adds a POST route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”post<
Path>(path,spec,handler, …handlers):this
Defined in: src/router.ts:1336
Adds a POST route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
OpenAPI specification for the route
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”prompt()
Section titled “prompt()”prompt(
name,args,handler):Shokupan<T>
Defined in: src/router.ts:359
Registers an MCP Prompt.
Parameters
Section titled “Parameters”string
object[] | undefined
handler
Section titled “handler”Function
Returns
Section titled “Returns”Shokupan<T>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”put<
Path>(path,handler, …handlers):this
Defined in: src/router.ts:1348
Adds a PUT route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”put<
Path>(path,spec,handler, …handlers):this
Defined in: src/router.ts:1356
Adds a PUT route to the router.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path
OpenAPI specification for the route
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
handlers
Section titled “handlers”…ShokupanHandler<T, RouteParams<Path>>[]
Route handler functions
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”register()
Section titled “register()”register(
plugin,options?):Promise<Shokupan<T>>
Defined in: src/shokupan.ts:395
Registers a plugin. This returns a promise that resolves when the plugin is initialized. You do not need to await it unless you want to run code specifically after the plugin is initialized. Shokupan automatically awaits plugin initialization promises when calling listen().
Parameters
Section titled “Parameters”plugin
Section titled “plugin”options?
Section titled “options?”string
Returns
Section titled “Returns”Promise<Shokupan<T>>
registerResponseTransformer()
Section titled “registerResponseTransformer()”registerResponseTransformer(
transformer):this
Defined in: src/shokupan.ts:264
Register a custom response transformer
Parameters
Section titled “Parameters”transformer
Section titled “transformer”ResponseTransformer
The transformer to register
Returns
Section titled “Returns”this
resource()
Section titled “resource()”resource(
uri,options,handler):Shokupan<T>
Defined in: src/router.ts:371
Registers an MCP Resource.
Parameters
Section titled “Parameters”string
options
Section titled “options”description?
Section titled “description?”string
mimeType?
Section titled “mimeType?”string
string
handler
Section titled “handler”Function
Returns
Section titled “Returns”Shokupan<T>
Inherited from
Section titled “Inherited from”runHooks()
Section titled “runHooks()”runHooks(
name, …args):void|Promise<void[]>
Defined in: src/router.ts:1708
Parameters
Section titled “Parameters”keyof ShokupanHooks<any>
…any[]
Returns
Section titled “Returns”void | Promise<void[]>
Inherited from
Section titled “Inherited from”runOnStopHooks()
Section titled “runOnStopHooks()”runOnStopHooks(
app):Promise<void>
Defined in: src/router.ts:1749
Parameters
Section titled “Parameters”Shokupan<any>
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”setDefaultResponseType()
Section titled “setDefaultResponseType()”setDefaultResponseType(
contentType):this
Defined in: src/shokupan.ts:285
Set the default response transformer content type
Parameters
Section titled “Parameters”contentType
Section titled “contentType”string
The content type to use as default
Returns
Section titled “Returns”this
socket()
Section titled “socket()”socket<
Path>(path,handler):this
Defined in: src/router.ts:1469
Adds a WebSocket route that handles its own upgrade logic.
Unless you need to handle the upgrade manually, you should use a ShokupanWebsocketRouter or WebsocketController instead.
Routes registered with .socket() will NOT be automatically upgraded by Shokupan’s WebSocket handling. You must implement
all event handlers manually. You have been warned.
Type Parameters
Section titled “Type Parameters”Path extends string
Parameters
Section titled “Parameters”Path
URL path for the WebSocket endpoint
handler
Section titled “handler”ShokupanHandler<T, RouteParams<Path>>
Route handler that will manually handle the upgrade
Returns
Section titled “Returns”this
Example
Section titled “Example”router.socket("/ws", (ctx) => { const success = ctx.upgrade({ data: { handler: { open: (ws) => console.log("Connected"), message: (ws, msg) => ws.send(msg), close: (ws) => console.log("Disconnected") } } }); if (!success) return ctx.text("Upgrade failed", 400);});Inherited from
Section titled “Inherited from”start()
Section titled “start()”start():
Promise<void>
Defined in: src/shokupan.ts:436
Prepare the application for listening. Use this if you want to initialize the app without starting the server immediately.
Returns
Section titled “Returns”Promise<void>
static()
Section titled “static()”static(
uriPath,options):Shokupan<T>
Defined in: src/router.ts:1562
Statically serves a directory with standard options.
Parameters
Section titled “Parameters”uriPath
Section titled “uriPath”string
URL path prefix
options
Section titled “options”Configuration options or root directory string
string | StaticServeOptions<T>
Returns
Section titled “Returns”Shokupan<T>
Inherited from
Section titled “Inherited from”stop()
Section titled “stop()”stop(
closeActiveConnections?):Promise<void>
Defined in: src/shokupan.ts:668
Stops the application server.
This method gracefully shuts down the server and stops any running monitors.
Parameters
Section titled “Parameters”closeActiveConnections?
Section titled “closeActiveConnections?”boolean
— Immediately terminate in-flight requests, websockets, and stop accepting new connections.
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the server has been stopped.
Example
Section titled “Example”const app = new Shokupan();const server = await app.listen(3000);
// Later, when you want to stop the serverawait app.stop();testRequest()
Section titled “testRequest()”testRequest(
options):Promise<ProcessResult>
Defined in: src/shokupan.ts:696
Processes a request by wrapping the standard fetch method.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<ProcessResult>
Overrides
Section titled “Overrides”tool()
Section titled “tool()”tool(
name,schema,handler):Shokupan<T>
Defined in: src/router.ts:347
Registers an MCP Tool.
Parameters
Section titled “Parameters”string
schema
Section titled “schema”any
handler
Section titled “handler”Function
Returns
Section titled “Returns”Shokupan<T>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”use(
middleware):this
Defined in: src/shokupan.ts:338
Adds middleware to the application.
Supports Express-style path-based middleware:
use('/admin', middleware) runs only for routes under /admin.
Parameters
Section titled “Parameters”middleware
Section titled “middleware”Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”use(
path,middleware):this
Defined in: src/shokupan.ts:339
Adds middleware to the application.
Supports Express-style path-based middleware:
use('/admin', middleware) runs only for routes under /admin.
Parameters
Section titled “Parameters”string
middleware
Section titled “middleware”Returns
Section titled “Returns”this