sleepy-serv 0.23.0 → 0.25.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 +53 -8
- package/dist/core/index.d.ts +31 -8
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/middleware.d.ts +2 -2
- package/dist/core/middleware.d.ts.map +1 -1
- package/dist/core/socket.d.ts +44 -17
- package/dist/core/socket.d.ts.map +1 -1
- package/dist/core/utils.d.ts +40 -86
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/index.ts +105 -71
- package/src/core/middleware.ts +9 -7
- package/src/core/socket.ts +172 -71
- package/src/core/utils.ts +51 -103
- package/src/index.ts +4 -4
package/README.md
CHANGED
|
@@ -571,10 +571,10 @@ and the server does not accept WebSocket upgrades. Calling `app.ws` or
|
|
|
571
571
|
|
|
572
572
|
The `app.ws` object exposes four methods for interacting with connected clients:
|
|
573
573
|
|
|
574
|
-
- `query(fn)`: return a filtered list of
|
|
575
|
-
- `send(event, body, fn)`: push a notification to clients matching a filter. The filter function receives `(
|
|
574
|
+
- `query(fn, filter?)`: return a filtered list of sessions. The filter function receives `(session, index)` where `session` is a `SessionEntry` (`{ clientId, type, data }`), and returns a boolean. The optional `filter` parameter controls which sessions are iterated: `'active'` (default), `'inactive'`, or `'all'`. To list all active sessions: `app.ws.query(() => true)`. To include inactive sessions: `app.ws.query(() => true, 'all')`.
|
|
575
|
+
- `send(event, body, fn)`: push a notification to clients matching a filter. The filter function receives `(session, index)` and returns a boolean. To target one client: `app.ws.send('ping', body, s => s.clientId === targetId)`.
|
|
576
576
|
- `broadcast(event, body)`: push a notification to all connected clients.
|
|
577
|
-
- `drop(signal, fn)`: close connections matching a filter. `signal` is a `CloseSignal` (`{ code, reason }`) with `code` validated in the range [4000-4099]. The filter function receives `(
|
|
577
|
+
- `drop(signal, fn)`: close connections matching a filter. `signal` is a `CloseSignal` (`{ code, reason }`) with `code` validated in the range [4000-4099]. The filter function receives `(session, index)` and returns a boolean. To drop one client: `app.ws.drop({ code: 4000, reason: 'kicked' }, s => s.clientId === targetId)`.
|
|
578
578
|
|
|
579
579
|
The same commands are available inside endpoint handlers via `req.ws`:
|
|
580
580
|
|
|
@@ -582,7 +582,7 @@ The same commands are available inside endpoint handlers via `req.ws`:
|
|
|
582
582
|
export default function (req) {
|
|
583
583
|
const targetId = req.query.targetId
|
|
584
584
|
|
|
585
|
-
req.ws.send('ping', { from: 'handler' },
|
|
585
|
+
req.ws.send('ping', { from: 'handler' }, s => s.clientId === targetId)
|
|
586
586
|
|
|
587
587
|
return Response.json({ ok: true })
|
|
588
588
|
}
|
|
@@ -590,17 +590,62 @@ export default function (req) {
|
|
|
590
590
|
|
|
591
591
|
This works from both HTTP and WebSocket transports.
|
|
592
592
|
|
|
593
|
+
### Typed Connection Data
|
|
594
|
+
|
|
595
|
+
All WebSocket types accept an optional generic parameter `<T>` that
|
|
596
|
+
constrains `session.data` in filter functions and query results:
|
|
597
|
+
|
|
598
|
+
```ts
|
|
599
|
+
type ConnectionData = {
|
|
600
|
+
userId: string
|
|
601
|
+
role: 'player' | 'spectator'
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const app = createApp<ConnectionData>(3000, { ws: true })
|
|
605
|
+
|
|
606
|
+
// session.data is typed as ConnectionData
|
|
607
|
+
app.ws.send('event', body, session => {
|
|
608
|
+
return session.data.userId !== excludedId
|
|
609
|
+
})
|
|
610
|
+
|
|
611
|
+
const players = app.ws.query(session => {
|
|
612
|
+
return session.data.role === 'player'
|
|
613
|
+
})
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
The type parameter propagates through `Request<T>`, `Middleware<T>`, and
|
|
617
|
+
`Handler<T>`, so typed handler and middleware functions also get typed
|
|
618
|
+
session data through `req.ws`:
|
|
619
|
+
|
|
620
|
+
```ts
|
|
621
|
+
import type { Request, AsyncHandlerResult } from 'sleepy-serv'
|
|
622
|
+
|
|
623
|
+
type ConnectionData = { userId: string }
|
|
624
|
+
|
|
625
|
+
export default async function (
|
|
626
|
+
req: Request<ConnectionData>,
|
|
627
|
+
): AsyncHandlerResult {
|
|
628
|
+
req.ws.send('joined', {}, session => {
|
|
629
|
+
return session.data.userId !== 'some-id'
|
|
630
|
+
})
|
|
631
|
+
|
|
632
|
+
return new Response('', { status: 204 })
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
593
636
|
## Exports
|
|
594
637
|
|
|
595
638
|
`sleepy-serv` exports several runtime constants and types:
|
|
596
639
|
|
|
597
|
-
- `
|
|
640
|
+
- `ServerCloseSignals`: server close signals: `Ok` (`{ code: 1000, reason: 'ok' }`), `Reaped` (`{ code: 4998, reason: 'reaped' }`), `Superseded` (`{ code: 4999, reason: 'superseded' }`)
|
|
598
641
|
- `CloseSignal`: the type for close signals: `{ code: number, reason: string }`
|
|
599
642
|
- `StatusCode`: the full range of HTTP status codes (1xx through 5xx)
|
|
600
643
|
- `HttpMethod`: HTTP verbs: `Head`, `Get`, `Post`, `Put`, `Patch`, `Delete`
|
|
601
|
-
- `
|
|
602
|
-
- `
|
|
603
|
-
- `
|
|
644
|
+
- `SessionType`: session state: `Active` (`'active'`), `Inactive` (`'inactive'`)
|
|
645
|
+
- `SessionFilter`: session filter: `Active` (`'active'`), `Inactive` (`'inactive'`), `All` (`'all'`)
|
|
646
|
+
- `SessionEntry<T>`: the shape returned by `query()` and received by filter callbacks: `{ clientId: string, type: SessionType, data: T }`
|
|
647
|
+
- `FilterFn<T>`: the filter callback type: `(session: SessionEntry<T>, index: number) => boolean`
|
|
648
|
+
- `SocketCommands<T>`: the type for `app.ws` and `req.ws`
|
|
604
649
|
- Error classes for every 4xx and 5xx status (e.g. `NotFoundError`, `UnauthorizedError`, `InternalServerError`)
|
|
605
650
|
- Middleware helpers: `parseJsonBody`, `validateSchemas`, `setValidationFormats`
|
|
606
651
|
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HttpMethod, Middleware, MiddlewareChain, Handler, Server } from './utils';
|
|
2
|
+
import type { SocketCommands } from './utils';
|
|
3
|
+
import type { SocketOptions } from './socket';
|
|
2
4
|
export * from './errors';
|
|
3
|
-
export {
|
|
5
|
+
export { ServerCloseSignals } from './socket';
|
|
6
|
+
export { StatusCode, HttpMethod, SessionType, SessionFilter, } from './utils';
|
|
4
7
|
export { parseJsonBody, setValidationFormats, validateSchemas, } from './middleware';
|
|
5
|
-
export type {
|
|
6
|
-
export type {
|
|
8
|
+
export type { ActiveSession, ActiveSessions, InactiveSession, SocketConnection, SocketOptions, } from './socket';
|
|
9
|
+
export type { AsyncHandlerResult, BaseRequest, CloseSignal, EndpointRequest, FilterFn, FormattedError, Handler, HandlerResult, Middleware, MiddlewareChain, NextFn, Request, Server, SessionEntry, SocketCommands, SocketData, WebSocketRequest, } from './utils';
|
|
7
10
|
export type { FormatterField, FormatterSchema, ValidationSchemas, } from './middleware';
|
|
11
|
+
export type RouteDefinition<T = void> = {
|
|
12
|
+
method: HttpMethod;
|
|
13
|
+
path: string;
|
|
14
|
+
chain: Handler<T> | MiddlewareChain<T>;
|
|
15
|
+
};
|
|
16
|
+
export type MetaEntry<T = void> = {
|
|
17
|
+
path: string;
|
|
18
|
+
middleware: Middleware<T>[];
|
|
19
|
+
};
|
|
20
|
+
export type RouteConfig<T = void> = {
|
|
21
|
+
routes: RouteDefinition<T>[];
|
|
22
|
+
meta?: MetaEntry<T>[];
|
|
23
|
+
};
|
|
24
|
+
export type AppOptions<T = void> = {
|
|
25
|
+
hostname?: string;
|
|
26
|
+
mountPath?: string;
|
|
27
|
+
middleware?: Middleware<T>[];
|
|
28
|
+
ws?: boolean | SocketOptions;
|
|
29
|
+
onClose?: () => Promise<void> | void;
|
|
30
|
+
};
|
|
8
31
|
type OutputRoutes = Record<string, string[]>;
|
|
9
32
|
type CloseFn = (force?: boolean) => Promise<void>;
|
|
10
|
-
export type App = {
|
|
11
|
-
server: Server
|
|
33
|
+
export type App<T = void> = {
|
|
34
|
+
server: Server<T>;
|
|
12
35
|
routes: OutputRoutes;
|
|
13
|
-
ws: SocketCommands
|
|
36
|
+
ws: SocketCommands<T>;
|
|
14
37
|
close: CloseFn;
|
|
15
38
|
};
|
|
16
|
-
export declare function createApp(port: number, config: RouteConfig
|
|
39
|
+
export declare function createApp<T = void>(port: number, config: RouteConfig<T>, opts?: AppOptions<T>): App<T>;
|
|
17
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAEV,UAAU,EACV,UAAU,EACV,eAAe,EAEf,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,UAAU,CAAA;AAEjB,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAE7C,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,SAAS,CAAA;AAEhB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,eAAe,GAChB,MAAM,cAAc,CAAA;AAErB,YAAY,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,UAAU,CAAA;AAEjB,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,cAAc,EACd,OAAO,EACP,aAAa,EACb,UAAU,EACV,eAAe,EACf,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G,IAAI,IAAI;IAC1B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IACjB,MAAM,EAAE,YAAY,CAAA;IACpB,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;IACrB,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AA0RD,wBAAgB,SAAS,CAAC,CAAC,GAAG,IAAI,EAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,IAAI,GAAE,UAAU,CAAC,CAAC,CAAM,GACvB,GAAG,CAAC,CAAC,CAAC,CAqBR"}
|
|
@@ -12,8 +12,8 @@ export type ValidationSchemas = {
|
|
|
12
12
|
body?: Schema;
|
|
13
13
|
};
|
|
14
14
|
export type SchemaKey = keyof ValidationSchemas;
|
|
15
|
-
export declare function parseJsonBody(): Middleware
|
|
15
|
+
export declare function parseJsonBody<T = void>(): Middleware<T>;
|
|
16
16
|
export declare function setValidationFormats(formats: Record<string, Format>): void;
|
|
17
17
|
export declare function resetValidationFormatsState(): void;
|
|
18
|
-
export declare function validateSchemas(schemas: ValidationSchemas): Middleware
|
|
18
|
+
export declare function validateSchemas<T = void>(schemas: ValidationSchemas): Middleware<T>;
|
|
19
19
|
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/core/middleware.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAoB,MAAM,KAAK,CAAA;AAE3D,OAAO,KAAK,EAIV,UAAU,EAGX,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;AAE5D,MAAM,MAAM,iBAAiB,GAAG;IAC9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
1
|
import type { WebSocketHandler } from 'bun';
|
|
2
|
-
import type { AsyncHandlerResult, CloseSignal, HttpMethod, Request, MiddlewareChain, SocketCommands, SocketData
|
|
3
|
-
type SocketHandler = (req: Request
|
|
4
|
-
type SocketEndpoint = {
|
|
2
|
+
import type { AsyncHandlerResult, CloseSignal, HttpMethod, Request, MiddlewareChain, SocketCommands, SocketData } from './utils';
|
|
3
|
+
type SocketHandler<T = void> = (req: Request<T>, res: unknown) => AsyncHandlerResult;
|
|
4
|
+
type SocketEndpoint<T = void> = {
|
|
5
5
|
method: HttpMethod;
|
|
6
6
|
path: string;
|
|
7
|
-
handler: SocketHandler
|
|
7
|
+
handler: SocketHandler<T>;
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
9
|
+
export type SocketConnection<T = void> = {
|
|
10
|
+
data: SocketData<T>;
|
|
11
|
+
send: (data: string) => unknown;
|
|
12
|
+
close: (code?: number, reason?: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export type ActiveSession<T = void> = {
|
|
15
|
+
token: string;
|
|
16
|
+
ws: SocketConnection<T>;
|
|
17
|
+
};
|
|
18
|
+
export type InactiveSession<T = void> = {
|
|
19
|
+
token: string;
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
data: T;
|
|
22
|
+
};
|
|
23
|
+
export type ActiveSessions<T = void> = ReadonlyMap<string, ActiveSession<T>>;
|
|
24
|
+
export declare const ServerCloseSignals: Record<string, CloseSignal>;
|
|
25
|
+
export type ServerCloseSignals = typeof ServerCloseSignals[keyof typeof ServerCloseSignals];
|
|
26
|
+
export type Session<T = void> = ActiveSession<T> | InactiveSession<T>;
|
|
27
|
+
export type SocketOptions = {
|
|
28
|
+
dropThreshold?: number;
|
|
29
|
+
heartbeatInterval?: number;
|
|
30
|
+
maxTickets?: number;
|
|
31
|
+
reclaimTtl?: number;
|
|
32
|
+
ticketTtl?: number;
|
|
33
|
+
onOpen?: (clientId: string) => void;
|
|
34
|
+
onClose?: (clientId: string, signal: CloseSignal) => void;
|
|
35
|
+
};
|
|
36
|
+
export type Ticket<T = void> = {
|
|
10
37
|
clientId: string;
|
|
11
38
|
expiresAt: number;
|
|
12
|
-
data:
|
|
39
|
+
data: T;
|
|
13
40
|
};
|
|
14
|
-
export type SocketState = {
|
|
41
|
+
export type SocketState<T = void> = {
|
|
15
42
|
dropThreshold: number;
|
|
16
43
|
heartbeatInterval: number;
|
|
17
44
|
maxTickets: number;
|
|
18
45
|
reclaimTtl: number;
|
|
19
46
|
ticketTtl: number;
|
|
20
|
-
tickets: Map<string, Ticket
|
|
21
|
-
activeSessions: Map<string, ActiveSession
|
|
22
|
-
inactiveSessions: Map<string, InactiveSession
|
|
47
|
+
tickets: Map<string, Ticket<T>>;
|
|
48
|
+
activeSessions: Map<string, ActiveSession<T>>;
|
|
49
|
+
inactiveSessions: Map<string, InactiveSession<T>>;
|
|
23
50
|
onOpen: ((clientId: string) => void) | null;
|
|
24
51
|
onClose: ((clientId: string, signal: CloseSignal) => void) | null;
|
|
25
52
|
};
|
|
26
|
-
export type SocketRoute = {
|
|
53
|
+
export type SocketRoute<T = void> = {
|
|
27
54
|
method: HttpMethod;
|
|
28
55
|
path: string;
|
|
29
56
|
segments: string[];
|
|
30
|
-
chain: MiddlewareChain
|
|
57
|
+
chain: MiddlewareChain<T>;
|
|
31
58
|
};
|
|
32
|
-
export declare function buildSocketState(opts?: SocketOptions): SocketState
|
|
33
|
-
export declare function buildSocketServer(routes: SocketRoute[], state: SocketState
|
|
34
|
-
export declare function buildSocketHandlers(state: SocketState): SocketEndpoint[];
|
|
35
|
-
export declare function buildDisabledSocketCommands(): SocketCommands
|
|
36
|
-
export declare function buildSocketCommands(state: SocketState): SocketCommands
|
|
59
|
+
export declare function buildSocketState<T = void>(opts?: SocketOptions): SocketState<T>;
|
|
60
|
+
export declare function buildSocketServer<T = void>(routes: SocketRoute<T>[], state: SocketState<T>, commands: SocketCommands<T>): WebSocketHandler<SocketData<T>>;
|
|
61
|
+
export declare function buildSocketHandlers<T = void>(state: SocketState<T>): SocketEndpoint<T>[];
|
|
62
|
+
export declare function buildDisabledSocketCommands<T = void>(): SocketCommands<T>;
|
|
63
|
+
export declare function buildSocketCommands<T = void>(state: SocketState<T>): SocketCommands<T>;
|
|
37
64
|
export {};
|
|
38
65
|
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/core/socket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/core/socket.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAE3C,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,OAAO,EAEP,eAAe,EACf,cAAc,EACd,UAAU,EAGX,MAAM,SAAS,CAAA;AAShB,KAAK,aAAa,CAAC,CAAC,GAAG,IAAI,IAAI,CAC7B,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EACf,GAAG,EAAE,OAAO,KACT,kBAAkB,CAAA;AAYvB,KAAK,cAAc,CAAC,CAAC,GAAG,IAAI,IAAI;IAC9B,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;CAC1B,CAAA;AAqBD,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,IAAI,IAAI;IACvC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;IACnB,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;IAC/B,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAChD,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,IAAI,IAAI;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,EAA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AC,CAAC,EAAE,CAwIrB;AAED,wBAAgB,2BAA2B,CAAC,CAAC,GAAG,IAAI,KAAM,cAAc,CAAC,CAAC,CAAC,CAS1E;AAED,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,IAAI,EAC1C,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GACpB,cAAc,CAAC,CAAC,CAAC,CAoHnB"}
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ErrorObject } from 'ajv';
|
|
2
2
|
import type { BunRequest, Server as BunServer } from 'bun';
|
|
3
|
+
export type TimeoutHandle = ReturnType<typeof setTimeout>;
|
|
3
4
|
export declare const HttpMethod: {
|
|
4
5
|
readonly Head: "HEAD";
|
|
5
6
|
readonly Get: "GET";
|
|
@@ -82,110 +83,63 @@ export type FormattedError = {
|
|
|
82
83
|
export type AsyncHandlerResult = Promise<Response>;
|
|
83
84
|
export type HandlerResult = Response | AsyncHandlerResult;
|
|
84
85
|
export type NextFn = (data?: unknown) => HandlerResult;
|
|
85
|
-
export type Middleware = (req: Request
|
|
86
|
-
export type Handler = (req: Request
|
|
87
|
-
export type MiddlewareChain = (Middleware | Handler)[];
|
|
88
|
-
export type
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
export type Middleware<T = void> = (req: Request<T>, res: unknown, next: NextFn) => HandlerResult;
|
|
87
|
+
export type Handler<T = void> = (req: Request<T>, res: unknown) => HandlerResult;
|
|
88
|
+
export type MiddlewareChain<T = void> = (Middleware<T> | Handler<T>)[];
|
|
89
|
+
export type CloseSignal = {
|
|
90
|
+
code: number;
|
|
91
|
+
reason: string;
|
|
92
|
+
};
|
|
93
|
+
export type SocketData<T = void> = {
|
|
94
|
+
clientId: string;
|
|
95
|
+
superseded: boolean;
|
|
96
|
+
reaped: boolean;
|
|
97
|
+
reaperHandle: TimeoutHandle | null;
|
|
98
|
+
data: T;
|
|
91
99
|
};
|
|
92
|
-
export
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
app: unknown;
|
|
100
|
+
export declare const SessionType: {
|
|
101
|
+
readonly Active: "active";
|
|
102
|
+
readonly Inactive: "inactive";
|
|
96
103
|
};
|
|
97
|
-
export type
|
|
98
|
-
export
|
|
99
|
-
|
|
104
|
+
export type SessionType = typeof SessionType[keyof typeof SessionType];
|
|
105
|
+
export declare const SessionFilter: {
|
|
106
|
+
readonly Active: "active";
|
|
107
|
+
readonly Inactive: "inactive";
|
|
108
|
+
readonly All: "all";
|
|
109
|
+
};
|
|
110
|
+
export type SessionFilter = typeof SessionFilter[keyof typeof SessionFilter];
|
|
111
|
+
export type SessionEntry<T = void> = {
|
|
100
112
|
clientId: string;
|
|
101
|
-
|
|
113
|
+
type: SessionType;
|
|
114
|
+
data: T;
|
|
102
115
|
};
|
|
103
|
-
export type FilterFn =
|
|
104
|
-
export type SocketCommands = {
|
|
116
|
+
export type FilterFn<T = void> = (session: SessionEntry<T>, index: number) => boolean;
|
|
117
|
+
export type SocketCommands<T = void> = {
|
|
105
118
|
broadcast: (event: string, body: unknown) => void;
|
|
106
|
-
send: (event: string, body: unknown, fn: FilterFn) => void;
|
|
107
|
-
drop: (signal: CloseSignal, fn: FilterFn) => void;
|
|
108
|
-
query: (fn: FilterFn) => SessionEntry[];
|
|
119
|
+
send: (event: string, body: unknown, fn: FilterFn<T>) => void;
|
|
120
|
+
drop: (signal: CloseSignal, fn: FilterFn<T>) => void;
|
|
121
|
+
query: (fn: FilterFn<T>, filter?: SessionFilter) => SessionEntry<T>[];
|
|
109
122
|
};
|
|
110
|
-
export type BaseRequest = {
|
|
123
|
+
export type BaseRequest<T = void> = {
|
|
111
124
|
method: HttpMethod;
|
|
112
125
|
route: string;
|
|
113
126
|
headers: Headers;
|
|
114
127
|
params: Record<string, string>;
|
|
115
128
|
query: Record<string, unknown>;
|
|
116
129
|
json: () => Promise<unknown>;
|
|
117
|
-
ws: SocketCommands
|
|
130
|
+
ws: SocketCommands<T>;
|
|
118
131
|
};
|
|
119
|
-
export type EndpointRequest = BaseRequest & {
|
|
132
|
+
export type EndpointRequest<T = void> = BaseRequest<T> & {
|
|
120
133
|
raw: BunRequest;
|
|
121
|
-
server: Server
|
|
134
|
+
server: Server<T>;
|
|
122
135
|
};
|
|
123
|
-
export type WebSocketRequest = BaseRequest & {
|
|
136
|
+
export type WebSocketRequest<T = void> = BaseRequest<T> & {
|
|
124
137
|
id: string;
|
|
125
138
|
clientId: string;
|
|
126
139
|
};
|
|
127
|
-
export type Request = EndpointRequest | WebSocketRequest
|
|
128
|
-
export type
|
|
129
|
-
code: number;
|
|
130
|
-
reason: string;
|
|
131
|
-
};
|
|
132
|
-
export declare const InternalCloseSignal: {
|
|
133
|
-
readonly Ok: {
|
|
134
|
-
readonly code: 1000;
|
|
135
|
-
readonly reason: "ok";
|
|
136
|
-
};
|
|
137
|
-
readonly Reaped: {
|
|
138
|
-
readonly code: 4998;
|
|
139
|
-
readonly reason: "reaped";
|
|
140
|
-
};
|
|
141
|
-
readonly Superseded: {
|
|
142
|
-
readonly code: 4999;
|
|
143
|
-
readonly reason: "superseded";
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
export type SocketOptions = {
|
|
147
|
-
dropThreshold?: number;
|
|
148
|
-
heartbeatInterval?: number;
|
|
149
|
-
maxTickets?: number;
|
|
150
|
-
reclaimTtl?: number;
|
|
151
|
-
ticketTtl?: number;
|
|
152
|
-
onOpen?: (clientId: string) => void;
|
|
153
|
-
onClose?: (clientId: string, signal: CloseSignal) => void;
|
|
154
|
-
};
|
|
155
|
-
export type SocketData = {
|
|
156
|
-
clientId: string;
|
|
157
|
-
superseded: boolean;
|
|
158
|
-
reaped: boolean;
|
|
159
|
-
reaperHandle: ReturnType<typeof setTimeout> | null;
|
|
160
|
-
app: unknown;
|
|
161
|
-
};
|
|
162
|
-
export type SocketConnection = {
|
|
163
|
-
data: SocketData;
|
|
164
|
-
send: (data: string) => unknown;
|
|
165
|
-
close: (code?: number, reason?: string) => void;
|
|
166
|
-
};
|
|
167
|
-
export type Server = BunServer<SocketData>;
|
|
168
|
-
export type RouteDefinition = {
|
|
169
|
-
method: HttpMethod;
|
|
170
|
-
path: string;
|
|
171
|
-
chain: Handler | MiddlewareChain;
|
|
172
|
-
};
|
|
173
|
-
export type MetaEntry = {
|
|
174
|
-
path: string;
|
|
175
|
-
middleware: Middleware[];
|
|
176
|
-
};
|
|
177
|
-
export type RouteConfig = {
|
|
178
|
-
routes: RouteDefinition[];
|
|
179
|
-
meta?: MetaEntry[];
|
|
180
|
-
};
|
|
181
|
-
export type AppOptions = {
|
|
182
|
-
hostname?: string;
|
|
183
|
-
mountPath?: string;
|
|
184
|
-
middleware?: Middleware[];
|
|
185
|
-
ws?: boolean | SocketOptions;
|
|
186
|
-
onClose?: () => Promise<void> | void;
|
|
187
|
-
};
|
|
140
|
+
export type Request<T = void> = EndpointRequest<T> | WebSocketRequest<T>;
|
|
141
|
+
export type Server<T = void> = BunServer<SocketData<T>>;
|
|
188
142
|
export declare function toSegments(pathString: string): string[];
|
|
189
143
|
export declare function formatError(prefix: string, input: ValidationError): FormattedError;
|
|
190
|
-
export declare function executeMiddlewareChain(req: Request
|
|
144
|
+
export declare function executeMiddlewareChain<T = void>(req: Request<T>, chain: MiddlewareChain<T>): AsyncHandlerResult;
|
|
191
145
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/core/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,KAAK,CAAA;AAE1D,eAAO,MAAM,UAAU;;;;;;;CAOb,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAA;AAEnE,eAAO,MAAM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AAA;CACtB,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACvD,GAAG,EAAE,UAAU,CAAA;IACf,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACxD,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA;AAExE,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,IAAI,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvD,wBAAgB,UAAU,CAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAaxD;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,GACrB,cAAc,CAQhB;AAED,wBAAsB,sBAAsB,CAAC,CAAC,GAAG,IAAI,EACnD,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EACf,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACxB,kBAAkB,CAyBpB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './core';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createApp(port: number, opts?: AppOptions): App
|
|
2
|
+
import type { AppOptions, App } from './core';
|
|
3
|
+
export declare function createApp<T = void>(port: number, opts?: AppOptions<T>): App<T>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AAEtB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AAEtB,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAE7C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,GAAG,IAAI,EACxC,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GACnB,GAAG,CAAC,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED