weifuwu 0.27.28 → 0.28.2

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/dist/types.d.ts DELETED
@@ -1,76 +0,0 @@
1
- import type postgres from 'postgres';
2
- /** Untyped postgres.js SQL client. Use typed `Sql<{ table: { col: type } }>` for schemas. */
3
- export type SqlClient = postgres.Sql<Record<string, unknown>>;
4
- /** Re-export for downstream usage. */
5
- export type { Sql } from 'postgres';
6
- /** Lightweight WebSocket interface for WS handler types (avoids external dep resolution). */
7
- export interface WebSocket {
8
- send(data: string | Buffer): void;
9
- close(code?: number, reason?: string): void;
10
- ping(data?: unknown): void;
11
- readyState: number;
12
- readonly OPEN: number;
13
- readonly CLOSED: number;
14
- readonly CONNECTING: number;
15
- readonly CLOSING: number;
16
- on(event: string, handler: (...args: unknown[]) => void): this;
17
- off(event: string, handler: (...args: unknown[]) => void): this;
18
- addEventListener(event: string, handler: (...args: unknown[]) => void): void;
19
- removeEventListener(event: string, handler: (...args: unknown[]) => void): void;
20
- }
21
- export type { Redis, RedisOptions } from 'ioredis';
22
- export interface WsContext {
23
- /** Per-connection state object */
24
- state: Record<string, unknown>;
25
- /** Send JSON to this connection */
26
- json(data: unknown): void;
27
- /** Join a room */
28
- join(room: string): void;
29
- /** Leave a room */
30
- leave(room: string): void;
31
- /** Broadcast to a room */
32
- sendRoom(room: string, data: unknown): void;
33
- }
34
- export interface Context {
35
- params: Record<string, string>;
36
- query: Record<string, string>;
37
- mountPath?: string;
38
- [key: string]: unknown;
39
- }
40
- export type Handler<T extends Context = Context> = (req: Request, ctx: T) => Response | Promise<Response>;
41
- /**
42
- * Metadata for middleware dependency checking.
43
- * Middleware factories attach this for runtime validation.
44
- */
45
- export interface MiddlewareMeta {
46
- /** Fields this middleware injects into ctx. */
47
- injects: string[];
48
- /** Fields this middleware depends on (must be injected earlier). */
49
- depends: string[];
50
- }
51
- export type Middleware<In extends Context = Context, Out extends In = In> = {
52
- (req: Request, ctx: In, next: Handler<Out>): Response | Promise<Response>;
53
- __meta?: MiddlewareMeta;
54
- };
55
- export type ErrorHandler<T extends Context = Context> = (error: Error, req: Request, ctx: T) => Response | Promise<Response>;
56
- /**
57
- * Interface for resources that require explicit cleanup (connections, pools, timers).
58
- * All stateful modules implement this.
59
- */
60
- export interface Closeable {
61
- /** Release all resources. Call once when shutting down. */
62
- close(): Promise<void>;
63
- }
64
- /**
65
- * HTTP error with an explicit status code.
66
- * Throw from a handler or middleware to return a non-200 response.
67
- *
68
- * ```ts
69
- * if (!resource) throw new HttpError('Not found', 404)
70
- * serve() catches it and returns the status code.
71
- * ```
72
- */
73
- export declare class HttpError extends Error {
74
- status: number;
75
- constructor(message: string, status: number);
76
- }