Git Product home page Git Product logo

ilms's Introduction

I ❤️ MicroService (ilms)

Project to build better microservices.

This repository contains ilms and few plugins.

What is a service ?

A service is a group of middleware. A middleware is a handler which, with a given input give a output ;

  • basic example
const ilms = require('ilms');

const sum = (params, next) => {
  next(params.a + params.b);
};

ilms('sum')
    .use(sum)
    .run({ a : 5, b: 4 })
    .then(result => {
      expect(result).to.be.equal(9);
    });
  • multiple middlewares in one service :
const ilms = require('ilms');

const registerUserMongoDB = require('./registerUserMongoDB');
const registerUserElasticSearch = require('./registerUserElasticSearch');
const triggerCRM = require('./triggerCRM');

ilms('users.register')
    .use(registerUserMongoDB)
    .use(registerUserElasticSearch)
    .use(triggerCRM);
  • call a service ;
const ilms = require('ilms');

ilms.run('users.get', { _id: 33 })
    .then(user => {
      // Do something
    });

Why ?

  • The project give a way to write buisness logic.
  • This kind of handler is easier to test.
  • The way to separe logic is easier to understand.

API

### API - ilms

  • ilms.declare(serviceName) : Create a new service from serviceName.
  • ilms.exists(serviceName) : Check if the given service exists
  • ilms.run(serviceName, params) : Play a service with the given params.
  • ilms.get(serviceName) : Get the service serviceName

API - Service

  • Service.use(middleware) : Associate a middleware to the given service.
  • Service.bind(serviceName) : Associate the current service with another service
  • Service.run(params) : Play the service and return a promise with the result.

### API - next

  • next(results) : go to the next middleware in the stack or resolve middleware stack
  • next.resolve(results) : resolve the middleware stack
  • next.reject(err) : reject the middleware stack
  • next.replay(params) : replay the same middleware with the params
  • next.run(serviceName, params) : play another service (return a promise)

ilms's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.