Personal project · 2022
osrm-node-api
A high-performance NodeJS server implementation for the Open Source Routing Machine (OSRM) backend.
NodeJSTypeScriptGeographic Services
Source on GitHubLast updated November 2026
What it does
osrm-node-api is a routing service for OpenStreetMap road data. Give it points on a map, and it answers four kinds of questions, using OSRM, a fast open-source routing engine:
Route
/routeThe fastest way through two or more points, with turn-by-turn steps if you want them.
Table
/tableTravel times from every start (A–C) to every destination (1–3), in one call.
Nearest
/nearestThe closest points on the road to a coordinate, nearest first.
Match
/matchSnaps a noisy GPS trace onto the roads it most likely followed.
What it adds to OSRM
OSRM ships its own server, osrm-routed, which works well on a laptop. Running routing as a service needs more around it, and that layer is what this project is.
osrm-node-api
- OSRM enginethe routing itself
- Several processesParallel workers behind one port
- MetricsLatency and errors, for Prometheus
- Health checks/liveness computes a real route
- Request logsOne line per request, with a trace ID
- Input checksUnknown parameters get a 400
- One Docker imageOSRM v6.0.0 built from source
How a request moves
Client
GET or POST /route /table /nearest /match
Docker container
Worker process × N
Forked by Node cluster; each creates its own OSRM instance
- 1Helmet headers, JSON body, timing log
- 2Check parameters against the service’s whitelist
- 3Call the OSRM Node binding on the libuv thread pool
Primary process
Forks the workers; serves /metrics on :9090, summed across workers
Logs
info and error files, rotated daily, kept 7 days
.osrm graph files
Prepared from OpenStreetMap; CH or MLD