nextrush 3.0.7 → 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 +386 -134
- 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 -8
- 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 +108 -4
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/package.json +33 -16
- package/scripts/postinstall.d.ts +0 -5
- package/scripts/postinstall.js +0 -84
package/dist/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
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 {
|
|
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,
|
|
@@ -18,19 +23,30 @@ import {
|
|
|
18
23
|
TooManyRequestsError,
|
|
19
24
|
UnauthorizedError,
|
|
20
25
|
UnprocessableEntityError,
|
|
21
|
-
catchAsync,
|
|
22
26
|
createError,
|
|
23
27
|
errorHandler,
|
|
24
28
|
isHttpError,
|
|
25
|
-
notFoundHandler
|
|
29
|
+
notFoundHandler,
|
|
30
|
+
ERROR_CODES,
|
|
31
|
+
codeForStatus,
|
|
32
|
+
ValidationError
|
|
26
33
|
} from "@nextrush/errors";
|
|
27
34
|
import { ContentType, HttpStatus } from "@nextrush/types";
|
|
35
|
+
function createApp(options) {
|
|
36
|
+
const router = options?.router ?? createDefaultRouter();
|
|
37
|
+
return createBareApp({
|
|
38
|
+
...options,
|
|
39
|
+
router
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
__name(createApp, "createApp");
|
|
28
43
|
export {
|
|
29
44
|
Application,
|
|
30
45
|
BadGatewayError,
|
|
31
46
|
BadRequestError,
|
|
32
47
|
ConflictError,
|
|
33
48
|
ContentType,
|
|
49
|
+
ERROR_CODES,
|
|
34
50
|
ForbiddenError,
|
|
35
51
|
GatewayTimeoutError,
|
|
36
52
|
HttpError,
|
|
@@ -45,12 +61,14 @@ export {
|
|
|
45
61
|
TooManyRequestsError,
|
|
46
62
|
UnauthorizedError,
|
|
47
63
|
UnprocessableEntityError,
|
|
48
|
-
|
|
64
|
+
ValidationError,
|
|
65
|
+
codeForStatus,
|
|
49
66
|
compose,
|
|
50
67
|
createApp,
|
|
51
68
|
createError,
|
|
52
69
|
createHandler,
|
|
53
70
|
createRouter,
|
|
71
|
+
endpoint,
|
|
54
72
|
errorHandler,
|
|
55
73
|
isHttpError,
|
|
56
74
|
listen,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * NextRush - Minimal, Modular, Blazing Fast Node.js Framework\n *\n * This meta package provides the **functional** API for building Node.js APIs:\n * - Application creation (createApp)\n * - Routing (createRouter)\n * - Server start (listen)\n * - HTTP errors\n * - Essential types\n *\n * For the class-based paradigm (DI, decorators, controllers),\n * import from `nextrush/class` instead.\n *\n * For middleware, install separately:\n * - @nextrush/cors\n * - @nextrush/helmet\n * - @nextrush/body-parser\n * - @nextrush/rate-limit\n * - @nextrush/logger\n *\n * For other runtimes, install the appropriate adapter:\n * - @nextrush/adapter-bun\n * - @nextrush/adapter-deno\n * - @nextrush/adapter-edge\n *\n * @packageDocumentation\n * @module nextrush\n *\n * @example Quick Start (Functional)\n * ```typescript\n * import { createApp, createRouter, listen } from 'nextrush';\n *\n * const app = createApp();\n * const router = createRouter();\n *\n * router.get('/', (ctx) => {\n * ctx.json({ message: 'Hello NextRush!' });\n * });\n *\n * app.route('/', router);\n * listen(app,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * NextRush - Minimal, Modular, Blazing Fast Node.js Framework\n *\n * This meta package provides the **functional** API for building Node.js APIs:\n * - Application creation (createApp)\n * - Routing (createRouter)\n * - Server start (listen)\n * - HTTP errors\n * - Essential types\n *\n * For the class-based paradigm (DI, decorators, controllers),\n * import from `nextrush/class` instead.\n *\n * For middleware, install separately:\n * - @nextrush/cors\n * - @nextrush/helmet\n * - @nextrush/body-parser\n * - @nextrush/rate-limit\n * - @nextrush/logger\n *\n * For other runtimes, install the appropriate adapter:\n * - @nextrush/adapter-bun\n * - @nextrush/adapter-deno\n * - @nextrush/adapter-edge\n *\n * @packageDocumentation\n * @module nextrush\n *\n * @example Quick Start (Functional)\n * ```typescript\n * import { createApp, createRouter, listen } from 'nextrush';\n *\n * const app = createApp();\n * const router = createRouter();\n *\n * router.get('/', (ctx) => {\n * ctx.json({ message: 'Hello NextRush!' });\n * });\n *\n * app.route('/', router);\n * listen(app, 8080);\n * ```\n *\n * @example With Middleware (install separately)\n * ```typescript\n * import { createApp, listen } from 'nextrush';\n * import { cors } from '@nextrush/cors';\n * import { json } from '@nextrush/body-parser';\n *\n * const app = createApp();\n * app.use(cors());\n * app.use(json());\n *\n * listen(app, 8080);\n * ```\n *\n * @example Class-Based (import from nextrush/class)\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// CORE: Application & Middleware Composition\n// ============================================\nimport {\n Application,\n compose,\n createApp as createBareApp,\n type ApplicationOptions,\n} from '@nextrush/core';\nimport { createRouter as createDefaultRouter } from '@nextrush/router';\n\n/**\n * Create an application with a default router wired in, so `app.get`/`app.post`\n * work out of the box.\n *\n * The functional `nextrush` entry is deliberately DI-free: it does NOT import or\n * attach a `@nextrush/di` container. Doing so would transitively load\n * `reflect-metadata` + tsyringe, making functional users pay a cost that belongs\n * only to the class-based paradigm (see NEW-1 in\n * docs/audits/class-based-master-audit.md).\n *\n * The container is bring-your-own: pass `options.container` to attach one. Class\n * users are unaffected — they import from `nextrush/class`, and\n * `registerControllers` supplies the global `@nextrush/di` container fallback\n * itself (`options.container ?? app.container ?? globalContainer`). See\n * docs/RFC/class-runtime/006-di-container-ownership.md.\n *\n * Import `createApp` from `@nextrush/core` for a minimal engine where the router\n * is also bring-your-own.\n */\nexport function createApp(options?: ApplicationOptions): Application {\n const router = options?.router ?? createDefaultRouter();\n return createBareApp({ ...options, router });\n}\n\nexport { Application, compose };\nexport type { ApplicationOptions, ComposedMiddleware } from '@nextrush/core';\n\n// ============================================\n// ROUTER: Segment Trie Routing + Route Metadata\n// ============================================\nexport { Router, createRouter, endpoint } from '@nextrush/router';\nexport type { RouterOptions } from '@nextrush/router';\n\n// ============================================\n// ADAPTER: Node.js HTTP (Default Runtime)\n// ============================================\nexport { createHandler, listen, serve } from '@nextrush/adapter-node';\nexport type { ServeOptions, ServerInstance } from '@nextrush/adapter-node';\n\n// ============================================\n// ERRORS: HTTP Error Classes & Factory\n// ============================================\nexport {\n BadGatewayError,\n // 4xx Client Errors\n BadRequestError, ConflictError, ForbiddenError,\n GatewayTimeoutError,\n // Base\n HttpError,\n // 5xx Server Errors\n InternalServerError, MethodNotAllowedError,\n NextRushError,\n NotFoundError, NotImplementedError,\n ServiceUnavailableError,\n TooManyRequestsError,\n UnauthorizedError,\n UnprocessableEntityError,\n // Factory functions\n createError,\n // Error handling middleware\n errorHandler, isHttpError, notFoundHandler,\n // Central error-code registry + validation (audit N-4)\n ERROR_CODES,\n codeForStatus,\n ValidationError\n} from '@nextrush/errors';\n\nexport type { ErrorHandlerOptions, HttpErrorOptions, ValidationIssue } from '@nextrush/errors';\n\n// ============================================\n// TYPES: Essential TypeScript Types\n// ============================================\nexport type {\n // Core types\n Context,\n // Extension model\n Extension,\n ExtensionContext,\n // HTTP types\n HttpMethod,\n HttpStatusCode,\n Middleware,\n Next,\n RouteHandler,\n // Route metadata (author with endpoint(); read by @nextrush/openapi)\n RouteDefinition,\n RouteMetadata,\n // Runtime\n Runtime\n} from '@nextrush/types';\n\n// HTTP constants\nexport { ContentType, HttpStatus } from '@nextrush/types';\n\n// NOTE: VERSION is not exported from the core package to maintain\n// Edge runtime compatibility (no node:fs). Use @nextrush/dev or\n// check package.json directly if you need the version.\n"],"mappings":";;;;;AAmFA,SACEA,aACAC,SACAC,aAAaC,qBAER;AACP,SAASC,gBAAgBC,2BAA2B;AAgCpD,SAASC,QAAQF,cAAcG,gBAAgB;AAM/C,SAASC,eAAeC,QAAQC,aAAa;AAM7C;EACIC;EAEAC;EAAiBC;EAAeC;EAChCC;EAEAC;EAEAC;EAAqBC;EACrBC;EACAC;EAAeC;EACfC;EACAC;EACAC;EACAC;EAEAC;EAEAC;EAAcC;EAAaC;EAE3BC;EACAC;EACAC;OACG;AA2BP,SAASC,aAAaC,kBAAkB;AAzEjC,SAASC,UAAUC,SAA4B;AACpD,QAAMC,SAASD,SAASC,UAAUC,oBAAAA;AAClC,SAAOC,cAAc;IAAE,GAAGH;IAASC;EAAO,CAAA;AAC5C;AAHgBF;","names":["Application","compose","createApp","createBareApp","createRouter","createDefaultRouter","Router","endpoint","createHandler","listen","serve","BadGatewayError","BadRequestError","ConflictError","ForbiddenError","GatewayTimeoutError","HttpError","InternalServerError","MethodNotAllowedError","NextRushError","NotFoundError","NotImplementedError","ServiceUnavailableError","TooManyRequestsError","UnauthorizedError","UnprocessableEntityError","createError","errorHandler","isHttpError","notFoundHandler","ERROR_CODES","codeForStatus","ValidationError","ContentType","HttpStatus","createApp","options","router","createDefaultRouter","createBareApp"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextrush",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "Minimal, modular, blazing fast Node.js framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,9 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
|
-
"
|
|
21
|
+
"bin",
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
|
+
"bin": {
|
|
25
|
+
"nextrush": "./bin/nextrush.js"
|
|
26
|
+
},
|
|
24
27
|
"keywords": [
|
|
25
28
|
"framework",
|
|
26
29
|
"web",
|
|
@@ -59,27 +62,41 @@
|
|
|
59
62
|
"./dist/class.js"
|
|
60
63
|
],
|
|
61
64
|
"dependencies": {
|
|
65
|
+
"@nextrush/adapter-node": "4.0.0-beta.0",
|
|
66
|
+
"@nextrush/core": "4.0.0-beta.0",
|
|
67
|
+
"@nextrush/errors": "4.0.0-beta.0",
|
|
68
|
+
"@nextrush/router": "4.0.0-beta.0",
|
|
69
|
+
"@nextrush/types": "4.0.0-beta.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
62
72
|
"reflect-metadata": "^0.2.2",
|
|
63
|
-
"@nextrush/
|
|
64
|
-
"@nextrush/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"@nextrush/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"@nextrush/
|
|
73
|
+
"@nextrush/class": "1.0.0-beta.0",
|
|
74
|
+
"@nextrush/di": "4.0.0-beta.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependenciesMeta": {
|
|
77
|
+
"@nextrush/class": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"@nextrush/di": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"reflect-metadata": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
71
86
|
},
|
|
72
87
|
"devDependencies": {
|
|
88
|
+
"reflect-metadata": "^0.2.2",
|
|
73
89
|
"tsup": "^8.5.1",
|
|
74
|
-
"typescript": "^6.0.
|
|
75
|
-
"vitest": "^4.1.
|
|
76
|
-
"@nextrush/body-parser": "
|
|
90
|
+
"typescript": "^6.0.3",
|
|
91
|
+
"vitest": "^4.1.10",
|
|
92
|
+
"@nextrush/body-parser": "4.0.0-beta.0",
|
|
77
93
|
"@nextrush/compression": "3.0.5",
|
|
78
|
-
"@nextrush/
|
|
79
|
-
"@nextrush/
|
|
94
|
+
"@nextrush/class": "1.0.0-beta.0",
|
|
95
|
+
"@nextrush/cors": "4.0.0-beta.0",
|
|
96
|
+
"@nextrush/di": "4.0.0-beta.0",
|
|
97
|
+
"@nextrush/helmet": "4.0.0-beta.0"
|
|
80
98
|
},
|
|
81
99
|
"scripts": {
|
|
82
|
-
"postinstall": "node scripts/postinstall.js",
|
|
83
100
|
"build": "tsup",
|
|
84
101
|
"clean": "rm -rf dist",
|
|
85
102
|
"typecheck": "tsc --noEmit",
|
package/scripts/postinstall.d.ts
DELETED
package/scripts/postinstall.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* nextrush postinstall script
|
|
5
|
-
*
|
|
6
|
-
* Automatically installs @nextrush/dev (dev server & build CLI) when
|
|
7
|
-
* a user installs the `nextrush` meta package. This ensures `nextrush dev`
|
|
8
|
-
* and `nextrush build` commands work out of the box.
|
|
9
|
-
*
|
|
10
|
-
* Skips installation when:
|
|
11
|
-
* - Running in CI (process.env.CI is set)
|
|
12
|
-
* - NEXTRUSH_SKIP_POSTINSTALL=1 is set
|
|
13
|
-
* - @nextrush/dev is already resolvable
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { createRequire } from 'node:module';
|
|
17
|
-
import { execSync } from 'node:child_process';
|
|
18
|
-
|
|
19
|
-
export function shouldSkip() {
|
|
20
|
-
if (process.env.CI) return true;
|
|
21
|
-
if (process.env.NEXTRUSH_SKIP_POSTINSTALL === '1') return true;
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isDevInstalled() {
|
|
26
|
-
const require = createRequire(import.meta.url);
|
|
27
|
-
try {
|
|
28
|
-
require.resolve('@nextrush/dev');
|
|
29
|
-
return true;
|
|
30
|
-
} catch {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function detectPackageManager() {
|
|
36
|
-
const userAgent = process.env.npm_config_user_agent || '';
|
|
37
|
-
|
|
38
|
-
if (userAgent.includes('pnpm')) return 'pnpm';
|
|
39
|
-
if (userAgent.includes('yarn')) return 'yarn';
|
|
40
|
-
if (userAgent.includes('bun')) return 'bun';
|
|
41
|
-
return 'npm';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getInstallCommand(packageManager) {
|
|
45
|
-
const cmds = {
|
|
46
|
-
pnpm: 'pnpm add -D @nextrush/dev@latest',
|
|
47
|
-
yarn: 'yarn add -D @nextrush/dev@latest',
|
|
48
|
-
bun: 'bun add -D @nextrush/dev@latest',
|
|
49
|
-
npm: 'npm install -D @nextrush/dev@latest',
|
|
50
|
-
};
|
|
51
|
-
return cmds[packageManager];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function installDevPackage(packageManager) {
|
|
55
|
-
const cmd = getInstallCommand(packageManager);
|
|
56
|
-
console.log('\n[nextrush] Installing @nextrush/dev (dev server & build CLI)...');
|
|
57
|
-
try {
|
|
58
|
-
execSync(cmd, { stdio: 'inherit' });
|
|
59
|
-
console.log('[nextrush] @nextrush/dev installed successfully.');
|
|
60
|
-
return true;
|
|
61
|
-
} catch {
|
|
62
|
-
console.warn('[nextrush] Warning: Failed to auto-install @nextrush/dev.');
|
|
63
|
-
console.warn(`[nextrush] Run manually: ${cmd}`);
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Only run when executed directly (not imported for testing)
|
|
69
|
-
const isMainModule = process.argv[1] &&
|
|
70
|
-
(process.argv[1].endsWith('postinstall.js') || process.argv[1].endsWith('postinstall'));
|
|
71
|
-
|
|
72
|
-
if (isMainModule) {
|
|
73
|
-
if (shouldSkip()) {
|
|
74
|
-
process.exit(0);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (isDevInstalled()) {
|
|
78
|
-
process.exit(0);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const pm = detectPackageManager();
|
|
82
|
-
const success = installDevPackage(pm);
|
|
83
|
-
process.exit(success ? 0 : 0); // Don't fail the parent install
|
|
84
|
-
}
|