nodejs-cranker-connector
v0.0.6
Published
cranker connector implementation with node and typescript
Downloads
7
Maintainers
Readme
nodejs-cranker-connector
A connector side implementation of cranker.
Usage
install dependency
npm install nodejs-cranker-connector
register to cranker gateway as below
// connect to cranker like const connector = await connectToRouter({ targetURI, targetServiceName: 'my-service', routerURIProvider: () => (["ws://localhost:12002"]), slidingWindow: 2 }); // you can expose connector status in your microservice's health // don't expose this to public, it's only for DevOps purpose app.get('/health', (req, res) => { res.status(200).send({ component: 'my-service', isHealthy: true, connector: connector?.status() }); }) // if you need to connect to cranker server with wss, provide the httpsAgent const connector = await connectToRouter({ targetURI, targetServiceName: 'my-service', routerURIProvider: () => (["wss://localhost:12002"]), slidingWindow: 2, httpsAgent: new https.Agent({ rejectUnauthorized: false // demo purpose, don't do this in production! }) });
Development
- Start cranker server: git clone cranker to your local, running
RunLocal.java
in it. - Start client side: running
npm run local
Manual Testing
# GET
curl -k https://localhost:12000/my-service/get
# POST
curl -k -X POST https://localhost:12000/my-service/post \
-H "Content-Type: application/json" \
-d '{"name":"hello"}'