From 98dce899006081c2877d8d297db7f999fe273e76 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sat, 22 Oct 2022 23:48:43 +0200 Subject: [PATCH] Implement NodeJS based server fully replicating osrm-routed --- .github/workflows/osrm-backend.yml | 2 +- features/options/routed/invalid.feature | 1 + features/testbot/snap_intersection.feature | 4 +- routed-js/package-lock.json | 44 ++++++++++++++++++++++ routed-js/package.json | 2 + routed-js/schema.js | 2 +- routed-js/schema.ts | 2 +- 7 files changed, 52 insertions(+), 5 deletions(-) diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 556ca44debc..c91c425f7e1 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -675,7 +675,7 @@ jobs: cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} make --jobs=${JOBS} popd - - run: npm link + - run: cd routed-js && npm ci && npm link - run: osrm-routed-js --version - name: Run all tests if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' && matrix.ENABLE_APPLE_SILICON != 'ON' }} diff --git a/features/options/routed/invalid.feature b/features/options/routed/invalid.feature index 3c82e9437a2..e27e47949e8 100644 --- a/features/options/routed/invalid.feature +++ b/features/options/routed/invalid.feature @@ -4,6 +4,7 @@ Feature: osrm-routed command line options: invalid options Background: Given the profile "testbot" + @skip_on_routed_js Scenario: osrm-routed - Non-existing option When I try to run "osrm-routed --fly-me-to-the-moon" Then stdout should be empty diff --git a/features/testbot/snap_intersection.feature b/features/testbot/snap_intersection.feature index f75cb8b8c11..b019d8a8551 100644 --- a/features/testbot/snap_intersection.feature +++ b/features/testbot/snap_intersection.feature @@ -570,7 +570,7 @@ Feature: Snapping at intersections | a,f,k | ac,cf,cf,fj,kj,kj | 132.8s | 132.8 | | k,f | ik,fi,fi | 54.3s | 54.3 | | f,a | ef,ae,ae | 66.6s | 66.6 | - | k,f,a | kj,fj,fj,ef,ae,ae | 141.399999999s | 141.399999999 | + | k,f,a | kj,fj,fj,ef,ae,ae | 141.399999999s +- 1e-7 | 141.399999999 +- 1e-7 | When I request a travel time matrix I should get | | a | f | k | @@ -626,4 +626,4 @@ Feature: Snapping at intersections | a,f,k | ad,df,df,fj,kj,kj | 105.6s | 105.6 | | k,f | ik,fi,fi | 54.3s | 54.3 | | f,a | ef,ae,ae | 66.6s | 66.6 | - | k,f,a | ik,fi,fi,ef,ae,ae | 120.899999999s | 120.899999999 | + | k,f,a | ik,fi,fi,ef,ae,ae | 120.899999999s +- 1e-7 | 120.899999999 +- 1e-7 | diff --git a/routed-js/package-lock.json b/routed-js/package-lock.json index 72390f9691c..f8c0b59d296 100644 --- a/routed-js/package-lock.json +++ b/routed-js/package-lock.json @@ -19,6 +19,8 @@ "osrm-routed-js": "routed.js" }, "devDependencies": { + "@types/node": "^18.11.3", + "@types/yargs": "^17.0.13", "typescript": "^4.8.4" }, "engines": { @@ -53,6 +55,27 @@ "fast-json-stringify": "^5.0.0" } }, + "node_modules/@types/node": { + "version": "18.11.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", + "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.13", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz", + "integrity": "sha512-9sWaruZk2JGxIQU+IhI1fhPYRcQ0UuTNuKuCW9bR5fp7qi2Llf7WDzNa17Cy7TKnh3cdxDOiyTu6gaLS0eDatg==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", + "dev": true + }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -1321,6 +1344,27 @@ "fast-json-stringify": "^5.0.0" } }, + "@types/node": { + "version": "18.11.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", + "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", + "dev": true + }, + "@types/yargs": { + "version": "17.0.13", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz", + "integrity": "sha512-9sWaruZk2JGxIQU+IhI1fhPYRcQ0UuTNuKuCW9bR5fp7qi2Llf7WDzNa17Cy7TKnh3cdxDOiyTu6gaLS0eDatg==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", + "dev": true + }, "abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", diff --git a/routed-js/package.json b/routed-js/package.json index 863477ed935..c2c252fba55 100644 --- a/routed-js/package.json +++ b/routed-js/package.json @@ -36,6 +36,8 @@ "access": "public" }, "devDependencies": { + "@types/node": "^18.11.3", + "@types/yargs": "^17.0.13", "typescript": "^4.8.4" } } diff --git a/routed-js/schema.js b/routed-js/schema.js index 9ae4f2ab731..30c164481e9 100644 --- a/routed-js/schema.js +++ b/routed-js/schema.js @@ -331,6 +331,6 @@ function parseCoordinatesAndFormat(coordinatesAndFormat) { if (!coordinatesSchema(coordinates)) { throw { message: 'Invalid coordinates', code: 'InvalidQuery' }; } - return { coordinates, format }; + return { coordinates: coordinates, format }; } exports.parseCoordinatesAndFormat = parseCoordinatesAndFormat; diff --git a/routed-js/schema.ts b/routed-js/schema.ts index 03610e105a2..a3675c57396 100644 --- a/routed-js/schema.ts +++ b/routed-js/schema.ts @@ -353,5 +353,5 @@ export function parseCoordinatesAndFormat(coordinatesAndFormat: string): { coord if (!coordinatesSchema(coordinates)) { throw {message: 'Invalid coordinates', code: 'InvalidQuery'}; } - return { coordinates, format }; + return { coordinates: coordinates as [number, number][], format }; }