@venizia/ignis 0.4.8-8 → 0.4.8-9

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.
Files changed (34) hide show
  1. package/README.md +1 -0
  2. package/dist/esm/components/index.d.ts +1 -0
  3. package/dist/esm/components/index.js +1 -0
  4. package/dist/esm/components/index.js.map +1 -1
  5. package/dist/esm/components/server-info/common/constants.d.ts +6 -0
  6. package/dist/esm/components/server-info/common/constants.js +6 -0
  7. package/dist/esm/components/server-info/common/constants.js.map +1 -0
  8. package/dist/esm/components/server-info/common/index.d.ts +5 -0
  9. package/dist/esm/components/server-info/common/index.js +5 -0
  10. package/dist/esm/components/server-info/common/index.js.map +1 -0
  11. package/dist/esm/components/server-info/common/keys.d.ts +5 -0
  12. package/dist/esm/components/server-info/common/keys.js +5 -0
  13. package/dist/esm/components/server-info/common/keys.js.map +1 -0
  14. package/dist/esm/components/server-info/common/rest-paths.d.ts +5 -0
  15. package/dist/esm/components/server-info/common/rest-paths.js +5 -0
  16. package/dist/esm/components/server-info/common/rest-paths.js.map +1 -0
  17. package/dist/esm/components/server-info/common/types.d.ts +68 -0
  18. package/dist/esm/components/server-info/common/types.js +2 -0
  19. package/dist/esm/components/server-info/common/types.js.map +1 -0
  20. package/dist/esm/components/server-info/component.d.ts +31 -0
  21. package/dist/esm/components/server-info/component.js +87 -0
  22. package/dist/esm/components/server-info/component.js.map +1 -0
  23. package/dist/esm/components/server-info/controller.d.ts +14 -0
  24. package/dist/esm/components/server-info/controller.js +68 -0
  25. package/dist/esm/components/server-info/controller.js.map +1 -0
  26. package/dist/esm/components/server-info/index.d.ts +5 -0
  27. package/dist/esm/components/server-info/index.js +5 -0
  28. package/dist/esm/components/server-info/index.js.map +1 -0
  29. package/dist/esm/components/server-info/reporter.d.ts +25 -0
  30. package/dist/esm/components/server-info/reporter.js +68 -0
  31. package/dist/esm/components/server-info/reporter.js.map +1 -0
  32. package/dist/presets/app/preset.json +1 -1
  33. package/dist/presets/lib/preset.json +2 -2
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -110,6 +110,7 @@ Register a component with `this.component(...)` in `preConfigure()`.
110
110
  |---|---|---|
111
111
  | `ApiReferenceComponent` | `@venizia/ignis` | The OpenAPI document and a Scalar or Swagger UI explorer (`@scalar/hono-api-reference` or `@hono/swagger-ui`) |
112
112
  | `HealthCheckComponent` | `@venizia/ignis` | `GET /health`, `POST /health/ping`, and `GET /health/stats` (closed outside development unless you enable it) |
113
+ | `ServerInfoComponent` | `@venizia/ignis` | `GET /server/info/time`, a public route that carries only data safe to publish (the server clock) |
113
114
  | `AuthenticateComponent` | `@venizia/ignis` | JWT, Basic, and service-to-service authentication strategies |
114
115
  | `AuthorizeComponent` | `@venizia/ignis` | Casbin-based authorization (`casbin`) |
115
116
  | `RequestTrackerComponent` | `@venizia/ignis` | Logs each request and response - registered for you by `BaseApplication` |
@@ -1,5 +1,6 @@
1
1
  export * from './auth/index.js';
2
2
  export * from './health-check/index.js';
3
+ export * from './server-info/index.js';
3
4
  export * from './request-tracker/index.js';
4
5
  export * from './api-reference/index.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
1
  export * from './auth/index.js';
2
2
  export * from './health-check/index.js';
3
+ export * from './server-info/index.js';
3
4
  export * from './request-tracker/index.js';
4
5
  export * from './api-reference/index.js';
5
6
  // Excluded from the barrel - import directly from the subpath: mail, socket-io, static-asset, websocket
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,wGAAwG","sourcesContent":["export * from './auth';\nexport * from './health-check';\nexport * from './request-tracker';\nexport * from './api-reference';\n\n// Excluded from the barrel - import directly from the subpath: mail, socket-io, static-asset, websocket\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,wGAAwG","sourcesContent":["export * from './auth';\nexport * from './health-check';\nexport * from './server-info';\nexport * from './request-tracker';\nexport * from './api-reference';\n\n// Excluded from the barrel - import directly from the subpath: mail, socket-io, static-asset, websocket\n"]}
@@ -0,0 +1,6 @@
1
+ /** `Cache-Control` values the server info controller sends. */
2
+ export declare class ServerInfoCacheControls {
3
+ /** A cached server time is a wrong server time: no cache and no service worker may store the answer. */
4
+ static readonly NO_STORE = "no-store";
5
+ }
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,6 @@
1
+ /** `Cache-Control` values the server info controller sends. */
2
+ export class ServerInfoCacheControls {
3
+ /** A cached server time is a wrong server time: no cache and no service worker may store the answer. */
4
+ static { this.NO_STORE = 'no-store'; }
5
+ }
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/constants.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,OAAO,uBAAuB;IAClC,wGAAwG;aACxF,aAAQ,GAAG,UAAU,CAAC","sourcesContent":["/** `Cache-Control` values the server info controller sends. */\nexport class ServerInfoCacheControls {\n /** A cached server time is a wrong server time: no cache and no service worker may store the answer. */\n static readonly NO_STORE = 'no-store';\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './constants.js';
2
+ export * from './keys.js';
3
+ export * from './rest-paths.js';
4
+ export * from './types.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from './constants.js';
2
+ export * from './keys.js';
3
+ export * from './rest-paths.js';
4
+ export * from './types.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC","sourcesContent":["export * from './constants';\nexport * from './keys';\nexport * from './rest-paths';\nexport * from './types';\n"]}
@@ -0,0 +1,5 @@
1
+ /** Container keys of the server info component. */
2
+ export declare class ServerInfoBindingKeys {
3
+ static readonly SERVER_INFO_OPTIONS = "@app/server-info/options";
4
+ }
5
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Container keys of the server info component. */
2
+ export class ServerInfoBindingKeys {
3
+ static { this.SERVER_INFO_OPTIONS = '@app/server-info/options'; }
4
+ }
5
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/keys.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,OAAO,qBAAqB;aAChB,wBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/** Container keys of the server info component. */\nexport class ServerInfoBindingKeys {\n static readonly SERVER_INFO_OPTIONS = '@app/server-info/options';\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /** Routes of the server info controller, relative to the configured base path. */
2
+ export declare class ServerInfoRestPaths {
3
+ static readonly TIME = "/time";
4
+ }
5
+ //# sourceMappingURL=rest-paths.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Routes of the server info controller, relative to the configured base path. */
2
+ export class ServerInfoRestPaths {
3
+ static { this.TIME = '/time'; }
4
+ }
5
+ //# sourceMappingURL=rest-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-paths.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/rest-paths.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,OAAO,mBAAmB;aACd,SAAI,GAAG,OAAO,CAAC","sourcesContent":["/** Routes of the server info controller, relative to the configured base path. */\nexport class ServerInfoRestPaths {\n static readonly TIME = '/time';\n}\n"]}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Options of `ServerInfoComponent`, bound at `ServerInfoBindingKeys.SERVER_INFO_OPTIONS`.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { ServerInfoBindingKeys, type BaseApplication, type IServerInfoOptions } from '@venizia/ignis';
7
+ *
8
+ * export const bindServerInfo = (application: BaseApplication) => {
9
+ * application
10
+ * .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
11
+ * .toValue({ restOptions: { path: '/clock' } });
12
+ * };
13
+ * ```
14
+ */
15
+ export interface IServerInfoOptions {
16
+ /** Partially-filled bindings are accepted; every missing field falls back to its default. */
17
+ restOptions?: {
18
+ /**
19
+ * Base path the server info routes mount under. The routes are public by design.
20
+ *
21
+ * @default '/server/info'
22
+ */
23
+ path?: string;
24
+ };
25
+ }
26
+ /**
27
+ * Body of `GET <path>/time`. Every field comes from ONE captured instant, so they never disagree.
28
+ *
29
+ * @example
30
+ * ```json
31
+ * {
32
+ * "server": {
33
+ * "date": "2026-11-10",
34
+ * "time": "15:00:00.123",
35
+ * "epoch": 1794297600123,
36
+ * "iso": "2026-11-10T15:00:00.123+07:00"
37
+ * },
38
+ * "tz": "Asia/Ho_Chi_Minh",
39
+ * "utc": { "offset": "+07:00", "minutes": 420, "iso": "2026-11-10T08:00:00.123Z" }
40
+ * }
41
+ * ```
42
+ */
43
+ export interface IServerTime {
44
+ server: {
45
+ /** Calendar date in the server time zone, `YYYY-MM-DD`. */
46
+ date: string;
47
+ /** Wall-clock time in the server time zone, `HH:mm:ss.SSS`. */
48
+ time: string;
49
+ /** Milliseconds since 1970-01-01T00:00:00Z (`Date.now()`). Compute clock skew from this field. */
50
+ epoch: number;
51
+ /** `date`, `time` and `utc.offset` joined as ISO-8601, e.g. `2026-11-10T15:00:00.123+07:00`. */
52
+ iso: string;
53
+ };
54
+ /** IANA time zone the server process resolved, e.g. `Asia/Ho_Chi_Minh`. */
55
+ tz: string;
56
+ utc: {
57
+ /** Offset of `tz` from UTC at response time, `+07:00` style. */
58
+ offset: string;
59
+ /**
60
+ * The same offset in minutes, POSITIVE east of UTC (`420` for `+07:00`). This is the opposite
61
+ * sign of JavaScript's `Date.prototype.getTimezoneOffset()`.
62
+ */
63
+ minutes: number;
64
+ /** The same instant in UTC, ISO-8601 with milliseconds (`toISOString()`). */
65
+ iso: string;
66
+ };
67
+ }
68
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/server-info/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options of `ServerInfoComponent`, bound at `ServerInfoBindingKeys.SERVER_INFO_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { ServerInfoBindingKeys, type BaseApplication, type IServerInfoOptions } from '@venizia/ignis';\n *\n * export const bindServerInfo = (application: BaseApplication) => {\n * application\n * .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })\n * .toValue({ restOptions: { path: '/clock' } });\n * };\n * ```\n */\nexport interface IServerInfoOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: {\n /**\n * Base path the server info routes mount under. The routes are public by design.\n *\n * @default '/server/info'\n */\n path?: string;\n };\n}\n\n/**\n * Body of `GET <path>/time`. Every field comes from ONE captured instant, so they never disagree.\n *\n * @example\n * ```json\n * {\n * \"server\": {\n * \"date\": \"2026-11-10\",\n * \"time\": \"15:00:00.123\",\n * \"epoch\": 1794297600123,\n * \"iso\": \"2026-11-10T15:00:00.123+07:00\"\n * },\n * \"tz\": \"Asia/Ho_Chi_Minh\",\n * \"utc\": { \"offset\": \"+07:00\", \"minutes\": 420, \"iso\": \"2026-11-10T08:00:00.123Z\" }\n * }\n * ```\n */\nexport interface IServerTime {\n server: {\n /** Calendar date in the server time zone, `YYYY-MM-DD`. */\n date: string;\n /** Wall-clock time in the server time zone, `HH:mm:ss.SSS`. */\n time: string;\n /** Milliseconds since 1970-01-01T00:00:00Z (`Date.now()`). Compute clock skew from this field. */\n epoch: number;\n /** `date`, `time` and `utc.offset` joined as ISO-8601, e.g. `2026-11-10T15:00:00.123+07:00`. */\n iso: string;\n };\n /** IANA time zone the server process resolved, e.g. `Asia/Ho_Chi_Minh`. */\n tz: string;\n utc: {\n /** Offset of `tz` from UTC at response time, `+07:00` style. */\n offset: string;\n /**\n * The same offset in minutes, POSITIVE east of UTC (`420` for `+07:00`). This is the opposite\n * sign of JavaScript's `Date.prototype.getTimezoneOffset()`.\n */\n minutes: number;\n /** The same instant in UTC, ISO-8601 with milliseconds (`toISOString()`). */\n iso: string;\n };\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { type BaseApplication } from '../../base/applications/index.js';
2
+ import { BaseComponent } from '@venizia/ignis-kernel';
3
+ import { type IServerInfoOptions } from './common/index.js';
4
+ /**
5
+ * Mounts the server info controller: `GET <path>/time`, public, no authentication.
6
+ *
7
+ * The rule of this component: it carries only data that is safe to publish and does not help an
8
+ * attacker. No version, runtime, pid, memory or environment - those stay in the gated
9
+ * `/health/stats`. It is separate from `HealthCheckComponent` on purpose: operators may lock
10
+ * `/health/*` away, and client features must not depend on it. `/server/info/*` is public by design.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { BaseApplication, ServerInfoComponent, type IServerInfoOptions } from '@venizia/ignis';
15
+ *
16
+ * abstract class App extends BaseApplication {
17
+ * preConfigure(): void {
18
+ * const options: IServerInfoOptions = { restOptions: { path: '/clock' } };
19
+ * this.component(ServerInfoComponent, { options });
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ export declare class ServerInfoComponent extends BaseComponent<IServerInfoOptions> {
25
+ private application;
26
+ constructor(application: BaseApplication);
27
+ /** Options given at the call site win over anything bound earlier, as in `HealthCheckComponent`. */
28
+ configure(opts?: IServerInfoOptions): Promise<void>;
29
+ binding(): void;
30
+ }
31
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1,87 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ var ServerInfoComponent_1;
14
+ import { controller, inject } from '../../base/metadata/index.js';
15
+ import { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';
16
+ import { ServerInfoBindingKeys } from './common/index.js';
17
+ import { ServerInfoController } from './controller.js';
18
+ const DEFAULT_REST_PATH = '/server/info';
19
+ const DEFAULT_OPTIONS = {
20
+ restOptions: { path: DEFAULT_REST_PATH },
21
+ };
22
+ /**
23
+ * Mounts the server info controller: `GET <path>/time`, public, no authentication.
24
+ *
25
+ * The rule of this component: it carries only data that is safe to publish and does not help an
26
+ * attacker. No version, runtime, pid, memory or environment - those stay in the gated
27
+ * `/health/stats`. It is separate from `HealthCheckComponent` on purpose: operators may lock
28
+ * `/health/*` away, and client features must not depend on it. `/server/info/*` is public by design.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { BaseApplication, ServerInfoComponent, type IServerInfoOptions } from '@venizia/ignis';
33
+ *
34
+ * abstract class App extends BaseApplication {
35
+ * preConfigure(): void {
36
+ * const options: IServerInfoOptions = { restOptions: { path: '/clock' } };
37
+ * this.component(ServerInfoComponent, { options });
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ let ServerInfoComponent = ServerInfoComponent_1 = class ServerInfoComponent extends BaseComponent {
43
+ constructor(application) {
44
+ super({
45
+ scope: ServerInfoComponent_1.name,
46
+ initDefault: { enable: true, container: application },
47
+ bindings: {
48
+ [ServerInfoBindingKeys.SERVER_INFO_OPTIONS]: Binding.bind({
49
+ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,
50
+ }).toValue(DEFAULT_OPTIONS),
51
+ },
52
+ });
53
+ this.application = application;
54
+ }
55
+ /** Options given at the call site win over anything bound earlier, as in `HealthCheckComponent`. */
56
+ async configure(opts) {
57
+ // The base short-circuits a second call; binding before that check would swap the options
58
+ // under routes that were already mounted from the first ones.
59
+ if (this.isConfigured) {
60
+ return;
61
+ }
62
+ if (opts !== undefined) {
63
+ this.application
64
+ .bind({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })
65
+ .toValue(opts);
66
+ }
67
+ await super.configure(opts);
68
+ }
69
+ binding() {
70
+ const options = this.application.get({
71
+ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,
72
+ isOptional: true,
73
+ });
74
+ // A partially filled options binding (env/config driven) must not take the app down at boot.
75
+ const path = options?.restOptions?.path ?? DEFAULT_REST_PATH;
76
+ // `@controller` writes the PATH onto this shared class in the process-wide MetadataRegistry;
77
+ // two applications booted concurrently with different paths would race, as in health-check.
78
+ Reflect.decorate([controller({ path })], ServerInfoController);
79
+ this.application.controller(ServerInfoController);
80
+ }
81
+ };
82
+ ServerInfoComponent = ServerInfoComponent_1 = __decorate([
83
+ __param(0, inject({ key: CoreBindings.APPLICATION_INSTANCE })),
84
+ __metadata("design:paramtypes", [Function])
85
+ ], ServerInfoComponent);
86
+ export { ServerInfoComponent };
87
+ //# sourceMappingURL=component.js.map
@@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B,EAAE,CAAC;iBAC5E,OAAO,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,MAAM,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAEQ,OAAO;QACd,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAqB;YACvD,GAAG,EAAE,qBAAqB,CAAC,mBAAmB;YAC9C,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,6FAA6F;QAC7F,MAAM,IAAI,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,IAAI,iBAAiB,CAAC;QAE7D,6FAA6F;QAC7F,4FAA4F;QAC5F,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC/D,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACpD,CAAC;CACF,CAAA;AA9CY,mBAAmB;IAE3B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,mBAAmB,CA8C/B","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { controller, inject } from '@/base/metadata';\nimport { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';\nimport { ServerInfoBindingKeys, type IServerInfoOptions } from './common';\nimport { ServerInfoController } from './controller';\n\nconst DEFAULT_REST_PATH = '/server/info';\nconst DEFAULT_OPTIONS: IServerInfoOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\n/**\n * Mounts the server info controller: `GET <path>/time`, public, no authentication.\n *\n * The rule of this component: it carries only data that is safe to publish and does not help an\n * attacker. No version, runtime, pid, memory or environment - those stay in the gated\n * `/health/stats`. It is separate from `HealthCheckComponent` on purpose: operators may lock\n * `/health/*` away, and client features must not depend on it. `/server/info/*` is public by design.\n *\n * @example\n * ```typescript\n * import { BaseApplication, ServerInfoComponent, type IServerInfoOptions } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * const options: IServerInfoOptions = { restOptions: { path: '/clock' } };\n * this.component(ServerInfoComponent, { options });\n * }\n * }\n * ```\n */\nexport class ServerInfoComponent extends BaseComponent<IServerInfoOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: ServerInfoComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [ServerInfoBindingKeys.SERVER_INFO_OPTIONS]: Binding.bind<IServerInfoOptions>({\n key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /** Options given at the call site win over anything bound earlier, as in `HealthCheckComponent`. */\n override async configure(opts?: IServerInfoOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application\n .bind<IServerInfoOptions>({ key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS })\n .toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override binding(): void {\n const options = this.application.get<IServerInfoOptions>({\n key: ServerInfoBindingKeys.SERVER_INFO_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = options?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // `@controller` writes the PATH onto this shared class in the process-wide MetadataRegistry;\n // two applications booted concurrently with different paths would race, as in health-check.\n Reflect.decorate([controller({ path })], ServerInfoController);\n this.application.controller(ServerInfoController);\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { BaseRestController } from '../../base/controllers/index.js';
2
+ import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
3
+ /**
4
+ * Serves `GET <path>/time`, a PUBLIC route with no authentication.
5
+ *
6
+ * Everything this controller answers must be safe to publish and must not help an attacker: a
7
+ * clock and a time zone, nothing else. No version, runtime, pid, memory or environment - those
8
+ * belong to the gated `/health/stats`. A new route here needs that same test.
9
+ */
10
+ export declare class ServerInfoController extends BaseRestController {
11
+ constructor();
12
+ binding(): ValueOrPromise<void>;
13
+ }
14
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1,68 @@
1
+ import { BaseRestController } from '../../base/controllers/index.js';
2
+ import { OpenApiResponses } from '@venizia/ignis-kernel';
3
+ import { z } from '@hono/zod-openapi';
4
+ import { HTTP } from '@venizia/ignis-helpers/common';
5
+ import { ServerInfoCacheControls, ServerInfoRestPaths } from './common/index.js';
6
+ import { ServerInfoReporter } from './reporter.js';
7
+ const RouteConfigs = {
8
+ TIME: {
9
+ method: HTTP.Methods.GET,
10
+ path: ServerInfoRestPaths.TIME,
11
+ responses: OpenApiResponses.jsonResponse({
12
+ schema: z
13
+ .object({
14
+ server: z.object({
15
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
16
+ time: z.string().regex(/^\d{2}:\d{2}:\d{2}\.\d{3}$/),
17
+ epoch: z.number().int(),
18
+ iso: z.iso.datetime({ offset: true }),
19
+ }),
20
+ tz: z.string(),
21
+ utc: z.object({
22
+ offset: z.string().regex(/^[+-]\d{2}:\d{2}$/),
23
+ minutes: z.number().int(),
24
+ iso: z.iso.datetime(),
25
+ }),
26
+ })
27
+ .openapi({
28
+ description: 'Server time',
29
+ examples: [
30
+ {
31
+ server: {
32
+ date: '2026-11-10',
33
+ time: '15:00:00.123',
34
+ epoch: 1794297600123,
35
+ iso: '2026-11-10T15:00:00.123+07:00',
36
+ },
37
+ tz: 'Asia/Ho_Chi_Minh',
38
+ utc: { offset: '+07:00', minutes: 420, iso: '2026-11-10T08:00:00.123Z' },
39
+ },
40
+ ],
41
+ }),
42
+ description: 'The server clock: local date and time, epoch milliseconds, time zone, UTC offset and the UTC instant',
43
+ }),
44
+ },
45
+ };
46
+ /**
47
+ * Serves `GET <path>/time`, a PUBLIC route with no authentication.
48
+ *
49
+ * Everything this controller answers must be safe to publish and must not help an attacker: a
50
+ * clock and a time zone, nothing else. No version, runtime, pid, memory or environment - those
51
+ * belong to the gated `/health/stats`. A new route here needs that same test.
52
+ */
53
+ export class ServerInfoController extends BaseRestController {
54
+ constructor() {
55
+ super({ scope: ServerInfoController.name });
56
+ this.definitions = RouteConfigs;
57
+ }
58
+ binding() {
59
+ this.bindRoute({ configs: RouteConfigs.TIME }).to({
60
+ handler: (context) => {
61
+ // A cached time is a wrong time; without this a cache or a service worker may serve it stale.
62
+ context.header(HTTP.Headers.CACHE_CONTROL, ServerInfoCacheControls.NO_STORE);
63
+ return context.json(ServerInfoReporter.buildTime(), HTTP.ResultCodes.RS_2.Ok);
64
+ },
65
+ });
66
+ }
67
+ }
68
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/components/server-info/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE;QACJ,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;QACxB,IAAI,EAAE,mBAAmB,CAAC,IAAI;QAC9B,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC;YACvC,MAAM,EAAE,CAAC;iBACN,MAAM,CAAC;gBACN,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;oBACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,CA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CAAC,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE;gBACnB,8FAA8F;gBAC9F,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CAAC;gBAE7E,OAAO,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChF,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { BaseRestController } from '@/base/controllers';\nimport { OpenApiResponses } from '@venizia/ignis-kernel';\nimport { z } from '@hono/zod-openapi';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { ServerInfoCacheControls, ServerInfoRestPaths } from './common';\nimport { ServerInfoReporter } from './reporter';\n\nconst RouteConfigs = {\n TIME: {\n method: HTTP.Methods.GET,\n path: ServerInfoRestPaths.TIME,\n responses: OpenApiResponses.jsonResponse({\n schema: z\n .object({\n server: z.object({\n date: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/),\n time: z.string().regex(/^\\d{2}:\\d{2}:\\d{2}\\.\\d{3}$/),\n epoch: z.number().int(),\n iso: z.iso.datetime({ offset: true }),\n }),\n tz: z.string(),\n utc: z.object({\n offset: z.string().regex(/^[+-]\\d{2}:\\d{2}$/),\n minutes: z.number().int(),\n iso: z.iso.datetime(),\n }),\n })\n .openapi({\n description: 'Server time',\n examples: [\n {\n server: {\n date: '2026-11-10',\n time: '15:00:00.123',\n epoch: 1794297600123,\n iso: '2026-11-10T15:00:00.123+07:00',\n },\n tz: 'Asia/Ho_Chi_Minh',\n utc: { offset: '+07:00', minutes: 420, iso: '2026-11-10T08:00:00.123Z' },\n },\n ],\n }),\n description:\n 'The server clock: local date and time, epoch milliseconds, time zone, UTC offset and the UTC instant',\n }),\n },\n} as const;\n\n/**\n * Serves `GET <path>/time`, a PUBLIC route with no authentication.\n *\n * Everything this controller answers must be safe to publish and must not help an attacker: a\n * clock and a time zone, nothing else. No version, runtime, pid, memory or environment - those\n * belong to the gated `/health/stats`. A new route here needs that same test.\n */\nexport class ServerInfoController extends BaseRestController {\n constructor() {\n super({ scope: ServerInfoController.name });\n\n this.definitions = RouteConfigs;\n }\n\n override binding(): ValueOrPromise<void> {\n this.bindRoute({ configs: RouteConfigs.TIME }).to({\n handler: (context) => {\n // A cached time is a wrong time; without this a cache or a service worker may serve it stale.\n context.header(HTTP.Headers.CACHE_CONTROL, ServerInfoCacheControls.NO_STORE);\n\n return context.json(ServerInfoReporter.buildTime(), HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './common/index.js';
2
+ export * from './component.js';
3
+ export * from './controller.js';
4
+ export * from './reporter.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from './common/index.js';
2
+ export * from './component.js';
3
+ export * from './controller.js';
4
+ export * from './reporter.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/server-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC","sourcesContent":["export * from './common';\nexport * from './component';\nexport * from './controller';\nexport * from './reporter';\n"]}
@@ -0,0 +1,25 @@
1
+ import type { IServerTime } from './common/index.js';
2
+ /** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */
3
+ export declare class ServerInfoReporter {
4
+ private static readonly MINUTES_PER_HOUR;
5
+ private static readonly MS_PER_SECOND;
6
+ private static readonly MS_PER_MINUTE;
7
+ private static readonly formatters;
8
+ private static getFormatter;
9
+ /** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */
10
+ static formatUtcOffset(opts: {
11
+ minutes: number;
12
+ }): string;
13
+ /** The process time zone as the runtime resolved it (`TZ`, or the host setting). */
14
+ static resolveTimeZone(): string;
15
+ /**
16
+ * Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the
17
+ * same instant. The offset is read from the zone AT that instant (a DST change moves it), not
18
+ * from the zone's standard offset.
19
+ */
20
+ static buildTime(opts?: {
21
+ now?: Date;
22
+ timeZone?: string;
23
+ }): IServerTime;
24
+ }
25
+ //# sourceMappingURL=reporter.d.ts.map
@@ -0,0 +1,68 @@
1
+ /** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */
2
+ export class ServerInfoReporter {
3
+ static { this.MINUTES_PER_HOUR = 60; }
4
+ static { this.MS_PER_SECOND = 1000; }
5
+ static { this.MS_PER_MINUTE = 60_000; }
6
+ static { this.formatters = new Map(); }
7
+ static getFormatter(opts) {
8
+ const cached = ServerInfoReporter.formatters.get(opts.timeZone);
9
+ if (cached) {
10
+ return cached;
11
+ }
12
+ // `h23` keeps midnight as `00`; the default `h24` of some locales prints `24`.
13
+ const formatter = new Intl.DateTimeFormat('en-US', {
14
+ timeZone: opts.timeZone,
15
+ hourCycle: 'h23',
16
+ year: 'numeric',
17
+ month: '2-digit',
18
+ day: '2-digit',
19
+ hour: '2-digit',
20
+ minute: '2-digit',
21
+ second: '2-digit',
22
+ });
23
+ ServerInfoReporter.formatters.set(opts.timeZone, formatter);
24
+ return formatter;
25
+ }
26
+ /** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */
27
+ static formatUtcOffset(opts) {
28
+ const sign = opts.minutes < 0 ? '-' : '+';
29
+ const absolute = Math.abs(opts.minutes);
30
+ const hh = String(Math.trunc(absolute / ServerInfoReporter.MINUTES_PER_HOUR)).padStart(2, '0');
31
+ const mm = String(absolute % ServerInfoReporter.MINUTES_PER_HOUR).padStart(2, '0');
32
+ return `${sign}${hh}:${mm}`;
33
+ }
34
+ /** The process time zone as the runtime resolved it (`TZ`, or the host setting). */
35
+ static resolveTimeZone() {
36
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
37
+ }
38
+ /**
39
+ * Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the
40
+ * same instant. The offset is read from the zone AT that instant (a DST change moves it), not
41
+ * from the zone's standard offset.
42
+ */
43
+ static buildTime(opts) {
44
+ const now = opts?.now ?? new Date();
45
+ const tz = opts?.timeZone ?? ServerInfoReporter.resolveTimeZone();
46
+ const epoch = now.getTime();
47
+ const parts = {};
48
+ for (const part of ServerInfoReporter.getFormatter({ timeZone: tz }).formatToParts(now)) {
49
+ parts[part.type] = part.value;
50
+ }
51
+ const date = `${parts.year}-${parts.month}-${parts.day}`;
52
+ const ms = String(((epoch % ServerInfoReporter.MS_PER_SECOND) + ServerInfoReporter.MS_PER_SECOND) %
53
+ ServerInfoReporter.MS_PER_SECOND).padStart(3, '0');
54
+ const time = `${parts.hour}:${parts.minute}:${parts.second}.${ms}`;
55
+ // The wall clock, read back as if it were UTC, minus the true instant (both cut to the
56
+ // second) is the zone's offset. Intl has no offset field that is portable across runtimes.
57
+ const wallAsUtc = Date.UTC(Number(parts.year), Number(parts.month) - 1, Number(parts.day), Number(parts.hour), Number(parts.minute), Number(parts.second));
58
+ const epochSecond = Math.floor(epoch / ServerInfoReporter.MS_PER_SECOND) * ServerInfoReporter.MS_PER_SECOND;
59
+ const minutes = (wallAsUtc - epochSecond) / ServerInfoReporter.MS_PER_MINUTE;
60
+ const offset = ServerInfoReporter.formatUtcOffset({ minutes });
61
+ return {
62
+ server: { date, time, epoch, iso: `${date}T${time}${offset}` },
63
+ tz,
64
+ utc: { offset, minutes, iso: now.toISOString() },
65
+ };
66
+ }
67
+ }
68
+ //# sourceMappingURL=reporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/components/server-info/reporter.ts"],"names":[],"mappings":"AAEA,yGAAyG;AACzG,MAAM,OAAO,kBAAkB;aACL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C3F,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CACxB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAClB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EACvB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EACjB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAClB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EACpB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CACrB,CAAC;QACF,MAAM,WAAW,GACf,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,kBAAkB,CAAC,aAAa,CAAC,GAAG,kBAAkB,CAAC,aAAa,CAAC;QAC1F,MAAM,OAAO,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,kBAAkB,CAAC,aAAa,CAAC;QAC7E,MAAM,MAAM,GAAG,kBAAkB,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAE/D,OAAO;YACL,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,IAAI,GAAG,MAAM,EAAE,EAAE;YAC9D,EAAE;YACF,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE;SACjD,CAAC;IACJ,CAAC","sourcesContent":["import type { IServerTime } from './common';\n\n/** Assembles what `GET <path>/time` answers. Reads the clock and the process time zone, nothing else. */\nexport class ServerInfoReporter {\n private static readonly MINUTES_PER_HOUR = 60;\n private static readonly MS_PER_SECOND = 1000;\n private static readonly MS_PER_MINUTE = 60_000;\n\n private static readonly formatters = new Map<string, Intl.DateTimeFormat>();\n\n private static getFormatter(opts: { timeZone: string }): Intl.DateTimeFormat {\n const cached = ServerInfoReporter.formatters.get(opts.timeZone);\n\n if (cached) {\n return cached;\n }\n\n // `h23` keeps midnight as `00`; the default `h24` of some locales prints `24`.\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: opts.timeZone,\n hourCycle: 'h23',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n });\n ServerInfoReporter.formatters.set(opts.timeZone, formatter);\n\n return formatter;\n }\n\n /** `+07:00` style text for an offset in minutes, positive east of UTC; `+00:00` for UTC itself. */\n static formatUtcOffset(opts: { minutes: number }): string {\n const sign = opts.minutes < 0 ? '-' : '+';\n const absolute = Math.abs(opts.minutes);\n const hh = String(Math.trunc(absolute / ServerInfoReporter.MINUTES_PER_HOUR)).padStart(2, '0');\n const mm = String(absolute % ServerInfoReporter.MINUTES_PER_HOUR).padStart(2, '0');\n\n return `${sign}${hh}:${mm}`;\n }\n\n /** The process time zone as the runtime resolved it (`TZ`, or the host setting). */\n static resolveTimeZone(): string {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /**\n * Every field comes from the one `now`, so `server.iso`, `server.epoch` and `utc.iso` name the\n * same instant. The offset is read from the zone AT that instant (a DST change moves it), not\n * from the zone's standard offset.\n */\n static buildTime(opts?: { now?: Date; timeZone?: string }): IServerTime {\n const now = opts?.now ?? new Date();\n const tz = opts?.timeZone ?? ServerInfoReporter.resolveTimeZone();\n const epoch = now.getTime();\n\n const parts: Record<string, string> = {};\n\n for (const part of ServerInfoReporter.getFormatter({ timeZone: tz }).formatToParts(now)) {\n parts[part.type] = part.value;\n }\n\n const date = `${parts.year}-${parts.month}-${parts.day}`;\n const ms = String(\n ((epoch % ServerInfoReporter.MS_PER_SECOND) + ServerInfoReporter.MS_PER_SECOND) %\n ServerInfoReporter.MS_PER_SECOND,\n ).padStart(3, '0');\n const time = `${parts.hour}:${parts.minute}:${parts.second}.${ms}`;\n\n // The wall clock, read back as if it were UTC, minus the true instant (both cut to the\n // second) is the zone's offset. Intl has no offset field that is portable across runtimes.\n const wallAsUtc = Date.UTC(\n Number(parts.year),\n Number(parts.month) - 1,\n Number(parts.day),\n Number(parts.hour),\n Number(parts.minute),\n Number(parts.second),\n );\n const epochSecond =\n Math.floor(epoch / ServerInfoReporter.MS_PER_SECOND) * ServerInfoReporter.MS_PER_SECOND;\n const minutes = (wallAsUtc - epochSecond) / ServerInfoReporter.MS_PER_MINUTE;\n const offset = ServerInfoReporter.formatUtcOffset({ minutes });\n\n return {\n server: { date, time, epoch, iso: `${date}T${time}${offset}` },\n tz,\n utc: { offset, minutes, iso: now.toISOString() },\n };\n }\n}\n"]}
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@hono/zod-openapi": "^1.6.3",
16
16
  "@scalar/hono-api-reference": "^0.12.13",
17
- "@venizia/ignis": "0.4.8-8",
17
+ "@venizia/ignis": "0.4.8-9",
18
18
  "@venizia/ignis-boot": "0.4.8-7",
19
19
  "@venizia/ignis-helpers": "0.4.8-7",
20
20
  "hono": "^4.13.13",
@@ -5,14 +5,14 @@
5
5
  "devDependencies": {
6
6
  "@types/bun": "^1.4.3",
7
7
  "@venizia/dev-configs": "0.4.8-5",
8
- "@venizia/ignis": "0.4.8-8",
8
+ "@venizia/ignis": "0.4.8-9",
9
9
  "eslint": "^10.13.0",
10
10
  "oxlint": "1.89.0",
11
11
  "oxlint-tsgolint": "7.0.2004",
12
12
  "typescript": "^6.0.3"
13
13
  },
14
14
  "peerDependencies": {
15
- "@venizia/ignis": "0.4.8-8"
15
+ "@venizia/ignis": "0.4.8-9"
16
16
  },
17
17
  "scripts": {
18
18
  "typecheck": "bun check",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/ignis",
3
- "version": "0.4.8-8",
3
+ "version": "0.4.8-9",
4
4
  "description": "TypeScript server framework with decorator-based DI, the repository pattern and a component system, on Hono. Features auto-generated OpenAPI docs, Drizzle ORM type-safe SQL, JWT/Basic authentication, Casbin authorization, convention-based bootstrapping, and pluggable components for health checks, Swagger UI, mail, Socket.IO, and static assets. Built for Bun.",
5
5
  "keywords": [
6
6
  "access-control",