nextrush 3.0.7 → 4.0.0-beta.1

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/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 { Router, createRouter } from "@nextrush/router";
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
- catchAsync,
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, 3000);\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, 3000);\n * ```\n *\n * @example Class-Based (import from nextrush/class)\n * ```typescript\n * import { createApp, listen } from 'nextrush';\n * import { Controller, Get, Service, controllersPlugin } 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 * app.plugin(controllersPlugin({ root: './src' }));\n * listen(app, 3000);\n * ```\n */\n\n// ============================================\n// CORE: Application & Middleware Composition\n// ============================================\nexport { Application, compose, createApp } from '@nextrush/core';\nexport type { ApplicationOptions, ComposedMiddleware } from '@nextrush/core';\n\n// ============================================\n// ROUTER: Radix Tree Routing\n// ============================================\nexport { Router, createRouter } 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, catchAsync,\n // Factory functions\n createError,\n // Error handling middleware\n errorHandler, isHttpError, notFoundHandler\n} from '@nextrush/errors';\n\nexport type { ErrorHandlerOptions, HttpErrorOptions } from '@nextrush/errors';\n\n// ============================================\n// TYPES: Essential TypeScript Types\n// ============================================\nexport type {\n // Core types\n Context,\n // HTTP types\n HttpMethod,\n HttpStatusCode,\n Middleware,\n Next,\n Plugin,\n RouteHandler,\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,SAASA,aAAaC,SAASC,iBAAiB;AAMhD,SAASC,QAAQC,oBAAoB;AAMrC,SAASC,eAAeC,QAAQC,aAAa;AAM7C;EACIC;EAEAC;EAAiBC;EAAeC;EAChCC;EAEAC;EAEAC;EAAqBC;EACrBC;EACAC;EAAeC;EACfC;EACAC;EACAC;EACAC;EAA0BC;EAE1BC;EAEAC;EAAcC;EAAaC;OACxB;AAsBP,SAASC,aAAaC,kBAAkB;","names":["Application","compose","createApp","Router","createRouter","createHandler","listen","serve","BadGatewayError","BadRequestError","ConflictError","ForbiddenError","GatewayTimeoutError","HttpError","InternalServerError","MethodNotAllowedError","NextRushError","NotFoundError","NotImplementedError","ServiceUnavailableError","TooManyRequestsError","UnauthorizedError","UnprocessableEntityError","catchAsync","createError","errorHandler","isHttpError","notFoundHandler","ContentType","HttpStatus"]}
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"]}
@@ -0,0 +1 @@
1
+ export { AppSource, NextHandlerOptions, NextRouteContext, NextRouteHandler, NextRouteHandlers, NextRouteParams, handle } from '@nextrush/adapter-nextjs';
package/dist/nextjs.js ADDED
@@ -0,0 +1,8 @@
1
+ import "./chunk-7QVYU63E.js";
2
+
3
+ // src/nextjs.ts
4
+ import { handle } from "@nextrush/adapter-nextjs";
5
+ export {
6
+ handle
7
+ };
8
+ //# sourceMappingURL=nextjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/nextjs.ts"],"sourcesContent":["/**\n * NextRush Next.js Adapter — mount a NextRush app in a Next.js App Router\n * route handler\n *\n * Import from `nextrush/nextjs` when building an API route inside a Next.js\n * (App Router) project. This entry is a plain re-export — unlike\n * `nextrush/class`, `@nextrush/adapter-nextjs` never imports `next` at module\n * scope (its one `next/server` import, resolving `after()`, is deferred to\n * the first request), so no dynamic-import peer guard is needed here.\n *\n * @packageDocumentation\n * @module nextrush/nextjs\n *\n * @example\n * ```typescript\n * // app/api/[[...route]]/route.ts\n * import { createApp, createRouter } from 'nextrush';\n * import { handle } from 'nextrush/nextjs';\n *\n * const app = createApp();\n * const api = createRouter();\n * api.get('/hello', (ctx) => ctx.json({ message: 'Hello Next.js!' }));\n * app.route('/api', api);\n *\n * export const { GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS } = handle(app);\n * ```\n */\n\nexport { handle } from '@nextrush/adapter-nextjs';\nexport type {\n AppSource,\n NextHandlerOptions,\n NextRouteContext,\n NextRouteHandler,\n NextRouteHandlers,\n NextRouteParams,\n} from '@nextrush/adapter-nextjs';\n"],"mappings":";;;AA4BA,SAASA,cAAc;","names":["handle"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextrush",
3
- "version": "3.0.7",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "Minimal, modular, blazing fast Node.js framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,13 +14,20 @@
14
14
  "./class": {
15
15
  "types": "./dist/class.d.ts",
16
16
  "import": "./dist/class.js"
17
+ },
18
+ "./nextjs": {
19
+ "types": "./dist/nextjs.d.ts",
20
+ "import": "./dist/nextjs.js"
17
21
  }
18
22
  },
19
23
  "files": [
20
24
  "dist",
21
- "scripts",
25
+ "bin",
22
26
  "README.md"
23
27
  ],
28
+ "bin": {
29
+ "nextrush": "./bin/nextrush.js"
30
+ },
24
31
  "keywords": [
25
32
  "framework",
26
33
  "web",
@@ -59,27 +66,46 @@
59
66
  "./dist/class.js"
60
67
  ],
61
68
  "dependencies": {
69
+ "@nextrush/adapter-node": "4.0.0-beta.1",
70
+ "@nextrush/core": "4.0.0-beta.1",
71
+ "@nextrush/errors": "4.0.0-beta.1",
72
+ "@nextrush/router": "4.0.0-beta.1",
73
+ "@nextrush/types": "4.0.0-beta.1"
74
+ },
75
+ "peerDependencies": {
62
76
  "reflect-metadata": "^0.2.2",
63
- "@nextrush/adapter-node": "3.0.7",
64
- "@nextrush/controllers": "3.0.7",
65
- "@nextrush/core": "3.0.7",
66
- "@nextrush/decorators": "3.0.7",
67
- "@nextrush/di": "3.0.7",
68
- "@nextrush/errors": "3.0.7",
69
- "@nextrush/router": "3.0.7",
70
- "@nextrush/types": "3.0.7"
77
+ "@nextrush/adapter-nextjs": "1.0.0-beta.0",
78
+ "@nextrush/class": "1.0.0-beta.1",
79
+ "@nextrush/di": "4.0.0-beta.1"
80
+ },
81
+ "peerDependenciesMeta": {
82
+ "@nextrush/adapter-nextjs": {
83
+ "optional": true
84
+ },
85
+ "@nextrush/class": {
86
+ "optional": true
87
+ },
88
+ "@nextrush/di": {
89
+ "optional": true
90
+ },
91
+ "reflect-metadata": {
92
+ "optional": true
93
+ }
71
94
  },
72
95
  "devDependencies": {
96
+ "reflect-metadata": "^0.2.2",
73
97
  "tsup": "^8.5.1",
74
- "typescript": "^6.0.2",
75
- "vitest": "^4.1.4",
76
- "@nextrush/body-parser": "3.0.5",
98
+ "typescript": "^6.0.3",
99
+ "vitest": "^4.1.10",
100
+ "@nextrush/adapter-nextjs": "1.0.0-beta.0",
101
+ "@nextrush/class": "1.0.0-beta.1",
102
+ "@nextrush/body-parser": "4.0.0-beta.0",
103
+ "@nextrush/cors": "4.0.0-beta.0",
77
104
  "@nextrush/compression": "3.0.5",
78
- "@nextrush/cors": "3.0.5",
79
- "@nextrush/helmet": "3.0.5"
105
+ "@nextrush/di": "4.0.0-beta.1",
106
+ "@nextrush/helmet": "4.0.0-beta.0"
80
107
  },
81
108
  "scripts": {
82
- "postinstall": "node scripts/postinstall.js",
83
109
  "build": "tsup",
84
110
  "clean": "rm -rf dist",
85
111
  "typecheck": "tsc --noEmit",
@@ -1,5 +0,0 @@
1
- export function shouldSkip(): boolean;
2
- export function isDevInstalled(): boolean;
3
- export function detectPackageManager(): string;
4
- export function getInstallCommand(pm: string): string[];
5
- export function installDevPackage(pm: string): void;
@@ -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
- }