Itineris (lat.) - route
npm install -g ts-node
npm install -g typescript
Endpoints are NodeJS server instances, bind to IP and port according to its configuration
ts-node src/router-ctl.ts endpoint add --endpointName local
ts-node src/router-ctl.ts endpoint nodes add --endpointName local --nodeName local-node
ts-node src/router-ctl.ts endpoint node add --endpointName local --nodeName local-node --ip 0.0.0.0 --port 1111
ts-node src/router-ctl.ts endpoint set --endpointName test --tls-key key.pem --tls-cert cert.pem
Targets are addresses where requests can be routed
ts-node src/router-ctl.ts target add --targetName test-target
ts-node src/router-ctl.ts target hosts add --targetName test-target --host localhost:1234
ts-node src/router-ctl.ts route add --routeName test-route --endpointName test --order 1 --rule "
return 'test-target';
"
To start router:
ts-node src/router-ctl.ts start
Router rule is a javascript snippet that looks like a body of function with one argument req
of type http.IncomingMessage
return req.headers['X-Api-Version'] === 1 ? 'target-1' : 'target-default';