Replace the linear, specificity-sorted scan behind matchRoute, resolveRoute and allowedMethods with a segment trie per HTTP method, built once per route array from the compiled segments compilePattern already produces. Ranking stays global: every terminal carries its position in the old sorted bucket (moreSpecific, declaration order on ties), and the walk keeps the lowest rank it can reach, pruning subtrees that cannot beat it. The tree decides which routes can match; the rank alone decides which one does. A static branch that dead-ends deeper backtracks into its param, constrained and catch-all siblings. All-static routes are also kept by exact path per method. A hit there is provably the tree's best match, so a static request is answered without splitting the path; a miss falls through to the walk. Mesh-spliced remote routes go in a second tree, per the owner's design decision. Both trees answer, the more specific match wins and an equal one goes to the earlier declaration, so local still beats remote on a tie. Allow, 405 and implicit HEAD run over the union. An app without remote routes does one lookup. allowedMethods walks the index instead of recompiling every route on a miss, and an implicit HEAD no longer builds a fresh index from a filtered array on every request. The frozen parity corpus passes unchanged. The frozen mutant script cannot run against the new layout by design, so test/router-index-mutants.ts re-targets its twelve bug classes at the new code and runs the same untouched suite. Refs #109 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
170 lines
4.5 KiB
JSON
170 lines
4.5 KiB
JSON
{
|
|
"name": "@green-tea/core",
|
|
"version": "26.9.0-beta.2",
|
|
"description": "A zen, opinionated, type-safe framework \u2014 your API is a graph, not a middleware chain.",
|
|
"license": "MIT",
|
|
"author": "green-tea contributors <projects@expressive-tea.io>",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/Expressive-Tea/green-tea.git"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/Expressive-Tea/green-tea/issues",
|
|
"email": "projects@expressive-tea.io"
|
|
},
|
|
"homepage": "https://green-tea.expressive-tea.io/docs/",
|
|
"keywords": [
|
|
"http",
|
|
"framework",
|
|
"typescript",
|
|
"dependency-injection",
|
|
"decorators",
|
|
"dependency-graph",
|
|
"sse",
|
|
"websocket",
|
|
"streaming",
|
|
"node"
|
|
],
|
|
"engines": {
|
|
"node": ">=22"
|
|
},
|
|
"publishConfig": {
|
|
"access": "public"
|
|
},
|
|
"type": "commonjs",
|
|
"main": "./dist/index.js",
|
|
"module": "./dist/index.mjs",
|
|
"types": "./dist/index.d.ts",
|
|
"exports": {
|
|
".": {
|
|
"import": {
|
|
"types": "./dist/index.d.mts",
|
|
"default": "./dist/index.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/index.d.ts",
|
|
"default": "./dist/index.js"
|
|
}
|
|
},
|
|
"./deno": {
|
|
"import": {
|
|
"types": "./dist/deno.d.mts",
|
|
"default": "./dist/deno.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/deno.d.ts",
|
|
"default": "./dist/deno.js"
|
|
}
|
|
},
|
|
"./bun": {
|
|
"import": {
|
|
"types": "./dist/bun.d.mts",
|
|
"default": "./dist/bun.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/bun.d.ts",
|
|
"default": "./dist/bun.js"
|
|
}
|
|
},
|
|
"./edge": {
|
|
"import": {
|
|
"types": "./dist/edge.d.mts",
|
|
"default": "./dist/edge.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/edge.d.ts",
|
|
"default": "./dist/edge.js"
|
|
}
|
|
}
|
|
},
|
|
"files": [
|
|
"dist",
|
|
"assets",
|
|
"README.md",
|
|
"CHANGELOG.md",
|
|
"LICENSE"
|
|
],
|
|
"scripts": {
|
|
"build": "tsup",
|
|
"test": "vitest run",
|
|
"test:dev": "vitest",
|
|
"test:deno": "deno test --allow-net --allow-read --allow-run --allow-env --no-check test/deno/",
|
|
"test:bun": "bun test test/bun/",
|
|
"test:edge": "tsx test/edge/run.ts",
|
|
"test:all": "npm test && npm run test:deno && npm run test:bun && npm run test:edge && deno publish --dry-run --allow-dirty",
|
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
"typecheck:bench": "tsc --noEmit -p bench/tsconfig.json",
|
|
"lint": "eslint src",
|
|
"lint:fix": "eslint src --fix",
|
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
"complexity": "ccts src",
|
|
"complexity:check": "node scripts/check-complexity.mjs",
|
|
"complexity:cyclomatic": "cyclomatic-complexity \"src/**/*.ts\" -tw 15 -te 25",
|
|
"bench": "tsx bench/run.ts",
|
|
"bench:compare": "tsx bench/compare.ts",
|
|
"bench:lookup": "tsx bench/lookup.ts",
|
|
"parity:mutants": "tsx test/router-parity/mutants.ts",
|
|
"parity:mutants:index": "tsx test/router-index-mutants.ts",
|
|
"prepublishOnly": "npm run lint && npm run complexity:check && npm run typecheck && npm test && npm run build",
|
|
"prepare": "git config core.hooksPath .githooks || true"
|
|
},
|
|
"dependencies": {
|
|
"reflect-metadata": "0.2.2"
|
|
},
|
|
"peerDependencies": {
|
|
"busboy": "^1.6.0",
|
|
"ws": "^8.18.0"
|
|
},
|
|
"peerDependenciesMeta": {
|
|
"busboy": {
|
|
"optional": true
|
|
},
|
|
"ws": {
|
|
"optional": true
|
|
}
|
|
},
|
|
"overrides": {
|
|
"find-my-way": "9.7.0",
|
|
"autocannon": {
|
|
"hyperid": {
|
|
"uuid": "11.1.1"
|
|
}
|
|
},
|
|
"undici": "7.29.1",
|
|
"sharp": "0.35.5",
|
|
"fastify": "$fastify"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^9.39.5",
|
|
"@nestjs/common": "^11.1.28",
|
|
"@nestjs/core": "^11.1.28",
|
|
"@nestjs/platform-express": "^11.1.28",
|
|
"@nestjs/platform-fastify": "^11.1.28",
|
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
"@types/autocannon": "^7.12.7",
|
|
"@types/busboy": "^1.5.4",
|
|
"@types/express": "^5.0.6",
|
|
"@types/node": "^22.20.5",
|
|
"@types/ws": "^8.18.1",
|
|
"autocannon": "^8.0.0",
|
|
"busboy": "^1.6.0",
|
|
"cognitive-complexity-ts": "^0.8.2",
|
|
"eslint": "^9.39.5",
|
|
"esbuild": "0.27.2",
|
|
"express": "^5.2.1",
|
|
"fastify": "^5.12.5",
|
|
"graphql": "^16.9.0",
|
|
"miniflare": "^4.20260730.0",
|
|
"prettier": "^3.9.6",
|
|
"rxjs": "^7.8.2",
|
|
"tsup": "^8.5.1",
|
|
"tsx": "^4.23.5",
|
|
"typescript": "^5.5.0",
|
|
"typescript-eslint": "^8.65.0",
|
|
"vite": "^6.4.3",
|
|
"vitest": "^4.1.11",
|
|
"ws": "^8.21.1"
|
|
}
|
|
}
|