0.0.6 • Published 2 years ago

nodejs-cranker-connector v0.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

nodejs-cranker-connector

A connector side implementation of cranker.

Usage

  1. install dependency

    npm install nodejs-cranker-connector
  2. 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

  1. Start cranker server: git clone cranker to your local, running RunLocal.java in it.
  2. 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"}'
0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago