Skip to content

dot-microservices/dot-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

a minimalist toolkit for building scalable, fault tolerant and eventually-consistent microservices

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy