@donneko/tyoi-server / ShortHandler
Class: ShortHandler<RequestNameList, WebSocketNameList>
Defined in: short-handler/short-handler.ts:23
tyoi() が返す簡易サーバー API。
API と WebSocket を登録し、必要に応じて server から 基盤となる Server の全機能へアクセスできます。
A compact server API returned by tyoi(). Register HTTP APIs and WebSocket handlers directly, or use server to access the complete underlying Server API.
Type Parameters
RequestNameList
RequestNameList extends string = string
登録できる HTTP API キー(例: "GET:/health")。 / HTTP API keys that can be registered, such as "GET:/health".
WebSocketNameList
WebSocketNameList extends string = string
登録できる WebSocket パス。 / WebSocket paths that can be registered.
Constructors
Constructor
new ShortHandler<
RequestNameList,WebSocketNameList>(server):ShortHandler<RequestNameList,WebSocketNameList>
Defined in: short-handler/short-handler.ts:29
Parameters
server
Server<RequestNameList, WebSocketNameList>
Returns
ShortHandler<RequestNameList, WebSocketNameList>
Accessors
server
Get Signature
get server():
Server<RequestNameList,WebSocketNameList>
Defined in: short-handler/short-handler.ts:33
基盤となる Server インスタンスを取得します。 / Returns the underlying Server instance.
Returns
Server<RequestNameList, WebSocketNameList>
Methods
close()
close():
Promise<void>
Defined in: short-handler/short-handler.ts:79
サーバーを停止し、接続の終了を待機します。 / Stops the server and waits for connections to close.
Returns
Promise<void>
get()
get(
pass,fn):this
Defined in: short-handler/short-handler.ts:38
型付きキーの GET: に対応する API ハンドラを登録します。 / Registers an API handler for a typed GET: key.
Parameters
pass
string extends RequestNameList ? string : RequestNameList extends `GET:${Path}` ? Path : never
fn
Returns
this
listen()
listen(
options?):Promise<Server<typeofIncomingMessage, typeofServerResponse> |undefined>
Defined in: short-handler/short-handler.ts:67
start() の別名です。 / Alias for start().
Parameters
options?
Returns
Promise<Server<typeof IncomingMessage, typeof ServerResponse> | undefined>
post()
post(
pass,fn):this
Defined in: short-handler/short-handler.ts:50
型付きキーの POST: に対応する API ハンドラを登録します。 / Registers an API handler for a typed POST: key.
Parameters
pass
string extends RequestNameList ? string : RequestNameList extends `POST:${Path}` ? Path : never
fn
Returns
this
start()
start(
options?):Promise<Server<typeofIncomingMessage, typeofServerResponse> |undefined>
Defined in: short-handler/short-handler.ts:71
サーバーを起動します。 / Starts the server.
Parameters
options?
Returns
Promise<Server<typeof IncomingMessage, typeof ServerResponse> | undefined>
stop()
stop():
Promise<void>
Defined in: short-handler/short-handler.ts:75
close() の別名です。 / Alias for close().
Returns
Promise<void>
ws()
ws(
pass,fn):this
Defined in: short-handler/short-handler.ts:62
WebSocket ハンドラを登録します。 / Registers a WebSocket handler.
Parameters
pass
WebSocketNameList
fn
Returns
this