oakbun 0.1.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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/adapter/mysql.d.ts +21 -0
- package/dist/adapter/mysql.d.ts.map +1 -0
- package/dist/adapter/mysql.js +10 -0
- package/dist/adapter/mysql.js.map +1 -0
- package/dist/adapter/postgres.d.ts +16 -0
- package/dist/adapter/postgres.d.ts.map +1 -0
- package/dist/adapter/postgres.js +10 -0
- package/dist/adapter/postgres.js.map +1 -0
- package/dist/adapter/resolve.d.ts +16 -0
- package/dist/adapter/resolve.d.ts.map +1 -0
- package/dist/adapter/sqlite.d.ts +17 -0
- package/dist/adapter/sqlite.d.ts.map +1 -0
- package/dist/adapter/sqlite.js +10 -0
- package/dist/adapter/sqlite.js.map +1 -0
- package/dist/adapter/types.d.ts +29 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/app/audit-wiring.d.ts +6 -0
- package/dist/app/audit-wiring.d.ts.map +1 -0
- package/dist/app/body-size-limit.d.ts +29 -0
- package/dist/app/body-size-limit.d.ts.map +1 -0
- package/dist/app/compression.d.ts +25 -0
- package/dist/app/compression.d.ts.map +1 -0
- package/dist/app/cookies.d.ts +17 -0
- package/dist/app/cookies.d.ts.map +1 -0
- package/dist/app/cors.d.ts +65 -0
- package/dist/app/cors.d.ts.map +1 -0
- package/dist/app/csrf.d.ts +52 -0
- package/dist/app/csrf.d.ts.map +1 -0
- package/dist/app/health.d.ts +36 -0
- package/dist/app/health.d.ts.map +1 -0
- package/dist/app/index.d.ts +282 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/logger.d.ts +4 -0
- package/dist/app/logger.d.ts.map +1 -0
- package/dist/app/middleware.d.ts +20 -0
- package/dist/app/middleware.d.ts.map +1 -0
- package/dist/app/module.d.ts +273 -0
- package/dist/app/module.d.ts.map +1 -0
- package/dist/app/plugin.d.ts +112 -0
- package/dist/app/plugin.d.ts.map +1 -0
- package/dist/app/rate-limit.d.ts +76 -0
- package/dist/app/rate-limit.d.ts.map +1 -0
- package/dist/app/request-id.d.ts +52 -0
- package/dist/app/request-id.d.ts.map +1 -0
- package/dist/app/router.d.ts +6 -0
- package/dist/app/router.d.ts.map +1 -0
- package/dist/app/scalar.d.ts +40 -0
- package/dist/app/scalar.d.ts.map +1 -0
- package/dist/app/secure-headers.d.ts +48 -0
- package/dist/app/secure-headers.d.ts.map +1 -0
- package/dist/app/system-ctx.d.ts +3 -0
- package/dist/app/system-ctx.d.ts.map +1 -0
- package/dist/app/types.d.ts +277 -0
- package/dist/app/types.d.ts.map +1 -0
- package/dist/chunk-32M77PK3.js +75 -0
- package/dist/chunk-32M77PK3.js.map +1 -0
- package/dist/chunk-7C6SKWY7.js +86 -0
- package/dist/chunk-7C6SKWY7.js.map +1 -0
- package/dist/chunk-7PGCL2E7.js +78 -0
- package/dist/chunk-7PGCL2E7.js.map +1 -0
- package/dist/chunk-F3WAOTEN.js +86 -0
- package/dist/chunk-FJSYS3BT.js +27 -0
- package/dist/chunk-UNRUXO7H.js +68 -0
- package/dist/chunk-WQ44NZ6K.js +116 -0
- package/dist/chunk-Z6ZWNWWR.js +34 -0
- package/dist/chunk-Z6ZWNWWR.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +645 -0
- package/dist/cli/commands/make/migration.d.ts +3 -0
- package/dist/cli/commands/make/migration.d.ts.map +1 -0
- package/dist/cli/commands/migrate/adapter.d.ts +14 -0
- package/dist/cli/commands/migrate/adapter.d.ts.map +1 -0
- package/dist/cli/commands/migrate/generate.d.ts +3 -0
- package/dist/cli/commands/migrate/generate.d.ts.map +1 -0
- package/dist/cli/commands/migrate/rollback.d.ts +3 -0
- package/dist/cli/commands/migrate/rollback.d.ts.map +1 -0
- package/dist/cli/commands/migrate/run.d.ts +3 -0
- package/dist/cli/commands/migrate/run.d.ts.map +1 -0
- package/dist/cli/commands/migrate/status.d.ts +3 -0
- package/dist/cli/commands/migrate/status.d.ts.map +1 -0
- package/dist/cli/commands/tinker.d.ts +7 -0
- package/dist/cli/commands/tinker.d.ts.map +1 -0
- package/dist/cli/config/defaults.d.ts +4 -0
- package/dist/cli/config/defaults.d.ts.map +1 -0
- package/dist/cli/config/loader.d.ts +3 -0
- package/dist/cli/config/loader.d.ts.map +1 -0
- package/dist/cli/config/types.d.ts +31 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/discovery/commands.d.ts +4 -0
- package/dist/cli/discovery/commands.d.ts.map +1 -0
- package/dist/cli/discovery/services.d.ts +4 -0
- package/dist/cli/discovery/services.d.ts.map +1 -0
- package/dist/cli/discovery/tables.d.ts +5 -0
- package/dist/cli/discovery/tables.d.ts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/client/error.d.ts +8 -0
- package/dist/client/error.d.ts.map +1 -0
- package/dist/client/index.d.ts +33 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/proxy.d.ts +88 -0
- package/dist/client/proxy.d.ts.map +1 -0
- package/dist/client/test-client.d.ts +30 -0
- package/dist/client/test-client.d.ts.map +1 -0
- package/dist/cron/index.d.ts +73 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/db/index.d.ts +281 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/migrations/diff.d.ts +5 -0
- package/dist/db/migrations/diff.d.ts.map +1 -0
- package/dist/db/migrations/generator.d.ts +26 -0
- package/dist/db/migrations/generator.d.ts.map +1 -0
- package/dist/db/migrations/index.d.ts +9 -0
- package/dist/db/migrations/index.d.ts.map +1 -0
- package/dist/db/migrations/introspect.d.ts +8 -0
- package/dist/db/migrations/introspect.d.ts.map +1 -0
- package/dist/db/migrations/migrator.d.ts +10 -0
- package/dist/db/migrations/migrator.d.ts.map +1 -0
- package/dist/db/migrations/runner.d.ts +7 -0
- package/dist/db/migrations/runner.d.ts.map +1 -0
- package/dist/db/migrations/tracker.d.ts +7 -0
- package/dist/db/migrations/tracker.d.ts.map +1 -0
- package/dist/db/migrations/types.d.ts +70 -0
- package/dist/db/migrations/types.d.ts.map +1 -0
- package/dist/db/sql.d.ts +148 -0
- package/dist/db/sql.d.ts.map +1 -0
- package/dist/db-XTXH6OKV.js +889 -0
- package/dist/errors/index.d.ts +30 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events/handler.d.ts +42 -0
- package/dist/events/handler.d.ts.map +1 -0
- package/dist/events/index.d.ts +48 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events-LDXSK7ME.js +12 -0
- package/dist/executor-BM3A6AGL.js +104 -0
- package/dist/hooks/executor.d.ts +20 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/types.d.ts +10 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5562 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations-IWFQ6MZZ.js +757 -0
- package/dist/model/index.d.ts +24 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/openapi/generator.d.ts +58 -0
- package/dist/openapi/generator.d.ts.map +1 -0
- package/dist/openapi/zod-to-schema.d.ts +4 -0
- package/dist/openapi/zod-to-schema.d.ts.map +1 -0
- package/dist/resource/errors.d.ts +2 -0
- package/dist/resource/errors.d.ts.map +1 -0
- package/dist/resource/index.d.ts +98 -0
- package/dist/resource/index.d.ts.map +1 -0
- package/dist/resource/zod-table.d.ts +6 -0
- package/dist/resource/zod-table.d.ts.map +1 -0
- package/dist/schema/audit.d.ts +25 -0
- package/dist/schema/audit.d.ts.map +1 -0
- package/dist/schema/column.d.ts +31 -0
- package/dist/schema/column.d.ts.map +1 -0
- package/dist/schema/table.d.ts +68 -0
- package/dist/schema/table.d.ts.map +1 -0
- package/dist/service/index.d.ts +27 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service-W4V6TFWU.js +126 -0
- package/dist/sqlite-VTXOCD65.js +10 -0
- package/dist/system-ctx-GPF44QCE.js +42 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 René (SchildW3rk)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# oakbun
|
|
2
|
+
|
|
3
|
+
Bun-native backend framework — No Magic, just code.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add oakbun zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createApp, defineModule, column, defineTable } from 'oakbun'
|
|
15
|
+
import { SQLiteAdapter } from 'oakbun/adapter/sqlite'
|
|
16
|
+
|
|
17
|
+
const db = new SQLiteAdapter({ filename: 'app.db' })
|
|
18
|
+
|
|
19
|
+
const users = defineTable('users', {
|
|
20
|
+
id: column.integer().primaryKey(),
|
|
21
|
+
name: column.text().notNull(),
|
|
22
|
+
email: column.text().notNull().unique(),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const app = createApp({ adapter: db })
|
|
26
|
+
|
|
27
|
+
app.use(defineModule('users')
|
|
28
|
+
.get('/', async (ctx) => ctx.json(await ctx.db.select(users)))
|
|
29
|
+
.post('/', async (ctx) => {
|
|
30
|
+
const body = await ctx.req.json()
|
|
31
|
+
await ctx.db.insert(users).values(body)
|
|
32
|
+
return ctx.json({ ok: true }, 201)
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
app.listen({ port: 3000 })
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Adapters
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { SQLiteAdapter } from 'oakbun/adapter/sqlite'
|
|
43
|
+
import { PostgresAdapter } from 'oakbun/adapter/postgres'
|
|
44
|
+
import { MySQLAdapter } from 'oakbun/adapter/mysql'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Documentation
|
|
48
|
+
|
|
49
|
+
Full docs at [oakbun.dev](https://oakbun.dev).
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { VelnAdapter, BindingValue, ExecuteResult, QueryLogEntry } from './types';
|
|
2
|
+
export interface MySQLConfig {
|
|
3
|
+
url?: string;
|
|
4
|
+
hostname?: string;
|
|
5
|
+
port?: number;
|
|
6
|
+
database?: string;
|
|
7
|
+
username?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
max?: number;
|
|
10
|
+
idleTimeout?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class MySQLAdapter implements VelnAdapter {
|
|
13
|
+
private readonly sql;
|
|
14
|
+
onQuery?: (entry: QueryLogEntry) => void;
|
|
15
|
+
constructor(config: MySQLConfig);
|
|
16
|
+
query<T>(sql: string, params?: BindingValue[]): Promise<T[]>;
|
|
17
|
+
execute(sql: string, params?: BindingValue[]): Promise<ExecuteResult>;
|
|
18
|
+
transaction<T>(fn: (tx: VelnAdapter) => Promise<T>): Promise<T>;
|
|
19
|
+
close(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=mysql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../../src/adapter/mysql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEtF,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,qBAAa,YAAa,YAAW,WAAW;IAI9C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAK;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;gBAE5B,MAAM,EAAE,WAAW;IAiBzB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,YAAY,EAAO,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAQhE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,YAAY,EAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAQzE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAgB/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VelnAdapter, BindingValue, ExecuteResult, QueryLogEntry } from './types';
|
|
2
|
+
export interface PostgresConfig {
|
|
3
|
+
url: string;
|
|
4
|
+
max?: number;
|
|
5
|
+
idleTimeout?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class PostgresAdapter implements VelnAdapter {
|
|
8
|
+
private readonly sql;
|
|
9
|
+
onQuery?: (entry: QueryLogEntry) => void;
|
|
10
|
+
constructor(config: PostgresConfig);
|
|
11
|
+
query<T>(sql: string, params?: BindingValue[]): Promise<T[]>;
|
|
12
|
+
execute(sql: string, params?: BindingValue[]): Promise<ExecuteResult>;
|
|
13
|
+
transaction<T>(fn: (tx: VelnAdapter) => Promise<T>): Promise<T>;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/adapter/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEtF,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,qBAAa,eAAgB,YAAW,WAAW;IAIjD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAK;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;gBAE5B,MAAM,EAAE,cAAc;IAe5B,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,YAAY,EAAO,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAQhE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,YAAY,EAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IASzE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAgB/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VelnAdapter } from './types';
|
|
2
|
+
export type AdapterConfig = {
|
|
3
|
+
adapter: 'sqlite';
|
|
4
|
+
path?: string;
|
|
5
|
+
} | {
|
|
6
|
+
adapter: 'postgres';
|
|
7
|
+
connectionString: string;
|
|
8
|
+
maxConnections?: number;
|
|
9
|
+
} | {
|
|
10
|
+
adapter: 'mysql';
|
|
11
|
+
connectionString: string;
|
|
12
|
+
maxConnections?: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function isVelnAdapter(value: unknown): value is VelnAdapter;
|
|
15
|
+
export declare function resolveAdapter(config: AdapterConfig | VelnAdapter): VelnAdapter;
|
|
16
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/adapter/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,MAAM,MAAM,aAAa,GACrB;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAG,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,OAAO,EAAE,OAAO,CAAC;IAAI,gBAAgB,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9E,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAOlE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,WAAW,CAwB/E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { VelnAdapter, BindingValue, ExecuteResult, QueryLogEntry } from './types';
|
|
2
|
+
export interface SQLiteConfig {
|
|
3
|
+
path?: string;
|
|
4
|
+
wal?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class SQLiteAdapter implements VelnAdapter {
|
|
7
|
+
private readonly db;
|
|
8
|
+
private readonly _stmtCache;
|
|
9
|
+
onQuery?: (entry: QueryLogEntry) => void;
|
|
10
|
+
constructor(config?: SQLiteConfig | string);
|
|
11
|
+
private _prepare;
|
|
12
|
+
query<T>(sql: string, params?: BindingValue[]): Promise<T[]>;
|
|
13
|
+
execute(sql: string, params?: BindingValue[]): Promise<ExecuteResult>;
|
|
14
|
+
transaction<T>(fn: (tx: VelnAdapter) => Promise<T>): Promise<T>;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=sqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/adapter/sqlite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEtF,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAMD,qBAAa,aAAc,YAAW,WAAW;IAC/C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;IAI7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqD;IAChF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;gBAE5B,MAAM,GAAE,YAAY,GAAG,MAAW;IAS9C,OAAO,CAAC,QAAQ;IAkBV,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,YAAY,EAAO,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAQhE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,YAAY,EAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAezE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAc/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type BindingValue = string | number | bigint | boolean | null | Uint8Array;
|
|
2
|
+
export interface ExecuteResult {
|
|
3
|
+
rowsAffected: number;
|
|
4
|
+
lastInsertId?: number | bigint;
|
|
5
|
+
}
|
|
6
|
+
/** Emitted by the adapter after every query() or execute() call. */
|
|
7
|
+
export interface QueryLogEntry {
|
|
8
|
+
/** The SQL string that was executed. */
|
|
9
|
+
sql: string;
|
|
10
|
+
/** The bound parameter values. */
|
|
11
|
+
params: BindingValue[];
|
|
12
|
+
/** Wall-clock duration in milliseconds (performance.now() resolution). */
|
|
13
|
+
durationMs: number;
|
|
14
|
+
/** Whether the call was query() (returns rows) or execute() (DML/DDL). */
|
|
15
|
+
type: 'query' | 'execute';
|
|
16
|
+
}
|
|
17
|
+
export interface VelnAdapter {
|
|
18
|
+
query<T = Record<string, unknown>>(sql: string, params?: BindingValue[]): Promise<T[]>;
|
|
19
|
+
execute(sql: string, params?: BindingValue[]): Promise<ExecuteResult>;
|
|
20
|
+
transaction<T>(fn: (tx: VelnAdapter) => Promise<T>): Promise<T>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Optional query observer. When set, the adapter calls this after every
|
|
24
|
+
* query() and execute() with timing and SQL details.
|
|
25
|
+
* Set by dbPlugin when query logging is enabled — do not call directly.
|
|
26
|
+
*/
|
|
27
|
+
onQuery?: (entry: QueryLogEntry) => void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapter/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,UAAU,CAAA;AAEd,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAA;IAGpB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC/B;AAED,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,GAAG,EAAS,MAAM,CAAA;IAClB,kCAAkC;IAClC,MAAM,EAAM,YAAY,EAAE,CAAA;IAC1B,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAA;IAClB,0EAA0E;IAC1E,IAAI,EAAQ,OAAO,GAAG,SAAS,CAAA;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;IACtF,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IACrE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAC/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;CACzC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { VelnAdapter } from '../adapter/types';
|
|
2
|
+
import type { SchemaMap } from '../schema/table';
|
|
3
|
+
import type { ModuleHookHandlers } from '../hooks/types';
|
|
4
|
+
import type { AuditDeclaration } from './module';
|
|
5
|
+
export declare function buildAuditHooks<T extends Record<string, unknown>, TCtx, S extends SchemaMap>(decl: AuditDeclaration<T, TCtx, S>, adapter: VelnAdapter): ModuleHookHandlers<T, unknown>;
|
|
6
|
+
//# sourceMappingURL=audit-wiring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-wiring.d.ts","sourceRoot":"","sources":["../../src/app/audit-wiring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAkBhD,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,SAAS,SAAS,EAC1F,IAAI,EAAE,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAClC,OAAO,EAAE,WAAW,GACnB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,CAoEhC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OnRequestHook } from './types';
|
|
2
|
+
export interface BodySizeLimitOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Maximum allowed body size in bytes.
|
|
5
|
+
* Default: 1_048_576 (1 MB)
|
|
6
|
+
*/
|
|
7
|
+
maxSize?: number;
|
|
8
|
+
/** Response message when limit is exceeded. Default: 'Payload too large' */
|
|
9
|
+
message?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* bodySizeLimitPlugin — rejects requests whose Content-Length exceeds maxSize.
|
|
13
|
+
*
|
|
14
|
+
* Returns an OnRequestHook — pass it to app.onRequest():
|
|
15
|
+
* app.onRequest(bodySizeLimitPlugin()) // 1MB default
|
|
16
|
+
* app.onRequest(bodySizeLimitPlugin({ maxSize: 512_000 })) // 512KB
|
|
17
|
+
*
|
|
18
|
+
* Checks the Content-Length header only — does not buffer or read the body.
|
|
19
|
+
* Requests without Content-Length are passed through (streaming / chunked).
|
|
20
|
+
* Returns 413 Payload Too Large on violation.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* This plugin enforces limits based on the Content-Length header only.
|
|
24
|
+
* Chunked transfer-encoding bypasses this check entirely.
|
|
25
|
+
* For production deployments, configure body size limits at the reverse proxy level:
|
|
26
|
+
* nginx: `client_max_body_size`, Caddy: `request_body { max_size }`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function bodySizeLimitPlugin(options?: BodySizeLimitOptions): OnRequestHook;
|
|
29
|
+
//# sourceMappingURL=body-size-limit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-size-limit.d.ts","sourceRoot":"","sources":["../../src/app/body-size-limit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAqBrF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OnResponseHook } from './types';
|
|
2
|
+
export interface CompressionOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Compression algorithms to offer, in preference order.
|
|
5
|
+
* Default: `['gzip', 'deflate']`
|
|
6
|
+
*
|
|
7
|
+
* Bun 1.x provides `Bun.gzipSync` and `Bun.deflateSync` natively.
|
|
8
|
+
*/
|
|
9
|
+
encodings?: Array<'gzip' | 'deflate'>;
|
|
10
|
+
/**
|
|
11
|
+
* Minimum response body size in bytes before compression is applied.
|
|
12
|
+
* Responses smaller than this are sent uncompressed.
|
|
13
|
+
* Default: `1024` (1 KB)
|
|
14
|
+
*/
|
|
15
|
+
threshold?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum response body size in bytes to attempt compression.
|
|
18
|
+
* Responses larger than this are passed through uncompressed to avoid
|
|
19
|
+
* excessive memory usage when buffering very large responses.
|
|
20
|
+
* Default: `10485760` (10 MB)
|
|
21
|
+
*/
|
|
22
|
+
maxSize?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function compressionPlugin(options?: CompressionOptions): OnResponseHook;
|
|
25
|
+
//# sourceMappingURL=compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../../src/app/compression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAErC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAmDD,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,cAAc,CA4ClF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface CookieOptions {
|
|
2
|
+
httpOnly?: boolean;
|
|
3
|
+
secure?: boolean;
|
|
4
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
5
|
+
maxAge?: number;
|
|
6
|
+
path?: string;
|
|
7
|
+
domain?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CookieJar {
|
|
10
|
+
get(name: string): string | undefined;
|
|
11
|
+
set(name: string, value: string, options?: CookieOptions): void;
|
|
12
|
+
delete(name: string): void;
|
|
13
|
+
/** Framework-internal: returns all pending Set-Cookie header values */
|
|
14
|
+
_pending(): string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function createCookieJar(req: Request): CookieJar;
|
|
17
|
+
//# sourceMappingURL=cookies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/app/cookies.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAI,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;IACpC,MAAM,CAAC,EAAI,MAAM,CAAA;IACjB,IAAI,CAAC,EAAM,MAAM,CAAA;IACjB,MAAM,CAAC,EAAI,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACrC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC/D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,uEAAuE;IACvE,QAAQ,IAAI,MAAM,EAAE,CAAA;CACrB;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAqDvD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { OnRequestHook, OnResponseHook } from './types';
|
|
2
|
+
export interface CorsOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Allowed origins. Can be:
|
|
5
|
+
* - `'*'` → any origin (not usable with credentials)
|
|
6
|
+
* - `string` → single allowed origin
|
|
7
|
+
* - `string[]` → list of allowed origins (matched against request Origin header)
|
|
8
|
+
* - `(origin: string) => boolean` → custom predicate
|
|
9
|
+
*
|
|
10
|
+
* Default: `'*'`
|
|
11
|
+
*/
|
|
12
|
+
origin?: '*' | string | string[] | ((origin: string) => boolean);
|
|
13
|
+
/**
|
|
14
|
+
* HTTP methods allowed in CORS requests.
|
|
15
|
+
* Default: `['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']`
|
|
16
|
+
*/
|
|
17
|
+
methods?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Request headers the client is allowed to send.
|
|
20
|
+
* Default: `['Content-Type', 'Authorization', 'x-csrf-token']`
|
|
21
|
+
*/
|
|
22
|
+
allowHeaders?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Response headers that the browser may expose to the client-side script.
|
|
25
|
+
* Default: `[]` (none exposed beyond the CORS-safelisted headers)
|
|
26
|
+
*/
|
|
27
|
+
exposeHeaders?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether cross-origin requests may include credentials (cookies, auth headers).
|
|
30
|
+
* When true, `origin` must not be `'*'`.
|
|
31
|
+
* Default: `false`
|
|
32
|
+
*/
|
|
33
|
+
credentials?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* How long (in seconds) the preflight result may be cached.
|
|
36
|
+
* Default: `86400` (24h)
|
|
37
|
+
*/
|
|
38
|
+
maxAge?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface CorsPlugin {
|
|
41
|
+
/**
|
|
42
|
+
* Register on `app.onRequest()`.
|
|
43
|
+
* Handles OPTIONS preflight requests — returns a 204 with CORS headers directly,
|
|
44
|
+
* short-circuiting the pipeline (no route handler runs for OPTIONS).
|
|
45
|
+
*/
|
|
46
|
+
onRequest: OnRequestHook;
|
|
47
|
+
/**
|
|
48
|
+
* Register on `app.onResponse()`.
|
|
49
|
+
* Appends CORS headers to every response.
|
|
50
|
+
*/
|
|
51
|
+
onResponse: OnResponseHook;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* corsPlugin — adds CORS headers to responses and handles preflight OPTIONS requests.
|
|
55
|
+
*
|
|
56
|
+
* Usage:
|
|
57
|
+
* const cors = corsPlugin({ origin: 'https://app.example.com', credentials: true })
|
|
58
|
+
* app.onRequest(cors.onRequest)
|
|
59
|
+
* app.onResponse(cors.onResponse)
|
|
60
|
+
*
|
|
61
|
+
* Preflight (OPTIONS) requests are short-circuited with a 204 — no route handler
|
|
62
|
+
* runs. All other requests receive CORS headers in onResponse.
|
|
63
|
+
*/
|
|
64
|
+
export declare function corsPlugin(options?: CorsOptions): CorsPlugin;
|
|
65
|
+
//# sourceMappingURL=cors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../src/app/cors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK5D,MAAM,WAAW,WAAW;IAC1B;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,GAAG,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAA;IAEhE;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IAEvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IAExB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAID,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,SAAS,EAAE,aAAa,CAAA;IACxB;;;OAGG;IACH,UAAU,EAAE,cAAc,CAAA;CAC3B;AAyBD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,WAAgB,GAAG,UAAU,CAsEhE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { OnRequestHook, OnResponseHook } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Constant-time string comparison to prevent timing attacks.
|
|
4
|
+
* Returns false immediately on length mismatch (length is not secret).
|
|
5
|
+
* XORs all character codes and accumulates into a single result so the
|
|
6
|
+
* comparison time is proportional to the string length, not the first mismatch.
|
|
7
|
+
*/
|
|
8
|
+
export declare function timingSafeEqual(a: string, b: string): boolean;
|
|
9
|
+
export interface CsrfOptions {
|
|
10
|
+
/** Cookie name that holds the CSRF token. Default: 'csrf_token' */
|
|
11
|
+
cookieName?: string;
|
|
12
|
+
/** Request header that must carry the token on state-changing requests. Default: 'x-csrf-token' */
|
|
13
|
+
headerName?: string;
|
|
14
|
+
/** Cookie Max-Age in seconds. Default: 86400 (24h) */
|
|
15
|
+
maxAge?: number;
|
|
16
|
+
/** Restrict cookie to HTTPS. Default: true (set false for local development) */
|
|
17
|
+
secure?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface CsrfPlugin {
|
|
20
|
+
/**
|
|
21
|
+
* Register on app.onRequest() or module.onRequest().
|
|
22
|
+
* Validates the CSRF token on state-changing methods (POST/PUT/PATCH/DELETE).
|
|
23
|
+
* Returns a 403 response on mismatch — short-circuits the request lifecycle.
|
|
24
|
+
*/
|
|
25
|
+
onRequest: OnRequestHook;
|
|
26
|
+
/**
|
|
27
|
+
* Register on app.onResponse() or module.onResponse().
|
|
28
|
+
* Sets a new CSRF token cookie on responses to safe methods (GET/HEAD/OPTIONS)
|
|
29
|
+
* when no valid token cookie exists yet.
|
|
30
|
+
*/
|
|
31
|
+
onResponse: OnResponseHook;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* csrfPlugin — Double-Submit Cookie pattern. Stateless, no store required.
|
|
35
|
+
*
|
|
36
|
+
* Usage:
|
|
37
|
+
* const csrf = csrfPlugin()
|
|
38
|
+
* app.onRequest(csrf.onRequest)
|
|
39
|
+
* app.onResponse(csrf.onResponse)
|
|
40
|
+
*
|
|
41
|
+
* How it works:
|
|
42
|
+
* 1. On GET/HEAD/OPTIONS — onResponse sets a readable cookie (httpOnly: false)
|
|
43
|
+
* so the client-side JS can read the token.
|
|
44
|
+
* 2. On POST/PUT/PATCH/DELETE — onRequest reads the cookie value and compares
|
|
45
|
+
* it to the x-csrf-token request header. Mismatch or missing → 403.
|
|
46
|
+
*
|
|
47
|
+
* The Double-Submit Cookie pattern is stateless: the server never stores tokens.
|
|
48
|
+
* Security relies on the same-origin policy: a cross-origin attacker can read
|
|
49
|
+
* neither the cookie nor the custom header value.
|
|
50
|
+
*/
|
|
51
|
+
export declare function csrfPlugin(options?: CsrfOptions): CsrfPlugin;
|
|
52
|
+
//# sourceMappingURL=csrf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csrf.d.ts","sourceRoot":"","sources":["../../src/app/csrf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAUrE;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAO7D;AAaD,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mGAAmG;IACnG,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAID,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,SAAS,EAAE,aAAa,CAAA;IACxB;;;;OAIG;IACH,UAAU,EAAE,cAAc,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,WAAgB,GAAG,UAAU,CAiDhE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { OnRequestHook } from './types';
|
|
2
|
+
export interface HealthCheck {
|
|
3
|
+
(): Promise<{
|
|
4
|
+
ok: boolean;
|
|
5
|
+
details?: Record<string, unknown>;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
|
8
|
+
export interface HealthPluginOptions {
|
|
9
|
+
/** Path for the liveness endpoint. Default: '/health' */
|
|
10
|
+
path?: string;
|
|
11
|
+
/** Path for the readiness endpoint. Default: '/ready' */
|
|
12
|
+
readyPath?: string;
|
|
13
|
+
/** Named checks to run for the readiness endpoint. */
|
|
14
|
+
checks?: Record<string, HealthCheck>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* healthPlugin — adds /health and /ready endpoints for Kubernetes/load balancers.
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* const health = healthPlugin({ checks: { db: async () => ({ ok: true }) } })
|
|
21
|
+
* app.onRequest(health.onRequest)
|
|
22
|
+
*
|
|
23
|
+
* GET /health → 200 { status: 'ok', uptime: number }
|
|
24
|
+
* Always returns 200. Use for liveness probes (is the process alive?).
|
|
25
|
+
*
|
|
26
|
+
* GET /ready → 200 { status: 'ready', checks: { db: { ok: true } } }
|
|
27
|
+
* → 503 { status: 'not_ready', checks: { db: { ok: false, error: '...' } } }
|
|
28
|
+
* Runs all checks. Use for readiness probes (is the service ready to serve traffic?).
|
|
29
|
+
*
|
|
30
|
+
* The health endpoints are intercepted in the onRequest phase — before auth plugins run.
|
|
31
|
+
*/
|
|
32
|
+
export interface HealthPlugin {
|
|
33
|
+
onRequest: OnRequestHook;
|
|
34
|
+
}
|
|
35
|
+
export declare function healthPlugin(options?: HealthPluginOptions): HealthPlugin;
|
|
36
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/app/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAK5C,MAAM,WAAW,WAAW;IAC1B,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAA;CAChE;AAED,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CACrC;AAID;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,aAAa,CAAA;CACzB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CA4C5E"}
|