node-honest 0.0.1 → 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.
Files changed (165) hide show
  1. package/dist/index.cjs +2185 -0
  2. package/dist/index.d.cts +1539 -0
  3. package/dist/index.d.ts +1539 -16
  4. package/dist/index.js +2116 -15
  5. package/package.json +14 -11
  6. package/dist/app.d.ts +0 -1
  7. package/dist/app.js +0 -36
  8. package/dist/application/plugin-entries.d.ts +0 -13
  9. package/dist/application/plugin-entries.js +0 -38
  10. package/dist/application/startup-guide.d.ts +0 -4
  11. package/dist/application/startup-guide.js +0 -53
  12. package/dist/application-context.d.ts +0 -13
  13. package/dist/application-context.js +0 -22
  14. package/dist/application.d.ts +0 -34
  15. package/dist/application.js +0 -224
  16. package/dist/components/index.d.ts +0 -1
  17. package/dist/components/index.js +0 -1
  18. package/dist/components/layout.component.d.ts +0 -31
  19. package/dist/components/layout.component.js +0 -94
  20. package/dist/constants/index.d.ts +0 -2
  21. package/dist/constants/index.js +0 -2
  22. package/dist/constants/pipeline.constants.d.ts +0 -6
  23. package/dist/constants/pipeline.constants.js +0 -6
  24. package/dist/constants/version.constants.d.ts +0 -5
  25. package/dist/constants/version.constants.js +0 -5
  26. package/dist/decorators/controller.decorator.d.ts +0 -9
  27. package/dist/decorators/controller.decorator.js +0 -16
  28. package/dist/decorators/http-method.decorator.d.ts +0 -43
  29. package/dist/decorators/http-method.decorator.js +0 -44
  30. package/dist/decorators/index.d.ts +0 -11
  31. package/dist/decorators/index.js +0 -11
  32. package/dist/decorators/module.decorator.d.ts +0 -8
  33. package/dist/decorators/module.decorator.js +0 -12
  34. package/dist/decorators/mvc.decorator.d.ts +0 -26
  35. package/dist/decorators/mvc.decorator.js +0 -36
  36. package/dist/decorators/parameter.decorator.d.ts +0 -41
  37. package/dist/decorators/parameter.decorator.js +0 -59
  38. package/dist/decorators/service.decorator.d.ts +0 -6
  39. package/dist/decorators/service.decorator.js +0 -11
  40. package/dist/decorators/use-component.decorator.d.ts +0 -10
  41. package/dist/decorators/use-component.decorator.js +0 -19
  42. package/dist/decorators/use-filters.decorator.d.ts +0 -8
  43. package/dist/decorators/use-filters.decorator.js +0 -17
  44. package/dist/decorators/use-guards.decorator.d.ts +0 -9
  45. package/dist/decorators/use-guards.decorator.js +0 -18
  46. package/dist/decorators/use-middleware.decorator.d.ts +0 -9
  47. package/dist/decorators/use-middleware.decorator.js +0 -18
  48. package/dist/decorators/use-pipes.decorator.d.ts +0 -9
  49. package/dist/decorators/use-pipes.decorator.js +0 -18
  50. package/dist/di/container.d.ts +0 -34
  51. package/dist/di/container.js +0 -114
  52. package/dist/di/index.d.ts +0 -1
  53. package/dist/di/index.js +0 -1
  54. package/dist/errors/framework.error.d.ts +0 -19
  55. package/dist/errors/framework.error.js +0 -23
  56. package/dist/errors/index.d.ts +0 -1
  57. package/dist/errors/index.js +0 -1
  58. package/dist/handlers/error.handler.d.ts +0 -28
  59. package/dist/handlers/error.handler.js +0 -17
  60. package/dist/handlers/index.d.ts +0 -2
  61. package/dist/handlers/index.js +0 -2
  62. package/dist/handlers/not-found.handler.d.ts +0 -14
  63. package/dist/handlers/not-found.handler.js +0 -17
  64. package/dist/helpers/create-error-response.helper.d.ts +0 -25
  65. package/dist/helpers/create-error-response.helper.js +0 -90
  66. package/dist/helpers/create-http-method-decorator.helper.d.ts +0 -16
  67. package/dist/helpers/create-http-method-decorator.helper.js +0 -30
  68. package/dist/helpers/create-param-decorator.helper.d.ts +0 -16
  69. package/dist/helpers/create-param-decorator.helper.js +0 -60
  70. package/dist/helpers/index.d.ts +0 -3
  71. package/dist/helpers/index.js +0 -3
  72. package/dist/interfaces/application-context.interface.d.ts +0 -35
  73. package/dist/interfaces/application-context.interface.js +0 -1
  74. package/dist/interfaces/controller-options.interface.d.ts +0 -17
  75. package/dist/interfaces/controller-options.interface.js +0 -1
  76. package/dist/interfaces/di-container.interface.d.ts +0 -35
  77. package/dist/interfaces/di-container.interface.js +0 -1
  78. package/dist/interfaces/error-response.interface.d.ts +0 -13
  79. package/dist/interfaces/error-response.interface.js +0 -1
  80. package/dist/interfaces/filter.interface.d.ts +0 -20
  81. package/dist/interfaces/filter.interface.js +0 -1
  82. package/dist/interfaces/guard.interface.d.ts +0 -21
  83. package/dist/interfaces/guard.interface.js +0 -1
  84. package/dist/interfaces/handler-invocation.interface.d.ts +0 -10
  85. package/dist/interfaces/handler-invocation.interface.js +0 -1
  86. package/dist/interfaces/honest-options.interface.d.ts +0 -121
  87. package/dist/interfaces/honest-options.interface.js +0 -1
  88. package/dist/interfaces/http-method-options.interface.d.ts +0 -38
  89. package/dist/interfaces/http-method-options.interface.js +0 -1
  90. package/dist/interfaces/index.d.ts +0 -21
  91. package/dist/interfaces/index.js +0 -21
  92. package/dist/interfaces/logger.interface.d.ts +0 -23
  93. package/dist/interfaces/logger.interface.js +0 -1
  94. package/dist/interfaces/metadata-repository.interface.d.ts +0 -30
  95. package/dist/interfaces/metadata-repository.interface.js +0 -1
  96. package/dist/interfaces/middleware.interface.d.ts +0 -22
  97. package/dist/interfaces/middleware.interface.js +0 -1
  98. package/dist/interfaces/module-options.interface.d.ts +0 -18
  99. package/dist/interfaces/module-options.interface.js +0 -1
  100. package/dist/interfaces/parameter-metadata.interface.d.ts +0 -27
  101. package/dist/interfaces/parameter-metadata.interface.js +0 -1
  102. package/dist/interfaces/parameter-resolution.interface.d.ts +0 -14
  103. package/dist/interfaces/parameter-resolution.interface.js +0 -1
  104. package/dist/interfaces/pipe.interface.d.ts +0 -37
  105. package/dist/interfaces/pipe.interface.js +0 -1
  106. package/dist/interfaces/pipeline-context.interface.d.ts +0 -9
  107. package/dist/interfaces/pipeline-context.interface.js +0 -1
  108. package/dist/interfaces/plugin.interface.d.ts +0 -74
  109. package/dist/interfaces/plugin.interface.js +0 -1
  110. package/dist/interfaces/route-definition.interface.d.ts +0 -51
  111. package/dist/interfaces/route-definition.interface.js +0 -1
  112. package/dist/interfaces/route-info.interface.d.ts +0 -42
  113. package/dist/interfaces/route-info.interface.js +0 -1
  114. package/dist/interfaces/service-registry.interface.d.ts +0 -7
  115. package/dist/interfaces/service-registry.interface.js +0 -1
  116. package/dist/loggers/console.logger.d.ts +0 -7
  117. package/dist/loggers/console.logger.js +0 -21
  118. package/dist/loggers/index.d.ts +0 -2
  119. package/dist/loggers/index.js +0 -2
  120. package/dist/loggers/noop.logger.d.ts +0 -7
  121. package/dist/loggers/noop.logger.js +0 -8
  122. package/dist/managers/component.manager.d.ts +0 -48
  123. package/dist/managers/component.manager.js +0 -210
  124. package/dist/managers/handler.invoker.d.ts +0 -7
  125. package/dist/managers/handler.invoker.js +0 -37
  126. package/dist/managers/index.d.ts +0 -5
  127. package/dist/managers/index.js +0 -5
  128. package/dist/managers/parameter.resolver.d.ts +0 -13
  129. package/dist/managers/parameter.resolver.js +0 -58
  130. package/dist/managers/pipeline.executor.d.ts +0 -28
  131. package/dist/managers/pipeline.executor.js +0 -71
  132. package/dist/managers/route.manager.d.ts +0 -36
  133. package/dist/managers/route.manager.js +0 -149
  134. package/dist/registries/index.d.ts +0 -4
  135. package/dist/registries/index.js +0 -4
  136. package/dist/registries/metadata.registry.d.ts +0 -163
  137. package/dist/registries/metadata.registry.js +0 -250
  138. package/dist/registries/metadata.repository.d.ts +0 -30
  139. package/dist/registries/metadata.repository.js +0 -151
  140. package/dist/registries/route.registry.d.ts +0 -16
  141. package/dist/registries/route.registry.js +0 -46
  142. package/dist/registries/service.registry.d.ts +0 -8
  143. package/dist/registries/service.registry.js +0 -9
  144. package/dist/testing/create-controller-test-application.d.ts +0 -5
  145. package/dist/testing/create-controller-test-application.js +0 -11
  146. package/dist/testing/create-service-test-container.d.ts +0 -5
  147. package/dist/testing/create-service-test-container.js +0 -31
  148. package/dist/testing/create-test-application.d.ts +0 -5
  149. package/dist/testing/create-test-application.js +0 -20
  150. package/dist/testing/create-testing-module.d.ts +0 -6
  151. package/dist/testing/create-testing-module.js +0 -13
  152. package/dist/testing/fixtures/application-test-fixtures.d.ts +0 -17
  153. package/dist/testing/fixtures/application-test-fixtures.js +0 -230
  154. package/dist/testing/index.d.ts +0 -5
  155. package/dist/testing/index.js +0 -5
  156. package/dist/testing/testing.interface.d.ts +0 -96
  157. package/dist/testing/testing.interface.js +0 -1
  158. package/dist/types/constructor.type.d.ts +0 -12
  159. package/dist/types/constructor.type.js +0 -1
  160. package/dist/types/index.d.ts +0 -1
  161. package/dist/types/index.js +0 -1
  162. package/dist/utils/common.util.d.ts +0 -117
  163. package/dist/utils/common.util.js +0 -140
  164. package/dist/utils/index.d.ts +0 -1
  165. package/dist/utils/index.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-honest",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "HonestJS - a modern web framework built on top of Hono and support node.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -8,30 +8,32 @@
8
8
  "pnpm": ">=10.0.0"
9
9
  },
10
10
  "types": "dist/index.d.ts",
11
- "main": "dist/index.js",
11
+ "main": "dist/index.cjs",
12
12
  "module": "dist/index.js",
13
+ "sideEffects": [
14
+ "./dist/index.js",
15
+ "./dist/index.cjs"
16
+ ],
13
17
  "repository": {
14
18
  "type": "git",
15
- "url": "git+https://github.com/rx-ted/honest-node.git"
19
+ "url": "git+https://github.com/rx-ted/node-honest.git"
16
20
  },
17
21
  "scripts": {
18
- "clean": "rm -rf dist",
19
22
  "test": "vitest run",
20
23
  "test:watch": "vitest",
21
24
  "test:coverage": "vitest run --coverage",
22
25
  "format": "biome format --write package.json tsconfig.json src",
23
- "build": "tsc -p tsconfig.json",
24
- "build:preview": "tsc -p tsconfig.json --noEmit",
26
+ "build": "tsup",
25
27
  "lint": "biome lint src --ignore='**/*.test.ts'",
26
28
  "lint:fix": "biome lint src --ignore='**/*.test.ts' --fix",
27
- "check": "pnpm lint && pnpm test"
29
+ "check": "pnpm format && pnpm lint && pnpm test && pnpm build"
28
30
  },
29
31
  "files": [
30
32
  "dist"
31
33
  ],
32
34
  "author": "rx-ted",
33
35
  "license": "MIT",
34
- "homepage": "https://github.com/rx-ted/honest-node",
36
+ "homepage": "https://github.com/rx-ted/node-honest",
35
37
  "keywords": [
36
38
  "nodejs",
37
39
  "deno",
@@ -45,15 +47,16 @@
45
47
  "honest"
46
48
  ],
47
49
  "publishConfig": {
48
- "registry": "https://registry.npmjs.org"
50
+ "access": "public"
49
51
  },
50
52
  "packageManager": "pnpm@10.33.0",
51
53
  "devDependencies": {
54
+ "@swc/core": "^1.15.26",
52
55
  "@types/node": "^25.6.0",
53
56
  "biome": "^0.3.3",
54
57
  "lefthook": "^2.1.5",
55
- "tsx": "^4.21.0",
56
- "typescript": "^6.0.2",
58
+ "tsup": "^8.5.1",
59
+ "typescript": "5.9.2",
57
60
  "vitest": "^4.1.4"
58
61
  },
59
62
  "dependencies": {
package/dist/app.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/app.js DELETED
@@ -1,36 +0,0 @@
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
- import { Application, Controller, Get, Module, Service } from '.';
11
- import { serve } from '@hono/node-server';
12
- let UsersController = class UsersController {
13
- getUsers() {
14
- return { users: [] };
15
- }
16
- };
17
- __decorate([
18
- Get(),
19
- __metadata("design:type", Function),
20
- __metadata("design:paramtypes", []),
21
- __metadata("design:returntype", void 0)
22
- ], UsersController.prototype, "getUsers", null);
23
- UsersController = __decorate([
24
- Controller('users')
25
- ], UsersController);
26
- let AppModule = class AppModule {
27
- };
28
- AppModule = __decorate([
29
- Module({
30
- controllers: [UsersController]
31
- })
32
- ], AppModule);
33
- const { hono } = await Application.create(AppModule);
34
- serve(hono, (info) => {
35
- console.log(`Listening on http://localhost:${info.port}`); // Listening on http://localhost:3000
36
- });
@@ -1,13 +0,0 @@
1
- import type { IPlugin, PluginEntry, PluginProcessor } from '../interfaces';
2
- import type { Constructor } from '../types';
3
- export declare const DEFAULT_PLUGIN_NAME = "AnonymousPlugin";
4
- export interface NormalizedPluginEntry {
5
- plugin: IPlugin;
6
- name: string;
7
- preProcessors: PluginProcessor[];
8
- postProcessors: PluginProcessor[];
9
- }
10
- export declare function resolvePlugin(pluginType: Constructor<IPlugin> | IPlugin): IPlugin;
11
- export declare function resolvePluginName(plugin: IPlugin, index: number, override?: string): string;
12
- export declare function normalizePluginEntry(entry: PluginEntry, index: number): NormalizedPluginEntry;
13
- export declare function normalizePluginEntries(plugins: PluginEntry[] | undefined): NormalizedPluginEntry[];
@@ -1,38 +0,0 @@
1
- import { isConstructor } from '../utils';
2
- export const DEFAULT_PLUGIN_NAME = 'AnonymousPlugin';
3
- export function resolvePlugin(pluginType) {
4
- if (isConstructor(pluginType)) {
5
- return new pluginType();
6
- }
7
- return pluginType;
8
- }
9
- export function resolvePluginName(plugin, index, override) {
10
- const resolved = override || plugin.meta?.name || plugin.constructor?.name;
11
- if (!resolved || resolved === DEFAULT_PLUGIN_NAME) {
12
- return `${DEFAULT_PLUGIN_NAME}#${index + 1}`;
13
- }
14
- return resolved;
15
- }
16
- export function normalizePluginEntry(entry, index) {
17
- if (entry && typeof entry === 'object' && 'plugin' in entry) {
18
- const obj = entry;
19
- const plugin = resolvePlugin(obj.plugin);
20
- const name = resolvePluginName(plugin, index, obj.name);
21
- return {
22
- plugin,
23
- name,
24
- preProcessors: obj.preProcessors ?? [],
25
- postProcessors: obj.postProcessors ?? []
26
- };
27
- }
28
- const plugin = resolvePlugin(entry);
29
- return {
30
- plugin,
31
- name: resolvePluginName(plugin, index),
32
- preProcessors: [],
33
- postProcessors: []
34
- };
35
- }
36
- export function normalizePluginEntries(plugins) {
37
- return (plugins ?? []).map((entry, index) => normalizePluginEntry(entry, index));
38
- }
@@ -1,4 +0,0 @@
1
- import type { HonestOptions, ILogger } from '../interfaces';
2
- import type { Constructor } from '../types';
3
- export declare function createStartupGuideHints(errorMessage: string): string[];
4
- export declare function emitStartupGuide(logger: ILogger, startupGuide: HonestOptions['startupGuide'], error: unknown, rootModule: Constructor): void;
@@ -1,53 +0,0 @@
1
- export function createStartupGuideHints(errorMessage) {
2
- const hints = new Set();
3
- hints.add('Check module wiring: root module imports, controllers, and services should be registered correctly.');
4
- if (errorMessage.includes('not decorated with @Controller()')) {
5
- hints.add('Add @Controller() to the class or remove it from module.controllers.');
6
- }
7
- if (errorMessage.includes('has no route handlers')) {
8
- hints.add('Add at least one HTTP method decorator such as @Get() or @Post() in the controller.');
9
- }
10
- if (errorMessage.includes('not decorated with @Service()')) {
11
- hints.add('Add @Service() to injectable classes used in constructor dependencies.');
12
- }
13
- if (errorMessage.includes('constructor metadata is missing') || errorMessage.includes('reflect-metadata')) {
14
- hints.add("Import 'reflect-metadata' in your entry file and enable 'emitDecoratorMetadata' in tsconfig.");
15
- }
16
- if (errorMessage.includes('Strict mode: no routes were registered')) {
17
- hints.add('Disable strict.requireRoutes for empty modules, or add a controller with at least one route.');
18
- }
19
- return [...hints];
20
- }
21
- export function emitStartupGuide(logger, startupGuide, error, rootModule) {
22
- if (!startupGuide) {
23
- return;
24
- }
25
- const verbose = typeof startupGuide === 'object' && Boolean(startupGuide.verbose);
26
- const errorMessage = error instanceof Error ? error.message : String(error);
27
- const hints = createStartupGuideHints(errorMessage);
28
- logger.emit({
29
- level: 'warn',
30
- category: 'startup',
31
- message: 'Startup guide',
32
- details: {
33
- rootModule: rootModule.name,
34
- errorMessage,
35
- hints,
36
- verbose
37
- }
38
- });
39
- if (verbose) {
40
- logger.emit({
41
- level: 'warn',
42
- category: 'startup',
43
- message: 'Startup guide (verbose)',
44
- details: {
45
- steps: [
46
- 'Verify decorators are present for controllers/services used by DI and routing.',
47
- "Ensure 'reflect-metadata' is imported once at entry and 'emitDecoratorMetadata' is enabled.",
48
- 'Enable debug.startup for extra startup diagnostics and timing details.'
49
- ]
50
- }
51
- });
52
- }
53
- }
@@ -1,13 +0,0 @@
1
- import type { IApplicationContext } from './interfaces';
2
- /**
3
- * Map-backed implementation of the app-level registry.
4
- * Used by Application so the app (bootstrap, services, any code with `app`) can share pipeline data by key.
5
- */
6
- export declare class ApplicationContext implements IApplicationContext {
7
- private readonly store;
8
- get<T>(key: string): T | undefined;
9
- set<T>(key: string, value: T): void;
10
- has(key: string): boolean;
11
- delete(key: string): boolean;
12
- keys(): IterableIterator<string>;
13
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Map-backed implementation of the app-level registry.
3
- * Used by Application so the app (bootstrap, services, any code with `app`) can share pipeline data by key.
4
- */
5
- export class ApplicationContext {
6
- store = new Map();
7
- get(key) {
8
- return this.store.get(key);
9
- }
10
- set(key, value) {
11
- this.store.set(key, value);
12
- }
13
- has(key) {
14
- return this.store.has(key);
15
- }
16
- delete(key) {
17
- return this.store.delete(key);
18
- }
19
- keys() {
20
- return this.store.keys();
21
- }
22
- }
@@ -1,34 +0,0 @@
1
- import { Hono } from 'hono';
2
- import type { DiContainer, HonestOptions, IApplicationContext, IMetadataRepository, RouteInfo } from './interfaces';
3
- import type { Constructor } from './types';
4
- /**
5
- * Main application class for the Honest framework.
6
- *
7
- * All per-app runtime state (routes, global components, DI container) is
8
- * instance-based. Static decorator metadata lives in MetadataRegistry and
9
- * is shared across all Application instances in the same process.
10
- */
11
- export declare class Application {
12
- private readonly hono;
13
- private readonly container;
14
- private readonly context;
15
- private readonly routeRegistry;
16
- private readonly metadataRepository;
17
- private readonly componentManager;
18
- private readonly routeManager;
19
- private readonly logger;
20
- private readonly options;
21
- constructor(options: HonestOptions | undefined, metadataRepository: IMetadataRepository);
22
- private setupErrorHandlers;
23
- private shouldEmitRouteDiagnostics;
24
- private emitStartupGuide;
25
- register(moduleClass: Constructor): Promise<Application>;
26
- static create(rootModule: Constructor, options?: HonestOptions): Promise<{
27
- app: Application;
28
- hono: Hono;
29
- }>;
30
- getApp(): Hono;
31
- getContainer(): DiContainer;
32
- getContext(): IApplicationContext;
33
- getRoutes(): ReadonlyArray<RouteInfo>;
34
- }
@@ -1,224 +0,0 @@
1
- import { Hono } from 'hono';
2
- import { emitStartupGuide as emitStartupGuideLogs } from './application/startup-guide';
3
- import { normalizePluginEntries } from './application/plugin-entries';
4
- import { ApplicationContext } from './application-context';
5
- import { ConsoleLogger } from './loggers';
6
- import { Container } from './di';
7
- import { ErrorHandler, NotFoundHandler } from './handlers';
8
- import { ComponentManager, RouteManager } from './managers';
9
- import { MetadataRepository, RouteRegistry } from './registries';
10
- import { isObject } from './utils';
11
- /**
12
- * Main application class for the Honest framework.
13
- *
14
- * All per-app runtime state (routes, global components, DI container) is
15
- * instance-based. Static decorator metadata lives in MetadataRegistry and
16
- * is shared across all Application instances in the same process.
17
- */
18
- export class Application {
19
- hono;
20
- container;
21
- context;
22
- routeRegistry;
23
- metadataRepository;
24
- componentManager;
25
- routeManager;
26
- logger;
27
- options;
28
- constructor(options = {}, metadataRepository) {
29
- this.options = isObject(options) ? options : {};
30
- const debugPipeline = this.options.debug === true ||
31
- (typeof this.options.debug === 'object' && Boolean(this.options.debug.pipeline));
32
- const debugDi = this.options.debug === true || (typeof this.options.debug === 'object' && Boolean(this.options.debug.di));
33
- this.hono = new Hono(this.options.hono);
34
- this.logger = this.options.logger || new ConsoleLogger();
35
- this.container = this.options.container || new Container(undefined, this.logger, debugDi);
36
- this.context = new ApplicationContext();
37
- this.routeRegistry = new RouteRegistry();
38
- this.metadataRepository = metadataRepository;
39
- this.componentManager = new ComponentManager(this.container, this.metadataRepository, this.logger);
40
- this.componentManager.setupGlobalComponents(this.options);
41
- this.setupErrorHandlers();
42
- this.routeManager = new RouteManager(this.hono, this.container, this.routeRegistry, this.componentManager, this.metadataRepository, this.logger, {
43
- prefix: this.options.routing?.prefix,
44
- version: this.options.routing?.version,
45
- debugPipeline
46
- });
47
- if (this.options.deprecations?.printPreV1Warning) {
48
- this.logger.emit({
49
- level: 'warn',
50
- category: 'deprecations',
51
- message: 'Pre-v1 warning: APIs may change before 1.0.0.'
52
- });
53
- }
54
- }
55
- setupErrorHandlers() {
56
- this.hono.notFound(this.options.notFound || NotFoundHandler.handle());
57
- this.hono.onError(this.options.onError || ErrorHandler.handle());
58
- }
59
- shouldEmitRouteDiagnostics() {
60
- const debug = this.options.debug;
61
- return debug === true || (typeof debug === 'object' && Boolean(debug.routes));
62
- }
63
- emitStartupGuide(error, rootModule) {
64
- emitStartupGuideLogs(this.logger, this.options.startupGuide, error, rootModule);
65
- }
66
- async register(moduleClass) {
67
- const controllers = await this.componentManager.registerModule(moduleClass);
68
- const debugRoutes = this.shouldEmitRouteDiagnostics();
69
- for (const controller of controllers) {
70
- const controllerStartedAt = Date.now();
71
- const routeCountBefore = this.routeRegistry.getRoutes().length;
72
- try {
73
- await this.routeManager.registerController(controller);
74
- if (debugRoutes) {
75
- this.logger.emit({
76
- level: 'info',
77
- category: 'routes',
78
- message: 'Registered controller routes',
79
- details: {
80
- controller: controller.name,
81
- routeCountAdded: this.routeRegistry.getRoutes().length - routeCountBefore,
82
- registrationDurationMs: Date.now() - controllerStartedAt
83
- }
84
- });
85
- }
86
- }
87
- catch (error) {
88
- if (debugRoutes) {
89
- this.logger.emit({
90
- level: 'error',
91
- category: 'routes',
92
- message: 'Failed to register controller routes',
93
- details: {
94
- controller: controller.name,
95
- registrationDurationMs: Date.now() - controllerStartedAt,
96
- errorMessage: error instanceof Error ? error.message : String(error)
97
- }
98
- });
99
- }
100
- throw error;
101
- }
102
- }
103
- return this;
104
- }
105
- static async create(rootModule, options = {}) {
106
- const startupStartedAt = Date.now();
107
- const metadataSnapshot = MetadataRepository.fromRootModule(rootModule);
108
- const app = new Application(options, metadataSnapshot);
109
- const entries = normalizePluginEntries(options.plugins);
110
- const ctx = app.getContext();
111
- const debug = options.debug;
112
- const debugPlugins = debug === true || (typeof debug === 'object' && debug.plugins);
113
- const debugRoutes = debug === true || (typeof debug === 'object' && debug.routes);
114
- const debugStartup = debug === true || (typeof debug === 'object' && (debug.startup || debugRoutes));
115
- let strictNoRoutesFailureEmitted = false;
116
- try {
117
- if (debugPlugins && entries.length > 0) {
118
- app.logger.emit({
119
- level: 'info',
120
- category: 'plugins',
121
- message: `Plugin order: ${entries.map(({ name }) => name).join(' -> ')}`
122
- });
123
- }
124
- for (const { plugin, preProcessors } of entries) {
125
- plugin.logger = app.logger;
126
- for (const fn of preProcessors) {
127
- await fn(app, app.hono, ctx);
128
- }
129
- if (plugin.beforeModulesRegistered) {
130
- await plugin.beforeModulesRegistered(app, app.hono);
131
- }
132
- }
133
- await app.register(rootModule);
134
- const routes = app.getRoutes();
135
- if (debugStartup) {
136
- app.logger.emit({
137
- level: 'info',
138
- category: 'startup',
139
- message: `Application registered ${routes.length} route(s)`,
140
- details: {
141
- routeCount: routes.length,
142
- rootModule: rootModule.name
143
- }
144
- });
145
- }
146
- if (options.strict?.requireRoutes && routes.length === 0) {
147
- strictNoRoutesFailureEmitted = true;
148
- app.logger.emit({
149
- level: 'error',
150
- category: 'startup',
151
- message: 'Strict mode failed: no routes were registered',
152
- details: {
153
- rootModule: rootModule.name,
154
- requireRoutes: true,
155
- startupDurationMs: Date.now() - startupStartedAt
156
- }
157
- });
158
- const strictError = new Error('Strict mode: no routes were registered. Check your module/controller decorators.');
159
- app.emitStartupGuide(strictError, rootModule);
160
- throw strictError;
161
- }
162
- if (debugRoutes) {
163
- app.logger.emit({
164
- level: 'info',
165
- category: 'routes',
166
- message: 'Registered routes',
167
- details: {
168
- routes: routes.map((route) => `${route.method.toUpperCase()} ${route.fullPath}`)
169
- }
170
- });
171
- }
172
- for (const { plugin, postProcessors } of entries) {
173
- if (plugin.afterModulesRegistered) {
174
- await plugin.afterModulesRegistered(app, app.hono);
175
- }
176
- for (const fn of postProcessors) {
177
- await fn(app, app.hono, ctx);
178
- }
179
- }
180
- if (debugStartup) {
181
- app.logger.emit({
182
- level: 'info',
183
- category: 'startup',
184
- message: 'Application startup completed',
185
- details: {
186
- rootModule: rootModule.name,
187
- pluginCount: entries.length,
188
- routeCount: routes.length,
189
- startupDurationMs: Date.now() - startupStartedAt
190
- }
191
- });
192
- }
193
- return { app, hono: app.getApp() };
194
- }
195
- catch (error) {
196
- app.emitStartupGuide(error, rootModule);
197
- if (debugStartup && !strictNoRoutesFailureEmitted) {
198
- app.logger.emit({
199
- level: 'error',
200
- category: 'startup',
201
- message: 'Application startup failed',
202
- details: {
203
- rootModule: rootModule.name,
204
- startupDurationMs: Date.now() - startupStartedAt,
205
- errorMessage: error instanceof Error ? error.message : String(error)
206
- }
207
- });
208
- }
209
- throw error;
210
- }
211
- }
212
- getApp() {
213
- return this.hono;
214
- }
215
- getContainer() {
216
- return this.container;
217
- }
218
- getContext() {
219
- return this.context;
220
- }
221
- getRoutes() {
222
- return this.routeRegistry.getRoutes();
223
- }
224
- }
@@ -1 +0,0 @@
1
- export * from './layout.component';
@@ -1 +0,0 @@
1
- export * from './layout.component';
@@ -1,31 +0,0 @@
1
- import type { PropsWithChildren } from 'hono/jsx';
2
- export type HtmlAttributes = Record<string, string | number | boolean>;
3
- export interface MetaTag {
4
- property: string;
5
- content: string;
6
- name?: string;
7
- prefix?: string;
8
- }
9
- export interface SiteData {
10
- title: string;
11
- description?: string;
12
- image?: string;
13
- url?: string;
14
- locale?: string;
15
- type?: string;
16
- siteName?: string;
17
- customMeta?: MetaTag[];
18
- scripts?: (string | {
19
- src: string;
20
- async?: boolean;
21
- defer?: boolean;
22
- })[];
23
- stylesheets?: string[];
24
- favicon?: string;
25
- twitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player';
26
- csp?: string;
27
- htmlAttributes?: HtmlAttributes;
28
- headAttributes?: HtmlAttributes;
29
- bodyAttributes?: HtmlAttributes;
30
- }
31
- export declare const Layout: (props: PropsWithChildren<SiteData>) => import("hono/utils/html").HtmlEscapedString | Promise<import("hono/utils/html").HtmlEscapedString>;
@@ -1,94 +0,0 @@
1
- import { html, raw } from 'hono/html';
2
- const defaultSiteData = {
3
- type: 'website',
4
- locale: 'en_US'
5
- };
6
- const attrsToString = (attrs) => {
7
- if (!attrs) {
8
- return '';
9
- }
10
- return Object.entries(attrs)
11
- .map(([key, value]) => {
12
- if (typeof value === 'boolean') {
13
- return value ? key : '';
14
- }
15
- const escapedValue = String(value).replace(/"/g, '&quot;');
16
- return `${key}="${escapedValue}"`;
17
- })
18
- .filter(Boolean)
19
- .join(' ');
20
- };
21
- export const Layout = (props) => {
22
- const data = { ...defaultSiteData, ...props };
23
- return html `
24
- <!DOCTYPE html>
25
- <html lang="${data.locale?.split('_')[0] || 'en'}" ${raw(attrsToString(data.htmlAttributes))}>
26
- <head ${raw(attrsToString(data.headAttributes))}>
27
- <meta charset="UTF-8" />
28
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
29
- ${data.csp ? html `<meta http-equiv="Content-Security-Policy" content="${data.csp}" />` : ''}
30
- <title>${data.title}</title>
31
- ${data.description ? html `<meta name="description" content="${data.description}" />` : ''}
32
-
33
- <!-- Open Graph / Facebook -->
34
- <meta prefix="og: http://ogp.me/ns#" />
35
- <meta property="og:title" content="${data.title}" />
36
- ${data.description ? html `<meta property="og:description" content="${data.description}" />` : ''}
37
- ${data.image ? html `<meta property="og:image" content="${data.image}" />` : ''}
38
- ${data.url ? html `<meta property="og:url" content="${data.url}" />` : ''}
39
- ${data.locale ? html `<meta property="og:locale" content="${data.locale}" />` : ''}
40
- ${data.type ? html `<meta property="og:type" content="${data.type}" />` : ''}
41
- ${data.siteName ? html `<meta property="og:site_name" content="${data.siteName}" />` : ''}
42
-
43
- <!-- Twitter -->
44
- <meta
45
- name="twitter:card"
46
- content="${data.twitterCard || (data.image ? 'summary_large_image' : 'summary')}"
47
- />
48
- <meta name="twitter:title" content="${data.title}" />
49
- ${data.description ? html `<meta name="twitter:description" content="${data.description}" />` : ''}
50
- ${data.image ? html `<meta name="twitter:image" content="${data.image}" />` : ''}
51
-
52
- <!-- Custom Meta Tags -->
53
- ${data.customMeta
54
- ? data.customMeta.map((meta) => {
55
- const nameAttr = meta.name ? `name="${meta.name}"` : '';
56
- const propertyAttr = meta.property ? `property="${meta.property}"` : '';
57
- return html `<meta ${nameAttr} ${propertyAttr} content="${meta.content}" />`;
58
- })
59
- : ''}
60
-
61
- <!-- Favicon -->
62
- ${data.favicon ? html `<link rel="icon" href="${data.favicon}" />` : ''}
63
-
64
- <!-- Stylesheets -->
65
- ${data.stylesheets
66
- ? data.stylesheets.map((href) => html `<link rel="stylesheet" href="${href}" />`)
67
- : ''}
68
-
69
- <!-- Scripts -->
70
- ${data.scripts
71
- ? data.scripts.map((script) => {
72
- if (typeof script === 'string') {
73
- return html `<script src="${script}"></script>`;
74
- }
75
- const { src, async, defer } = script;
76
- if (async && defer) {
77
- return html `<script src="${src}" async defer></script>`;
78
- }
79
- if (async) {
80
- return html `<script src="${src}" async></script>`;
81
- }
82
- if (defer) {
83
- return html `<script src="${src}" defer></script>`;
84
- }
85
- return html `<script src="${src}"></script>`;
86
- })
87
- : ''}
88
- </head>
89
- <body ${raw(attrsToString(data.bodyAttributes))}>
90
- ${data.children}
91
- </body>
92
- </html>
93
- `;
94
- };
@@ -1,2 +0,0 @@
1
- export * from './version.constants';
2
- export * from './pipeline.constants';
@@ -1,2 +0,0 @@
1
- export * from './version.constants';
2
- export * from './pipeline.constants';
@@ -1,6 +0,0 @@
1
- /**
2
- * Internal request-context keys used by the Honest runtime pipeline.
3
- */
4
- export declare const HONEST_PIPELINE_CONTROLLER_KEY = "__honest_controllerClass";
5
- export declare const HONEST_PIPELINE_HANDLER_KEY = "__honest_handlerName";
6
- export declare const HONEST_PIPELINE_BODY_CACHE_KEY = "__honest.body.cache";