nextrush 3.0.5 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +389 -122
- package/bin/nextrush.js +19 -0
- package/dist/chunk-7QVYU63E.js +7 -0
- package/dist/chunk-7QVYU63E.js.map +1 -0
- package/dist/class.d.ts +105 -3
- package/dist/class.js +79 -28
- package/dist/class.js.map +1 -1
- package/dist/dev-cli-launcher.d.ts +63 -0
- package/dist/dev-cli-launcher.js +112 -0
- package/dist/dev-cli-launcher.js.map +1 -0
- package/dist/index.d.ts +31 -11
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/package.json +33 -19
package/dist/class.d.ts
CHANGED
|
@@ -1,3 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import * as _nextrush_class from '@nextrush/class';
|
|
2
|
+
export { BodyOptions, CanActivate, ControllerMetadata, ControllerOptions, ControllerRouteMetadata, ControllersOptions, CustomParamExtractor, ExceptionFilter, GuardContext, GuardFn, HeaderOptions, Interceptor, ModuleMetadata, ModuleOptions, ModuleProvider, ModuleProviderConfig, ModuleRegistrationOptions, OnInit, OnShutdown, ParamMetadata, ParamOptions, ParamSource, QueryOptions, RouteMetadata, RouteOptions, TransformFn } from '@nextrush/class';
|
|
3
|
+
import * as _nextrush_types from '@nextrush/types';
|
|
4
|
+
import * as _nextrush_di from '@nextrush/di';
|
|
5
|
+
export { ClassProvider, ConfigOptions, Container, FactoryProvider, Provider, Scope, ServiceOptions, Token, ValueProvider } from '@nextrush/di';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* NextRush Class-Based API — Decorators, DI, and Controllers
|
|
9
|
+
*
|
|
10
|
+
* Import from `nextrush/class` when using the class-based paradigm.
|
|
11
|
+
* This entry point auto-loads `reflect-metadata` and re-exports all
|
|
12
|
+
* DI, decorator, and controller APIs in a single import.
|
|
13
|
+
*
|
|
14
|
+
* Functional users who only need `createApp` / `createRouter` should
|
|
15
|
+
* import from `nextrush` (the default entry) — no reflect-metadata overhead.
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
* @module nextrush/class
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { createApp, listen } from 'nextrush';
|
|
23
|
+
* import { Controller, Get, Service, registerControllers } from 'nextrush/class';
|
|
24
|
+
*
|
|
25
|
+
* @Service()
|
|
26
|
+
* class UserService {
|
|
27
|
+
* findAll() { return [{ id: 1, name: 'Alice' }]; }
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* @Controller('/users')
|
|
31
|
+
* class UserController {
|
|
32
|
+
* constructor(private users: UserService) {}
|
|
33
|
+
*
|
|
34
|
+
* @Get()
|
|
35
|
+
* findAll() { return this.users.findAll(); }
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* const app = createApp();
|
|
39
|
+
* await registerControllers(app, { root: './src' });
|
|
40
|
+
* await listen(app, 8080);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare const Config: typeof _nextrush_di.Config;
|
|
44
|
+
declare const container: _nextrush_types.Container;
|
|
45
|
+
declare const createContainer: typeof _nextrush_di.createContainer;
|
|
46
|
+
declare const delay: typeof _nextrush_di.delay;
|
|
47
|
+
declare const inject: typeof _nextrush_di.inject;
|
|
48
|
+
declare const Injectable: typeof _nextrush_di.Injectable;
|
|
49
|
+
declare const Optional: typeof _nextrush_di.Optional;
|
|
50
|
+
declare const Repository: typeof _nextrush_di.Repository;
|
|
51
|
+
declare const Service: typeof _nextrush_di.Service;
|
|
52
|
+
|
|
53
|
+
declare const All: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
54
|
+
declare const Body: {
|
|
55
|
+
(): ParameterDecorator;
|
|
56
|
+
(property: string): ParameterDecorator;
|
|
57
|
+
(options: _nextrush_class.BodyOptions): ParameterDecorator;
|
|
58
|
+
(property: string, options: _nextrush_class.BodyOptions): ParameterDecorator;
|
|
59
|
+
};
|
|
60
|
+
declare const Controller: typeof _nextrush_class.Controller;
|
|
61
|
+
declare const Module: typeof _nextrush_class.Module;
|
|
62
|
+
declare const createCustomParamDecorator: typeof _nextrush_class.createCustomParamDecorator;
|
|
63
|
+
declare const Ctx: typeof _nextrush_class.Ctx;
|
|
64
|
+
declare const Delete: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
65
|
+
declare const Get: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
66
|
+
declare const Head: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
67
|
+
declare const Header: {
|
|
68
|
+
(): ParameterDecorator;
|
|
69
|
+
(name: string): ParameterDecorator;
|
|
70
|
+
(options: _nextrush_class.HeaderOptions): ParameterDecorator;
|
|
71
|
+
(name: string, options: _nextrush_class.HeaderOptions): ParameterDecorator;
|
|
72
|
+
};
|
|
73
|
+
declare const HttpCode: typeof _nextrush_class.HttpCode;
|
|
74
|
+
declare const Options: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
75
|
+
declare const Param: {
|
|
76
|
+
(): ParameterDecorator;
|
|
77
|
+
(name: string): ParameterDecorator;
|
|
78
|
+
(options: _nextrush_class.ParamOptions): ParameterDecorator;
|
|
79
|
+
(name: string, options: _nextrush_class.ParamOptions): ParameterDecorator;
|
|
80
|
+
};
|
|
81
|
+
declare const Patch: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
82
|
+
declare const Post: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
83
|
+
declare const Put: (pathOrOptions?: string | _nextrush_class.RouteOptions, options?: _nextrush_class.RouteOptions) => MethodDecorator;
|
|
84
|
+
declare const Query: {
|
|
85
|
+
(): ParameterDecorator;
|
|
86
|
+
(name: string): ParameterDecorator;
|
|
87
|
+
(options: _nextrush_class.QueryOptions): ParameterDecorator;
|
|
88
|
+
(name: string, options: _nextrush_class.QueryOptions): ParameterDecorator;
|
|
89
|
+
};
|
|
90
|
+
declare const Redirect: typeof _nextrush_class.Redirect;
|
|
91
|
+
declare const Req: typeof _nextrush_class.Req;
|
|
92
|
+
declare const Res: typeof _nextrush_class.Res;
|
|
93
|
+
declare const SetHeader: typeof _nextrush_class.SetHeader;
|
|
94
|
+
declare const UseGuard: typeof _nextrush_class.UseGuard;
|
|
95
|
+
declare const Catch: typeof _nextrush_class.Catch;
|
|
96
|
+
declare const UseFilter: typeof _nextrush_class.UseFilter;
|
|
97
|
+
declare const UseInterceptor: typeof _nextrush_class.UseInterceptor;
|
|
98
|
+
declare const isOnInit: typeof _nextrush_class.isOnInit;
|
|
99
|
+
declare const isOnShutdown: typeof _nextrush_class.isOnShutdown;
|
|
100
|
+
declare const getModuleMetadata: typeof _nextrush_class.getModuleMetadata;
|
|
101
|
+
declare const isModule: typeof _nextrush_class.isModule;
|
|
102
|
+
declare const registerControllers: typeof _nextrush_class.registerControllers;
|
|
103
|
+
declare const registerModule: typeof _nextrush_class.registerModule;
|
|
104
|
+
|
|
105
|
+
export { All, Body, Catch, Config, Controller, Ctx, Delete, Get, Head, Header, HttpCode, Injectable, Module, Optional, Options, Param, Patch, Post, Put, Query, Redirect, Repository, Req, Res, Service, SetHeader, UseFilter, UseGuard, UseInterceptor, container, createContainer, createCustomParamDecorator, delay, getModuleMetadata, inject, isModule, isOnInit, isOnShutdown, registerControllers, registerModule };
|
package/dist/class.js
CHANGED
|
@@ -1,33 +1,75 @@
|
|
|
1
|
-
// src/class.ts
|
|
2
|
-
import "reflect-metadata";
|
|
3
|
-
import { AutoInjectable, Config, container, createContainer, delay, inject, Injectable, Optional, Repository, Service } from "@nextrush/di";
|
|
4
1
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-7QVYU63E.js";
|
|
4
|
+
|
|
5
|
+
// src/class-peer-guard.ts
|
|
6
|
+
var MISSING_MODULE_PATTERN = /Cannot find (?:module|package) '(@nextrush\/class|@nextrush\/di|reflect-metadata)'/;
|
|
7
|
+
function describeMissingClassPeerError(err) {
|
|
8
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
9
|
+
if (!MISSING_MODULE_PATTERN.test(message)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return "nextrush/class requires @nextrush/class and reflect-metadata as optional peer dependencies, which are not installed in this project. Install them:\n pnpm add @nextrush/class reflect-metadata";
|
|
13
|
+
}
|
|
14
|
+
__name(describeMissingClassPeerError, "describeMissingClassPeerError");
|
|
15
|
+
|
|
16
|
+
// src/class.ts
|
|
17
|
+
var di;
|
|
18
|
+
var cls;
|
|
19
|
+
try {
|
|
20
|
+
await import("reflect-metadata");
|
|
21
|
+
di = await import("@nextrush/di");
|
|
22
|
+
cls = await import("@nextrush/class");
|
|
23
|
+
} catch (err) {
|
|
24
|
+
const guardedMessage = describeMissingClassPeerError(err);
|
|
25
|
+
throw guardedMessage ? new Error(guardedMessage, {
|
|
26
|
+
cause: err
|
|
27
|
+
}) : err;
|
|
28
|
+
}
|
|
29
|
+
var Config = di.Config;
|
|
30
|
+
var container = di.container;
|
|
31
|
+
var createContainer = di.createContainer;
|
|
32
|
+
var delay = di.delay;
|
|
33
|
+
var inject = di.inject;
|
|
34
|
+
var Injectable = di.Injectable;
|
|
35
|
+
var Optional = di.Optional;
|
|
36
|
+
var Repository = di.Repository;
|
|
37
|
+
var Service = di.Service;
|
|
38
|
+
var All = cls.All;
|
|
39
|
+
var Body = cls.Body;
|
|
40
|
+
var Controller = cls.Controller;
|
|
41
|
+
var Module = cls.Module;
|
|
42
|
+
var createCustomParamDecorator = cls.createCustomParamDecorator;
|
|
43
|
+
var Ctx = cls.Ctx;
|
|
44
|
+
var Delete = cls.Delete;
|
|
45
|
+
var Get = cls.Get;
|
|
46
|
+
var Head = cls.Head;
|
|
47
|
+
var Header = cls.Header;
|
|
48
|
+
var HttpCode = cls.HttpCode;
|
|
49
|
+
var Options = cls.Options;
|
|
50
|
+
var Param = cls.Param;
|
|
51
|
+
var Patch = cls.Patch;
|
|
52
|
+
var Post = cls.Post;
|
|
53
|
+
var Put = cls.Put;
|
|
54
|
+
var Query = cls.Query;
|
|
55
|
+
var Redirect = cls.Redirect;
|
|
56
|
+
var Req = cls.Req;
|
|
57
|
+
var Res = cls.Res;
|
|
58
|
+
var SetHeader = cls.SetHeader;
|
|
59
|
+
var UseGuard = cls.UseGuard;
|
|
60
|
+
var Catch = cls.Catch;
|
|
61
|
+
var UseFilter = cls.UseFilter;
|
|
62
|
+
var UseInterceptor = cls.UseInterceptor;
|
|
63
|
+
var isOnInit = cls.isOnInit;
|
|
64
|
+
var isOnShutdown = cls.isOnShutdown;
|
|
65
|
+
var getModuleMetadata = cls.getModuleMetadata;
|
|
66
|
+
var isModule = cls.isModule;
|
|
67
|
+
var registerControllers = cls.registerControllers;
|
|
68
|
+
var registerModule = cls.registerModule;
|
|
27
69
|
export {
|
|
28
70
|
All,
|
|
29
|
-
AutoInjectable,
|
|
30
71
|
Body,
|
|
72
|
+
Catch,
|
|
31
73
|
Config,
|
|
32
74
|
Controller,
|
|
33
75
|
Ctx,
|
|
@@ -35,7 +77,9 @@ export {
|
|
|
35
77
|
Get,
|
|
36
78
|
Head,
|
|
37
79
|
Header,
|
|
80
|
+
HttpCode,
|
|
38
81
|
Injectable,
|
|
82
|
+
Module,
|
|
39
83
|
Optional,
|
|
40
84
|
Options,
|
|
41
85
|
Param,
|
|
@@ -49,12 +93,19 @@ export {
|
|
|
49
93
|
Res,
|
|
50
94
|
Service,
|
|
51
95
|
SetHeader,
|
|
96
|
+
UseFilter,
|
|
52
97
|
UseGuard,
|
|
98
|
+
UseInterceptor,
|
|
53
99
|
container,
|
|
54
|
-
controllersPlugin,
|
|
55
100
|
createContainer,
|
|
56
101
|
createCustomParamDecorator,
|
|
57
102
|
delay,
|
|
58
|
-
|
|
103
|
+
getModuleMetadata,
|
|
104
|
+
inject,
|
|
105
|
+
isModule,
|
|
106
|
+
isOnInit,
|
|
107
|
+
isOnShutdown,
|
|
108
|
+
registerControllers,
|
|
109
|
+
registerModule
|
|
59
110
|
};
|
|
60
111
|
//# sourceMappingURL=class.js.map
|
package/dist/class.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/class.ts"],"sourcesContent":["/**\n * NextRush Class-Based API — Decorators, DI, and Controllers\n *\n * Import from `nextrush/class` when using the class-based paradigm.\n * This entry point auto-loads `reflect-metadata` and re-exports all\n * DI, decorator, and controller APIs in a single import.\n *\n * Functional users who only need `createApp` / `createRouter` should\n * import from `nextrush` (the default entry) — no reflect-metadata overhead.\n *\n * @packageDocumentation\n * @module nextrush/class\n *\n * @example\n * ```typescript\n * import { createApp, listen } from 'nextrush';\n * import { Controller, Get, Service,
|
|
1
|
+
{"version":3,"sources":["../src/class-peer-guard.ts","../src/class.ts"],"sourcesContent":["/**\n * Resolution guard for the `nextrush/class` subpath's optional peer dependencies.\n *\n * `@nextrush/class`, `@nextrush/di`, and `reflect-metadata` are OPTIONAL peer dependencies of\n * `nextrush` (see docs/RFC/framework-composition/020-framework-composition-integrity.md) — a\n * functional-only install never resolves them. When a consumer imports `nextrush/class`\n * without having installed the peer, the resulting module-not-found error is opaque. This\n * module recognizes that specific failure and rewrites it into an actionable message naming\n * the missing package and the exact install command, without swallowing unrelated errors.\n */\n\nconst MISSING_MODULE_PATTERN = /Cannot find (?:module|package) '(@nextrush\\/class|@nextrush\\/di|reflect-metadata)'/;\n\n/**\n * Given an error thrown while loading `nextrush/class`, return an actionable message if it is\n * the specific \"the optional class/DI peer is not installed\" case, or `null` if the error is\n * unrelated (in which case the caller should re-throw the original error unchanged).\n */\nexport function describeMissingClassPeerError(err: unknown): string | null {\n const message = err instanceof Error ? err.message : String(err);\n if (!MISSING_MODULE_PATTERN.test(message)) {\n return null;\n }\n\n return (\n 'nextrush/class requires @nextrush/class and reflect-metadata as optional peer ' +\n 'dependencies, which are not installed in this project. Install them:\\n' +\n ' pnpm add @nextrush/class reflect-metadata'\n );\n}\n","/**\n * NextRush Class-Based API — Decorators, DI, and Controllers\n *\n * Import from `nextrush/class` when using the class-based paradigm.\n * This entry point auto-loads `reflect-metadata` and re-exports all\n * DI, decorator, and controller APIs in a single import.\n *\n * Functional users who only need `createApp` / `createRouter` should\n * import from `nextrush` (the default entry) — no reflect-metadata overhead.\n *\n * @packageDocumentation\n * @module nextrush/class\n *\n * @example\n * ```typescript\n * import { createApp, listen } from 'nextrush';\n * import { Controller, Get, Service, registerControllers } from 'nextrush/class';\n *\n * @Service()\n * class UserService {\n * findAll() { return [{ id: 1, name: 'Alice' }]; }\n * }\n *\n * @Controller('/users')\n * class UserController {\n * constructor(private users: UserService) {}\n *\n * @Get()\n * findAll() { return this.users.findAll(); }\n * }\n *\n * const app = createApp();\n * await registerControllers(app, { root: './src' });\n * await listen(app, 8080);\n * ```\n */\n\n// ============================================\n// OPTIONAL-PEER LOADING (framework-composition-integrity)\n// ============================================\n//\n// @nextrush/class, @nextrush/di, and reflect-metadata are OPTIONAL peer dependencies of\n// `nextrush` (see docs/RFC/framework-composition/020-framework-composition-integrity.md) — a\n// functional-only install never resolves them. A STATIC `export { X } from '@nextrush/class'`\n// would fail module LINKING (before any module body runs) with an opaque Node error the moment\n// that package is unresolvable — there is no way to catch a static specifier's resolution\n// failure from inside the module. So every RUNTIME (value) export below is loaded dynamically\n// and re-exported by re-assignment, letting this try/catch convert a missing-peer failure into\n// an actionable message. `export type` declarations stay static: type-only specifiers are\n// erased before runtime and never cause a module-resolution failure, so they are unaffected.\nimport { describeMissingClassPeerError } from './class-peer-guard.js';\n\ntype DiModule = typeof import('@nextrush/di');\ntype ClassModule = typeof import('@nextrush/class');\n\nlet di: DiModule;\nlet cls: ClassModule;\n\ntry {\n await import('reflect-metadata');\n di = await import('@nextrush/di');\n cls = await import('@nextrush/class');\n} catch (err) {\n const guardedMessage = describeMissingClassPeerError(err);\n throw guardedMessage ? new Error(guardedMessage, { cause: err }) : err;\n}\n\n// ============================================\n// DI: Dependency Injection Container\n// ============================================\nexport const Config = di.Config;\nexport const container = di.container;\nexport const createContainer = di.createContainer;\nexport const delay = di.delay;\nexport const inject = di.inject;\nexport const Injectable = di.Injectable;\nexport const Optional = di.Optional;\nexport const Repository = di.Repository;\nexport const Service = di.Service;\n\nexport type {\n ClassProvider,\n ConfigOptions,\n Container,\n FactoryProvider,\n Provider,\n Scope,\n ServiceOptions,\n Token,\n ValueProvider,\n} from '@nextrush/di';\n\n// ============================================\n// DECORATORS & CONTROLLERS: From @nextrush/class\n// ============================================\nexport const All = cls.All;\nexport const Body = cls.Body;\nexport const Controller = cls.Controller;\nexport const Module = cls.Module;\nexport const createCustomParamDecorator = cls.createCustomParamDecorator;\nexport const Ctx = cls.Ctx;\nexport const Delete = cls.Delete;\nexport const Get = cls.Get;\nexport const Head = cls.Head;\nexport const Header = cls.Header;\nexport const HttpCode = cls.HttpCode;\nexport const Options = cls.Options;\nexport const Param = cls.Param;\nexport const Patch = cls.Patch;\nexport const Post = cls.Post;\nexport const Put = cls.Put;\nexport const Query = cls.Query;\nexport const Redirect = cls.Redirect;\nexport const Req = cls.Req;\nexport const Res = cls.Res;\nexport const SetHeader = cls.SetHeader;\nexport const UseGuard = cls.UseGuard;\nexport const Catch = cls.Catch;\nexport const UseFilter = cls.UseFilter;\nexport const UseInterceptor = cls.UseInterceptor;\nexport const isOnInit = cls.isOnInit;\nexport const isOnShutdown = cls.isOnShutdown;\nexport const getModuleMetadata = cls.getModuleMetadata;\nexport const isModule = cls.isModule;\nexport const registerControllers = cls.registerControllers;\nexport const registerModule = cls.registerModule;\n\nexport type {\n // Decorators\n BodyOptions,\n CanActivate,\n ControllerMetadata,\n ControllerOptions,\n ControllerRouteMetadata,\n CustomParamExtractor,\n ExceptionFilter,\n GuardContext,\n GuardFn,\n HeaderOptions,\n Interceptor,\n ModuleMetadata,\n ModuleOptions,\n ModuleProvider,\n ModuleProviderConfig,\n ParamMetadata,\n ParamOptions,\n ParamSource,\n QueryOptions,\n /** @deprecated Use ControllerRouteMetadata. Removed in the next major. */\n RouteMetadata,\n RouteOptions,\n TransformFn,\n OnInit,\n OnShutdown,\n // Controllers\n ControllersOptions,\n ModuleRegistrationOptions,\n} from '@nextrush/class';\n"],"mappings":";;;;;AAWA,IAAMA,yBAAyB;AAOxB,SAASC,8BAA8BC,KAAY;AACxD,QAAMC,UAAUD,eAAeE,QAAQF,IAAIC,UAAUE,OAAOH,GAAAA;AAC5D,MAAI,CAACF,uBAAuBM,KAAKH,OAAAA,GAAU;AACzC,WAAO;EACT;AAEA,SACE;AAIJ;AAXgBF;;;ACqChB,IAAIM;AACJ,IAAIC;AAEJ,IAAI;AACF,QAAM,OAAO,kBAAA;AACbD,OAAK,MAAM,OAAO,cAAA;AAClBC,QAAM,MAAM,OAAO,iBAAA;AACrB,SAASC,KAAK;AACZ,QAAMC,iBAAiBC,8BAA8BF,GAAAA;AACrD,QAAMC,iBAAiB,IAAIE,MAAMF,gBAAgB;IAAEG,OAAOJ;EAAI,CAAA,IAAKA;AACrE;AAKO,IAAMK,SAASP,GAAGO;AAClB,IAAMC,YAAYR,GAAGQ;AACrB,IAAMC,kBAAkBT,GAAGS;AAC3B,IAAMC,QAAQV,GAAGU;AACjB,IAAMC,SAASX,GAAGW;AAClB,IAAMC,aAAaZ,GAAGY;AACtB,IAAMC,WAAWb,GAAGa;AACpB,IAAMC,aAAad,GAAGc;AACtB,IAAMC,UAAUf,GAAGe;AAiBnB,IAAMC,MAAMf,IAAIe;AAChB,IAAMC,OAAOhB,IAAIgB;AACjB,IAAMC,aAAajB,IAAIiB;AACvB,IAAMC,SAASlB,IAAIkB;AACnB,IAAMC,6BAA6BnB,IAAImB;AACvC,IAAMC,MAAMpB,IAAIoB;AAChB,IAAMC,SAASrB,IAAIqB;AACnB,IAAMC,MAAMtB,IAAIsB;AAChB,IAAMC,OAAOvB,IAAIuB;AACjB,IAAMC,SAASxB,IAAIwB;AACnB,IAAMC,WAAWzB,IAAIyB;AACrB,IAAMC,UAAU1B,IAAI0B;AACpB,IAAMC,QAAQ3B,IAAI2B;AAClB,IAAMC,QAAQ5B,IAAI4B;AAClB,IAAMC,OAAO7B,IAAI6B;AACjB,IAAMC,MAAM9B,IAAI8B;AAChB,IAAMC,QAAQ/B,IAAI+B;AAClB,IAAMC,WAAWhC,IAAIgC;AACrB,IAAMC,MAAMjC,IAAIiC;AAChB,IAAMC,MAAMlC,IAAIkC;AAChB,IAAMC,YAAYnC,IAAImC;AACtB,IAAMC,WAAWpC,IAAIoC;AACrB,IAAMC,QAAQrC,IAAIqC;AAClB,IAAMC,YAAYtC,IAAIsC;AACtB,IAAMC,iBAAiBvC,IAAIuC;AAC3B,IAAMC,WAAWxC,IAAIwC;AACrB,IAAMC,eAAezC,IAAIyC;AACzB,IAAMC,oBAAoB1C,IAAI0C;AAC9B,IAAMC,WAAW3C,IAAI2C;AACrB,IAAMC,sBAAsB5C,IAAI4C;AAChC,IAAMC,iBAAiB7C,IAAI6C;","names":["MISSING_MODULE_PATTERN","describeMissingClassPeerError","err","message","Error","String","test","di","cls","err","guardedMessage","describeMissingClassPeerError","Error","cause","Config","container","createContainer","delay","inject","Injectable","Optional","Repository","Service","All","Body","Controller","Module","createCustomParamDecorator","Ctx","Delete","Get","Head","Header","HttpCode","Options","Param","Patch","Post","Put","Query","Redirect","Req","Res","SetHeader","UseGuard","Catch","UseFilter","UseInterceptor","isOnInit","isOnShutdown","getModuleMetadata","isModule","registerControllers","registerModule"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin launcher for the `nextrush` meta-package's `bin`.
|
|
3
|
+
*
|
|
4
|
+
* `@nextrush/dev` is an optional dev-time toolkit, not a runtime dependency of `nextrush`
|
|
5
|
+
* (docs/RFC/framework-composition/020-framework-composition-integrity.md §21; ADR-0013). This
|
|
6
|
+
* launcher resolves it on demand: when present it delegates to its CLI transparently; when absent
|
|
7
|
+
* it prints an actionable, package-manager-aware install message and exits non-zero, instead of the
|
|
8
|
+
* shell's raw "command not found". All logic lives inside the exported functions — importing this
|
|
9
|
+
* module has no side effect, so it never executes at install time.
|
|
10
|
+
*
|
|
11
|
+
* @see docs/adr/ADR-0013-nextrush-cli-launcher-discoverability.md
|
|
12
|
+
*/
|
|
13
|
+
/** The `@nextrush/dev` CLI surface this launcher depends on. `cli()` reads `process.argv` itself. */
|
|
14
|
+
interface DevCliModule {
|
|
15
|
+
readonly cli: (argv?: string[]) => void;
|
|
16
|
+
}
|
|
17
|
+
/** Package managers whose install command the launcher can name precisely; `null` = inconclusive. */
|
|
18
|
+
type LauncherPackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
19
|
+
/** Injectable seams — the defaults hit the real module loader / environment; tests substitute them. */
|
|
20
|
+
interface DevCliLauncherDeps {
|
|
21
|
+
readonly importDevCli?: () => Promise<DevCliModule>;
|
|
22
|
+
readonly detectPackageManager?: () => LauncherPackageManager | null;
|
|
23
|
+
readonly writeError?: (message: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Directory `@nextrush/dev` must resolve relative to — the CONSUMING app's own directory,
|
|
26
|
+
* never this package's. Defaults to `process.cwd()` at the real call site. A bare
|
|
27
|
+
* `import('@nextrush/dev')` from inside this file would resolve against `nextrush`'s own
|
|
28
|
+
* `node_modules`, which deliberately never has `@nextrush/dev` linked (ADR-0013) — so every
|
|
29
|
+
* consumer, regardless of what THEY have installed, would see "not installed." See ADR-0013
|
|
30
|
+
* addendum and the regression test covering this.
|
|
31
|
+
*/
|
|
32
|
+
readonly baseDir?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* True only when the error is specifically "@nextrush/dev is not installed" — not when
|
|
36
|
+
* `@nextrush/dev` is present but one of ITS OWN dependencies is missing (whose message names that
|
|
37
|
+
* other specifier, even though the `@nextrush/dev` path may appear in the "imported from" clause).
|
|
38
|
+
*/
|
|
39
|
+
declare function isMissingDevToolkitError(err: unknown): boolean;
|
|
40
|
+
/** The exact `-D`/`-d` install command for a package manager (design D4). */
|
|
41
|
+
declare function installCommand(pm: LauncherPackageManager | null): string;
|
|
42
|
+
/**
|
|
43
|
+
* The actionable message shown when the toolkit is absent: brands `@nextrush/dev` as the
|
|
44
|
+
* Development Toolkit, gives the exact install command for the detected package manager, a one-line
|
|
45
|
+
* description of what it provides, and a "then run" hint reflecting the command the user attempted
|
|
46
|
+
* (fed.md Option 1).
|
|
47
|
+
*/
|
|
48
|
+
declare function buildMissingToolkitMessage(pm: LauncherPackageManager | null, attemptedArgv?: readonly string[]): string;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve `@nextrush/dev`'s CLI and delegate; on the specific "toolkit not installed" case, print
|
|
51
|
+
* an actionable message and return a non-zero exit code. Any other error propagates unchanged.
|
|
52
|
+
*
|
|
53
|
+
* On the success path the underlying `cli()` reads `process.argv` and self-exits with its own code,
|
|
54
|
+
* so the launcher does not need to re-propagate it; the returned `0` is reached only when `cli()`
|
|
55
|
+
* returns without exiting (e.g. `--help`).
|
|
56
|
+
*
|
|
57
|
+
* @param argv - The CLI arguments (`process.argv.slice(2)`), passed through to the delegate.
|
|
58
|
+
* @param deps - Injectable seams for testing; defaults use the real loader and environment.
|
|
59
|
+
* @returns The exit code the launcher itself controls (non-zero when the toolkit is absent).
|
|
60
|
+
*/
|
|
61
|
+
declare function runDevCliLauncher(argv: string[], deps?: DevCliLauncherDeps): Promise<number>;
|
|
62
|
+
|
|
63
|
+
export { type DevCliLauncherDeps, type DevCliModule, type LauncherPackageManager, buildMissingToolkitMessage, installCommand, isMissingDevToolkitError, runDevCliLauncher };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-7QVYU63E.js";
|
|
4
|
+
|
|
5
|
+
// src/dev-cli-launcher.ts
|
|
6
|
+
import { readFile } from "fs/promises";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { pathToFileURL } from "url";
|
|
9
|
+
var MISSING_DEV_TOOLKIT_PATTERN = /Cannot find (?:module|package) ['"]@nextrush\/dev['"]/;
|
|
10
|
+
function isMissingDevToolkitError(err) {
|
|
11
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
12
|
+
return MISSING_DEV_TOOLKIT_PATTERN.test(message);
|
|
13
|
+
}
|
|
14
|
+
__name(isMissingDevToolkitError, "isMissingDevToolkitError");
|
|
15
|
+
function installCommand(pm) {
|
|
16
|
+
switch (pm) {
|
|
17
|
+
case "pnpm":
|
|
18
|
+
return "pnpm add -D @nextrush/dev";
|
|
19
|
+
case "yarn":
|
|
20
|
+
return "yarn add -D @nextrush/dev";
|
|
21
|
+
case "bun":
|
|
22
|
+
return "bun add -d @nextrush/dev";
|
|
23
|
+
case "npm":
|
|
24
|
+
return "npm install -D @nextrush/dev";
|
|
25
|
+
default:
|
|
26
|
+
return "install @nextrush/dev as a dev dependency (e.g. `npm install -D @nextrush/dev`)";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
__name(installCommand, "installCommand");
|
|
30
|
+
function runHint(pm, attemptedArgv) {
|
|
31
|
+
const prefix = pm === "npm" ? "npx" : pm ?? "";
|
|
32
|
+
return [
|
|
33
|
+
prefix,
|
|
34
|
+
"nextrush",
|
|
35
|
+
...attemptedArgv
|
|
36
|
+
].filter(Boolean).join(" ");
|
|
37
|
+
}
|
|
38
|
+
__name(runHint, "runHint");
|
|
39
|
+
function buildMissingToolkitMessage(pm, attemptedArgv = []) {
|
|
40
|
+
const lines = [
|
|
41
|
+
"The NextRush Development Toolkit (@nextrush/dev) is not installed in this project.",
|
|
42
|
+
"",
|
|
43
|
+
"Install it:",
|
|
44
|
+
` ${installCommand(pm)}`,
|
|
45
|
+
"",
|
|
46
|
+
"It provides the hot-reload dev server, production builds, and code generators (nextrush dev / build / generate)."
|
|
47
|
+
];
|
|
48
|
+
const hint = runHint(pm, attemptedArgv);
|
|
49
|
+
if (attemptedArgv.length > 0) {
|
|
50
|
+
lines.push("", "Then run:", ` ${hint}`);
|
|
51
|
+
}
|
|
52
|
+
return lines.join("\n");
|
|
53
|
+
}
|
|
54
|
+
__name(buildMissingToolkitMessage, "buildMissingToolkitMessage");
|
|
55
|
+
function detectPackageManagerFromEnv() {
|
|
56
|
+
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
57
|
+
if (userAgent.startsWith("pnpm")) return "pnpm";
|
|
58
|
+
if (userAgent.startsWith("yarn")) return "yarn";
|
|
59
|
+
if (userAgent.startsWith("bun")) return "bun";
|
|
60
|
+
if (userAgent.startsWith("npm")) return "npm";
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
__name(detectPackageManagerFromEnv, "detectPackageManagerFromEnv");
|
|
64
|
+
async function importDevCliModule(baseDir) {
|
|
65
|
+
const manifestPath = path.join(baseDir, "node_modules", "@nextrush", "dev", "package.json");
|
|
66
|
+
let manifestContents;
|
|
67
|
+
try {
|
|
68
|
+
manifestContents = await readFile(manifestPath, "utf8");
|
|
69
|
+
} catch {
|
|
70
|
+
throw new Error(`Cannot find package '@nextrush/dev' imported from ${baseDir}`);
|
|
71
|
+
}
|
|
72
|
+
const manifest = JSON.parse(manifestContents);
|
|
73
|
+
const entryRelativePath = manifest.exports?.["."]?.import;
|
|
74
|
+
if (!entryRelativePath) {
|
|
75
|
+
throw new Error(`@nextrush/dev's package.json at ${manifestPath} has no "exports['.'].import" entry`);
|
|
76
|
+
}
|
|
77
|
+
const packageDir = path.dirname(manifestPath);
|
|
78
|
+
const entryAbsolutePath = path.join(packageDir, entryRelativePath);
|
|
79
|
+
return await import(pathToFileURL(entryAbsolutePath).href);
|
|
80
|
+
}
|
|
81
|
+
__name(importDevCliModule, "importDevCliModule");
|
|
82
|
+
function defaultWriteError(message) {
|
|
83
|
+
process.stderr.write(`${message}
|
|
84
|
+
`);
|
|
85
|
+
}
|
|
86
|
+
__name(defaultWriteError, "defaultWriteError");
|
|
87
|
+
async function runDevCliLauncher(argv, deps = {}) {
|
|
88
|
+
const baseDir = deps.baseDir ?? process.cwd();
|
|
89
|
+
const importDevCli = deps.importDevCli ?? (() => importDevCliModule(baseDir));
|
|
90
|
+
const detectPm = deps.detectPackageManager ?? detectPackageManagerFromEnv;
|
|
91
|
+
const writeError = deps.writeError ?? defaultWriteError;
|
|
92
|
+
let devCli;
|
|
93
|
+
try {
|
|
94
|
+
devCli = await importDevCli();
|
|
95
|
+
} catch (err) {
|
|
96
|
+
if (isMissingDevToolkitError(err)) {
|
|
97
|
+
writeError(buildMissingToolkitMessage(detectPm(), argv));
|
|
98
|
+
return 1;
|
|
99
|
+
}
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
devCli.cli(argv);
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
__name(runDevCliLauncher, "runDevCliLauncher");
|
|
106
|
+
export {
|
|
107
|
+
buildMissingToolkitMessage,
|
|
108
|
+
installCommand,
|
|
109
|
+
isMissingDevToolkitError,
|
|
110
|
+
runDevCliLauncher
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=dev-cli-launcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev-cli-launcher.ts"],"sourcesContent":["/**\n * Thin launcher for the `nextrush` meta-package's `bin`.\n *\n * `@nextrush/dev` is an optional dev-time toolkit, not a runtime dependency of `nextrush`\n * (docs/RFC/framework-composition/020-framework-composition-integrity.md §21; ADR-0013). This\n * launcher resolves it on demand: when present it delegates to its CLI transparently; when absent\n * it prints an actionable, package-manager-aware install message and exits non-zero, instead of the\n * shell's raw \"command not found\". All logic lives inside the exported functions — importing this\n * module has no side effect, so it never executes at install time.\n *\n * @see docs/adr/ADR-0013-nextrush-cli-launcher-discoverability.md\n */\n\nimport { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\n/** The `@nextrush/dev` CLI surface this launcher depends on. `cli()` reads `process.argv` itself. */\nexport interface DevCliModule {\n readonly cli: (argv?: string[]) => void;\n}\n\n/** Package managers whose install command the launcher can name precisely; `null` = inconclusive. */\nexport type LauncherPackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';\n\n/** Injectable seams — the defaults hit the real module loader / environment; tests substitute them. */\nexport interface DevCliLauncherDeps {\n readonly importDevCli?: () => Promise<DevCliModule>;\n readonly detectPackageManager?: () => LauncherPackageManager | null;\n readonly writeError?: (message: string) => void;\n /**\n * Directory `@nextrush/dev` must resolve relative to — the CONSUMING app's own directory,\n * never this package's. Defaults to `process.cwd()` at the real call site. A bare\n * `import('@nextrush/dev')` from inside this file would resolve against `nextrush`'s own\n * `node_modules`, which deliberately never has `@nextrush/dev` linked (ADR-0013) — so every\n * consumer, regardless of what THEY have installed, would see \"not installed.\" See ADR-0013\n * addendum and the regression test covering this.\n */\n readonly baseDir?: string;\n}\n\nconst MISSING_DEV_TOOLKIT_PATTERN = /Cannot find (?:module|package) ['\"]@nextrush\\/dev['\"]/;\n\n/**\n * True only when the error is specifically \"@nextrush/dev is not installed\" — not when\n * `@nextrush/dev` is present but one of ITS OWN dependencies is missing (whose message names that\n * other specifier, even though the `@nextrush/dev` path may appear in the \"imported from\" clause).\n */\nexport function isMissingDevToolkitError(err: unknown): boolean {\n const message = err instanceof Error ? err.message : String(err);\n return MISSING_DEV_TOOLKIT_PATTERN.test(message);\n}\n\n/** The exact `-D`/`-d` install command for a package manager (design D4). */\nexport function installCommand(pm: LauncherPackageManager | null): string {\n switch (pm) {\n case 'pnpm':\n return 'pnpm add -D @nextrush/dev';\n case 'yarn':\n return 'yarn add -D @nextrush/dev';\n case 'bun':\n return 'bun add -d @nextrush/dev';\n case 'npm':\n return 'npm install -D @nextrush/dev';\n default:\n // Inconclusive detection → package-manager-agnostic phrasing (design D4 fallback).\n return 'install @nextrush/dev as a dev dependency (e.g. `npm install -D @nextrush/dev`)';\n }\n}\n\n/** The `<prefix> nextrush …` invocation to suggest re-running, matching the invoking package manager. */\nfunction runHint(pm: LauncherPackageManager | null, attemptedArgv: readonly string[]): string {\n const prefix = pm === 'npm' ? 'npx' : (pm ?? '');\n return [prefix, 'nextrush', ...attemptedArgv].filter(Boolean).join(' ');\n}\n\n/**\n * The actionable message shown when the toolkit is absent: brands `@nextrush/dev` as the\n * Development Toolkit, gives the exact install command for the detected package manager, a one-line\n * description of what it provides, and a \"then run\" hint reflecting the command the user attempted\n * (fed.md Option 1).\n */\nexport function buildMissingToolkitMessage(\n pm: LauncherPackageManager | null,\n attemptedArgv: readonly string[] = []\n): string {\n const lines = [\n 'The NextRush Development Toolkit (@nextrush/dev) is not installed in this project.',\n '',\n 'Install it:',\n ` ${installCommand(pm)}`,\n '',\n 'It provides the hot-reload dev server, production builds, and code generators ' +\n '(nextrush dev / build / generate).',\n ];\n const hint = runHint(pm, attemptedArgv);\n if (attemptedArgv.length > 0) {\n lines.push('', 'Then run:', ` ${hint}`);\n }\n return lines.join('\\n');\n}\n\n/** Reads the invoking package manager from `npm_config_user_agent`; `null` when inconclusive. */\nfunction detectPackageManagerFromEnv(): LauncherPackageManager | null {\n const userAgent = process.env.npm_config_user_agent ?? '';\n if (userAgent.startsWith('pnpm')) return 'pnpm';\n if (userAgent.startsWith('yarn')) return 'yarn';\n // capability-exempt: 'bun' here identifies a PACKAGE MANAGER (npm/pnpm/yarn/bun), not a NextRush\n // JS-runtime capability — this never branches on which runtime is executing (mirrors\n // create-nextrush's detectPackageManager()).\n if (userAgent.startsWith('bun')) return 'bun';\n if (userAgent.startsWith('npm')) return 'npm';\n return null;\n}\n\nasync function importDevCliModule(baseDir: string): Promise<DevCliModule> {\n // Resolve relative to `baseDir` (the consuming app's own directory), never this file's own\n // location — a bare `import('@nextrush/dev')` here would resolve against `nextrush`'s own\n // node_modules, which never has `@nextrush/dev` linked by design (see DevCliLauncherDeps.baseDir).\n //\n // Neither `createRequire(baseDir).resolve()` (CJS-only — `@nextrush/dev`'s `exports` map has no\n // `require` condition, per the repo's ESM-only rule) nor `import.meta.resolve(specifier, parent)`\n // (the `parent` override is unreliable across Node versions — verified empirically: it silently\n // resolves against THIS file's own URL instead of `parent` on the Node version this was built\n // against) can do this correctly. Reading the target package's own `package.json` `exports` map\n // directly is the same information Node's resolver would use, without either broken path.\n const manifestPath = path.join(baseDir, 'node_modules', '@nextrush', 'dev', 'package.json');\n let manifestContents: string;\n try {\n manifestContents = await readFile(manifestPath, 'utf8');\n } catch {\n throw new Error(`Cannot find package '@nextrush/dev' imported from ${baseDir}`);\n }\n\n const manifest = JSON.parse(manifestContents) as { exports?: { '.'?: { import?: string } } };\n const entryRelativePath = manifest.exports?.['.']?.import;\n if (!entryRelativePath) {\n throw new Error(`@nextrush/dev's package.json at ${manifestPath} has no \"exports['.'].import\" entry`);\n }\n\n const packageDir = path.dirname(manifestPath);\n const entryAbsolutePath = path.join(packageDir, entryRelativePath);\n return (await import(pathToFileURL(entryAbsolutePath).href)) as DevCliModule;\n}\n\nfunction defaultWriteError(message: string): void {\n process.stderr.write(`${message}\\n`);\n}\n\n/**\n * Resolve `@nextrush/dev`'s CLI and delegate; on the specific \"toolkit not installed\" case, print\n * an actionable message and return a non-zero exit code. Any other error propagates unchanged.\n *\n * On the success path the underlying `cli()` reads `process.argv` and self-exits with its own code,\n * so the launcher does not need to re-propagate it; the returned `0` is reached only when `cli()`\n * returns without exiting (e.g. `--help`).\n *\n * @param argv - The CLI arguments (`process.argv.slice(2)`), passed through to the delegate.\n * @param deps - Injectable seams for testing; defaults use the real loader and environment.\n * @returns The exit code the launcher itself controls (non-zero when the toolkit is absent).\n */\nexport async function runDevCliLauncher(argv: string[], deps: DevCliLauncherDeps = {}): Promise<number> {\n const baseDir = deps.baseDir ?? process.cwd();\n const importDevCli = deps.importDevCli ?? (() => importDevCliModule(baseDir));\n const detectPm = deps.detectPackageManager ?? detectPackageManagerFromEnv;\n const writeError = deps.writeError ?? defaultWriteError;\n\n let devCli: DevCliModule;\n try {\n devCli = await importDevCli();\n } catch (err: unknown) {\n if (isMissingDevToolkitError(err)) {\n writeError(buildMissingToolkitMessage(detectPm(), argv));\n return 1;\n }\n throw err;\n }\n\n devCli.cli(argv);\n return 0;\n}\n"],"mappings":"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","names":["readFile","path","pathToFileURL","MISSING_DEV_TOOLKIT_PATTERN","isMissingDevToolkitError","err","message","Error","String","test","installCommand","pm","runHint","attemptedArgv","prefix","filter","Boolean","join","buildMissingToolkitMessage","lines","hint","length","push","detectPackageManagerFromEnv","userAgent","process","env","npm_config_user_agent","startsWith","importDevCliModule","baseDir","manifestPath","path","manifestContents","readFile","manifest","JSON","parse","entryRelativePath","exports","import","packageDir","dirname","entryAbsolutePath","pathToFileURL","href","defaultWriteError","stderr","write","runDevCliLauncher","argv","deps","cwd","importDevCli","detectPm","detectPackageManager","writeError","devCli","cli"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
import { ApplicationOptions, Application } from '@nextrush/core';
|
|
2
|
+
export { Application, ApplicationOptions, ComposedMiddleware, compose } from '@nextrush/core';
|
|
3
|
+
export { Router, RouterOptions, createRouter, endpoint } from '@nextrush/router';
|
|
3
4
|
export { ServeOptions, ServerInstance, createHandler, listen, serve } from '@nextrush/adapter-node';
|
|
4
|
-
export { BadGatewayError, BadRequestError, ConflictError, ErrorHandlerOptions, ForbiddenError, GatewayTimeoutError, HttpError, HttpErrorOptions, InternalServerError, MethodNotAllowedError, NextRushError, NotFoundError, NotImplementedError, ServiceUnavailableError, TooManyRequestsError, UnauthorizedError, UnprocessableEntityError,
|
|
5
|
-
export { ContentType, Context, HttpMethod, HttpStatus, HttpStatusCode, Middleware, Next,
|
|
5
|
+
export { BadGatewayError, BadRequestError, ConflictError, ERROR_CODES, ErrorHandlerOptions, ForbiddenError, GatewayTimeoutError, HttpError, HttpErrorOptions, InternalServerError, MethodNotAllowedError, NextRushError, NotFoundError, NotImplementedError, ServiceUnavailableError, TooManyRequestsError, UnauthorizedError, UnprocessableEntityError, ValidationError, ValidationIssue, codeForStatus, createError, errorHandler, isHttpError, notFoundHandler } from '@nextrush/errors';
|
|
6
|
+
export { ContentType, Context, Extension, ExtensionContext, HttpMethod, HttpStatus, HttpStatusCode, Middleware, Next, RouteDefinition, RouteHandler, RouteMetadata, Runtime } from '@nextrush/types';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* NextRush - Minimal, Modular, Blazing Fast Node.js Framework
|
|
@@ -44,7 +45,7 @@ export { ContentType, Context, HttpMethod, HttpStatus, HttpStatusCode, Middlewar
|
|
|
44
45
|
* });
|
|
45
46
|
*
|
|
46
47
|
* app.route('/', router);
|
|
47
|
-
* listen(app,
|
|
48
|
+
* listen(app, 8080);
|
|
48
49
|
* ```
|
|
49
50
|
*
|
|
50
51
|
* @example With Middleware (install separately)
|
|
@@ -57,13 +58,13 @@ export { ContentType, Context, HttpMethod, HttpStatus, HttpStatusCode, Middlewar
|
|
|
57
58
|
* app.use(cors());
|
|
58
59
|
* app.use(json());
|
|
59
60
|
*
|
|
60
|
-
* listen(app,
|
|
61
|
+
* listen(app, 8080);
|
|
61
62
|
* ```
|
|
62
63
|
*
|
|
63
64
|
* @example Class-Based (import from nextrush/class)
|
|
64
65
|
* ```typescript
|
|
65
66
|
* import { createApp, listen } from 'nextrush';
|
|
66
|
-
* import { Controller, Get, Service,
|
|
67
|
+
* import { Controller, Get, Service, registerControllers } from 'nextrush/class';
|
|
67
68
|
*
|
|
68
69
|
* @Service()
|
|
69
70
|
* class UserService {
|
|
@@ -79,11 +80,30 @@ export { ContentType, Context, HttpMethod, HttpStatus, HttpStatusCode, Middlewar
|
|
|
79
80
|
* }
|
|
80
81
|
*
|
|
81
82
|
* const app = createApp();
|
|
82
|
-
* app
|
|
83
|
-
* listen(app,
|
|
83
|
+
* await registerControllers(app, { root: './src' });
|
|
84
|
+
* await listen(app, 8080);
|
|
84
85
|
* ```
|
|
85
86
|
*/
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Create an application with a default router wired in, so `app.get`/`app.post`
|
|
90
|
+
* work out of the box.
|
|
91
|
+
*
|
|
92
|
+
* The functional `nextrush` entry is deliberately DI-free: it does NOT import or
|
|
93
|
+
* attach a `@nextrush/di` container. Doing so would transitively load
|
|
94
|
+
* `reflect-metadata` + tsyringe, making functional users pay a cost that belongs
|
|
95
|
+
* only to the class-based paradigm (see NEW-1 in
|
|
96
|
+
* docs/audits/class-based-master-audit.md).
|
|
97
|
+
*
|
|
98
|
+
* The container is bring-your-own: pass `options.container` to attach one. Class
|
|
99
|
+
* users are unaffected — they import from `nextrush/class`, and
|
|
100
|
+
* `registerControllers` supplies the global `@nextrush/di` container fallback
|
|
101
|
+
* itself (`options.container ?? app.container ?? globalContainer`). See
|
|
102
|
+
* docs/RFC/class-runtime/006-di-container-ownership.md.
|
|
103
|
+
*
|
|
104
|
+
* Import `createApp` from `@nextrush/core` for a minimal engine where the router
|
|
105
|
+
* is also bring-your-own.
|
|
106
|
+
*/
|
|
107
|
+
declare function createApp(options?: ApplicationOptions): Application;
|
|
88
108
|
|
|
89
|
-
export {
|
|
109
|
+
export { createApp };
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-7QVYU63E.js";
|
|
4
|
+
|
|
1
5
|
// src/index.ts
|
|
2
|
-
import { Application, compose, createApp } from "@nextrush/core";
|
|
3
|
-
import { createRouter
|
|
6
|
+
import { Application, compose, createApp as createBareApp } from "@nextrush/core";
|
|
7
|
+
import { createRouter as createDefaultRouter } from "@nextrush/router";
|
|
8
|
+
import { Router, createRouter, endpoint } from "@nextrush/router";
|
|
4
9
|
import { createHandler, listen, serve } from "@nextrush/adapter-node";
|
|
5
10
|
import {
|
|
6
11
|
BadGatewayError,
|
|
7
12
|
BadRequestError,
|
|
8
|
-
catchAsync,
|
|
9
13
|
ConflictError,
|
|
10
|
-
createError,
|
|
11
|
-
errorHandler,
|
|
12
14
|
ForbiddenError,
|
|
13
15
|
GatewayTimeoutError,
|
|
14
16
|
HttpError,
|
|
15
17
|
InternalServerError,
|
|
16
|
-
isHttpError,
|
|
17
18
|
MethodNotAllowedError,
|
|
18
19
|
NextRushError,
|
|
19
20
|
NotFoundError,
|
|
20
|
-
notFoundHandler,
|
|
21
21
|
NotImplementedError,
|
|
22
22
|
ServiceUnavailableError,
|
|
23
23
|
TooManyRequestsError,
|
|
24
24
|
UnauthorizedError,
|
|
25
|
-
UnprocessableEntityError
|
|
25
|
+
UnprocessableEntityError,
|
|
26
|
+
createError,
|
|
27
|
+
errorHandler,
|
|
28
|
+
isHttpError,
|
|
29
|
+
notFoundHandler,
|
|
30
|
+
ERROR_CODES,
|
|
31
|
+
codeForStatus,
|
|
32
|
+
ValidationError
|
|
26
33
|
} from "@nextrush/errors";
|
|
27
34
|
import { ContentType, HttpStatus } from "@nextrush/types";
|
|
28
|
-
|
|
35
|
+
function createApp(options) {
|
|
36
|
+
const router = options?.router ?? createDefaultRouter();
|
|
37
|
+
return createBareApp({
|
|
38
|
+
...options,
|
|
39
|
+
router
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
__name(createApp, "createApp");
|
|
29
43
|
export {
|
|
30
44
|
Application,
|
|
31
45
|
BadGatewayError,
|
|
32
46
|
BadRequestError,
|
|
33
47
|
ConflictError,
|
|
34
48
|
ContentType,
|
|
49
|
+
ERROR_CODES,
|
|
35
50
|
ForbiddenError,
|
|
36
51
|
GatewayTimeoutError,
|
|
37
52
|
HttpError,
|
|
@@ -46,13 +61,14 @@ export {
|
|
|
46
61
|
TooManyRequestsError,
|
|
47
62
|
UnauthorizedError,
|
|
48
63
|
UnprocessableEntityError,
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
ValidationError,
|
|
65
|
+
codeForStatus,
|
|
51
66
|
compose,
|
|
52
67
|
createApp,
|
|
53
68
|
createError,
|
|
54
69
|
createHandler,
|
|
55
70
|
createRouter,
|
|
71
|
+
endpoint,
|
|
56
72
|
errorHandler,
|
|
57
73
|
isHttpError,
|
|
58
74
|
listen,
|