0.4.0 • Published 4 years ago

dot-rest v0.4.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

dot-rest

a minimalist toolkit for building fast, scalable and fault tolerant microservices

Configuration

  • host : binds server instance to this value. it's 0.0.0.0 by default.
  • pino : options for pino logger. it's { "level": "error" } by default.
  • port : start point for port assignment. it's 8000 by default.

Examples

const Clerq = require('clerq');
const { Client, Server } = require('dot-rest');
const IORedis = require('ioredis');

class Service {
    static _configure() {
        return {
            echo: [ '*', '/:path' ]
        };
    }

    static _name() {
        return 'myService';
    }

    static async echo(req) { // ? , res
        return req.params;
    }
}

const registry = new Clerq(new IORedis(), { expire: 5, pino: { level: 'error' } });
const client = new Client(registry, { expire: 5, pino: { level: 'error' } });
const server = new Server(registry, { expire: 5, pino: { level: 'error' } });
server.start()
    .then(() => server.addService(Service))
    .catch(console.log);

setTimeout(async() => {
    const r = await client.get(Server._unCamelCase(Service._name()), 'test');
    console.log(r.data);
    server.stop();
    client.close();
}, 500);
0.4.0

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.3

4 years ago

0.3.2

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago