diff --git a/.github/workflows/release.beta.yml b/.github/workflows/release.beta.yml index c160deb..a036f17 100644 --- a/.github/workflows/release.beta.yml +++ b/.github/workflows/release.beta.yml @@ -11,8 +11,8 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: - node-version: '22' - - run: npm install --global npm@10 + node-version: '24' + - run: npm install --global npm@11 - run: npm ci - uses: JS-DevTools/npm-publish@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e924379..3506268 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,8 +23,8 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: - node-version: '22' - - run: npm install --global npm@10 + node-version: '24' + - run: npm install --global npm@11 - run: npm ci - uses: JS-DevTools/npm-publish@v4 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e36c16..a6f2bdf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - node: ['22', '24'] + node: ['24'] os: [macos-latest, ubuntu-latest, windows-latest] steps: @@ -23,7 +23,7 @@ jobs: - uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} - - run: npm install -g npm@10 + - run: npm install -g npm@11 - run: npm ci - run: npm install -g . - run: npm test diff --git a/CHANGELOG.md b/CHANGELOG.md index ac5a131..ef5ef9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- **[BREAKING]** API Hosting runtime version from Node.js 18 to [Node.js 22](https://nodejs.org/en/blog/announcements/v22-release-announce) -- Require minimum [Node.js 22](https://nodejs.org/en/blog/announcements/v22-release-announce) +- **[BREAKING]** API Hosting runtime version from Node.js 18 to [Node.js 24](https://nodejs.org/en/blog/release/v24.11.0) +- Require minimum [Node.js 24](https://nodejs.org/en/blog/release/v24.11.0) ### Removed diff --git a/docs/README.md b/docs/README.md index 9473047..960d456 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,8 +2,8 @@ ## Requirements -- [Node.js](https://nodejs.org/) 22.0 or newer -- NPM 10.0 or newer +- [Node.js](https://nodejs.org/) 24.0 or newer +- NPM 11.0 or newer ## Installation diff --git a/docs/api/environment.md b/docs/api/environment.md index ca4bb71..b1cec3b 100644 --- a/docs/api/environment.md +++ b/docs/api/environment.md @@ -2,12 +2,12 @@ ## Execution Environment -- Code executes within a Linux environment with [Node.js 22](https://nodejs.org/dist/latest-v22.x/docs/api/) +- Code executes within a Linux environment with [Node.js 24](https://nodejs.org/dist/latest-v24.x/docs/api/) - If you use features not available in this version of Node.js, transpile before deployment. NPM packages using native binaries can be installed using docker: ``` - docker run -it --rm -v ${PWD}:/app -w /app node:22 npm install + docker run -it --rm -v ${PWD}:/app -w /app node:24 npm install ``` * The environment your code executes in is arbitrarily destroyed between requests diff --git a/eslint.config.mjs b/eslint.config.mjs index 6aa82d6..3914c1d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -17,13 +17,7 @@ const compat = new FlatCompat({ export default [ { - ignores: [ - '**/node_modules', - '**/examples', - '**/docs', - '**/dist', - '**/my-serverless', - ], + ignores: ['./node_modules/**', './examples/**', './docs/**', './dist/**'], }, ...pluginMicrosoftSdl.configs.recommended, ...compat.extends( @@ -42,8 +36,7 @@ export default [ }, parser: tsParser, - ecmaVersion: 2020, - sourceType: 'commonjs', + ecmaVersion: 2024, parserOptions: { project: './tsconfig.eslint.json' }, }, diff --git a/index.d.ts b/index.d.ts index aeac580..8776ca8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -6,7 +6,7 @@ export type OneBlinkAPIHostingRequest = { url: { host: string hostname: string - params: { [id: string]: string } + params: Record pathname: string protocol: 'http:' | 'https:' query: Record diff --git a/package-lock.json b/package-lock.json index 03f1aba..24b487f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,6 @@ "recursive-copy": "^2.0.14", "s3-sync-client": "^4.3.1", "temp": "^0.9.4", - "uniloc": "^0.3.0", "update-notifier": "^7.3.1", "valid-url": "^1.0.9", "write-json-file": "^7.0.0" @@ -61,6 +60,7 @@ "@types/mime-types": "^3.0.1", "@types/minimist": "^1.2.5", "@types/morgan": "^1.9.10", + "@types/node": "^24.10.8", "@types/object-merge": "^2.5.3", "@types/temp": "^0.9.4", "@types/update-notifier": "^6.0.8", @@ -82,8 +82,8 @@ "yauzl": "^3.2.0" }, "engines": { - "node": ">=22", - "npm": ">=10" + "node": ">=24", + "npm": ">=11" } }, "node_modules/@aws-crypto/crc32": { @@ -4739,13 +4739,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.13.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.5.tgz", - "integrity": "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg==", + "version": "24.10.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.8.tgz", + "integrity": "sha512-r0bBaXu5Swb05doFYO2kTWHMovJnNVbCsII0fhesM8bNRlLhXIuckley4a2DaD+vOdmm5G+zGkQZAPZsF80+YQ==", "devOptional": true, "license": "MIT", "dependencies": { - "undici-types": "~6.20.0" + "undici-types": "~7.16.0" } }, "node_modules/@types/normalize-package-data": { @@ -12805,9 +12805,9 @@ } }, "node_modules/undici-types": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", - "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "devOptional": true, "license": "MIT" }, @@ -12823,12 +12823,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/uniloc": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/uniloc/-/uniloc-0.3.0.tgz", - "integrity": "sha512-e5ww85FupZlbS5VihjB6pKKrpTNS46NBL4Iqfo8S2KXFYwXjo/NeELqtOmHYnG//gsOoOaIVAvkWyGZbafN89Q==", - "license": "MIT" - }, "node_modules/universal-user-agent": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", diff --git a/package.json b/package.json index a241898..4bf31c3 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "recursive-copy": "^2.0.14", "s3-sync-client": "^4.3.1", "temp": "^0.9.4", - "uniloc": "^0.3.0", "update-notifier": "^7.3.1", "valid-url": "^1.0.9", "write-json-file": "^7.0.0" @@ -63,6 +62,7 @@ "@types/mime-types": "^3.0.1", "@types/minimist": "^1.2.5", "@types/morgan": "^1.9.10", + "@types/node": "^24.10.8", "@types/object-merge": "^2.5.3", "@types/temp": "^0.9.4", "@types/update-notifier": "^6.0.8", @@ -87,8 +87,8 @@ "test": "test" }, "engines": { - "node": ">=22", - "npm": ">=10" + "node": ">=24", + "npm": ">=11" }, "exports": "./index.js", "files": [ diff --git a/src/api/handlers.ts b/src/api/handlers.ts index 45cde57..ce3336c 100644 --- a/src/api/handlers.ts +++ b/src/api/handlers.ts @@ -1,7 +1,6 @@ +import { URLPattern } from 'url' import type { RouteConfiguration } from './types.js' -import uniloc from 'uniloc' - import BmResponse from './bm-response.js' import { OneBlinkAPIHostingHandler, @@ -49,24 +48,19 @@ function findRouteConfig( route: string, routeConfigs: RouteConfiguration[], ): RouteConfiguration { - const unilocRoutes = routeConfigs.reduce>( - (memo, r) => { - memo[r.route] = `GET ${r.route.replace(/{/g, ':').replace(/}/g, '')}` - return memo - }, - {}, - ) - const unilocRouter = uniloc(unilocRoutes) - const unilocRoute = unilocRouter.lookup(route, 'GET') + const routeConfig = routeConfigs.find((routeConfig) => { + const urlPattern = new URLPattern({ + pathname: routeConfig.route.replace(/\{([^}]+)\}/g, ':$1'), + }) + const result = urlPattern.exec(route) + routeConfig.params = result?.pathname.groups + return result + }) - const routeConfig = routeConfigs.find( - (routeConfig) => routeConfig.route === unilocRoute.name, - ) if (!routeConfig) { throw new Error(`Route has not been implemented: ${route}`) } - routeConfig.params = unilocRoute.options return routeConfig } diff --git a/src/api/types.ts b/src/api/types.ts index aa100b1..93ae1b0 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -45,9 +45,7 @@ export type CLIOptions = { export type HandlerConfiguration = { handler: OneBlinkAPIHostingHandler | void - params: { - [id: string]: string - } + params: Record } export type Headers = OneBlinkAPIHostingRequest['headers'] @@ -84,7 +82,7 @@ export type Protocol = OneBlinkAPIHostingRequest['url']['protocol'] export type RouteConfiguration = APITypes.APIEnvironmentRoute & { timeout?: number - params?: { [id: string]: string } + params?: Record } export type ScheduledFunctionConfiguration = Omit< diff --git a/src/api/values.ts b/src/api/values.ts index b3ef488..1a319b1 100644 --- a/src/api/values.ts +++ b/src/api/values.ts @@ -28,7 +28,7 @@ const METHODS: Array = [ const DEFAULT_TIMEOUT_SECONDS = 15 export default { - AWS_LAMBDA_RUNTIME: 'nodejs22.x', + AWS_LAMBDA_RUNTIME: 'nodejs24.x', DEFAULT_CORS: { CREDENTIALS, EXPOSED_HEADERS, diff --git a/src/types/uniloc.d.ts b/src/types/uniloc.d.ts deleted file mode 100644 index 63fce3f..0000000 --- a/src/types/uniloc.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'uniloc' diff --git a/tsconfig.json b/tsconfig.json index c6afd10..d94496e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,10 +4,10 @@ /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ - "target": "ES2023" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, - "module": "Node16" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, + "target": "ES2024" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, + "module": "nodenext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, "lib": [ - "ES2023" + "ES2024" ] /* Specify library files to be included in the compilation. */, // "allowJs": true /* Allow javascript files to be compiled. */, // "checkJs": true, /* Report errors in .js files. */