GithubHelp home page GithubHelp logo

djkwagala / microservice-lite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robophil/microservice-lite

0.0 1.0 0.0 79 KB

A very lite microservice starter.

License: MIT License

JavaScript 100.00%

microservice-lite's Introduction

microservice-lite

Build Status semantic-release

Microservice-lite is a very small package for getting started with microservices on node. It covers everything a simple microservice should have.

  1. Having it's own database (mysql, mongo, postgres, redis, and more)
  2. Small footprint
  3. Indepenent deployment
  4. Zero-configuration
  5. Zero-dependency
  6. Auto-discovery, fault toleranct and scalable

This works, thanks to the effort of @dashersw and his wonderful project cote.js and @balderdashy for writing waterline

install

# for pre-release do npm i -g microservice-lite@next
npm i -g microservice-lite

or

# for pre-release do yarn global add microservice-lite@next
yarn global add microservice-lite

cli commands

create a project

# creates new project
mslite new sample

responder

# New responder has been created as src/app/foo.responder.js
mslite g responder foo [...othernames]

requester

# New requester has been created as src/app/foo.requester.js
mslite g requester foo [...othernames]

Requesters are global and can be accessed from any location. The above can be accessed as FooRequester globally with the app

subscriber

# New subscriber has been created as src/app/foo.subscriber.js
mslite g subscriber foo [...othernames]

publisher

# New publisher has been created as src/app/foo.publisher.js
mslite g publisher foo [...othernames]

Publishers are global and can be accessed from any location. The above can be accessed as FooPublisher globally with the app

model

# New model has been created as src/models/foo.js
mslite g model foo [...othernames]

Models are global and can be accessed from any location. The above can be accessed as Foo globally with the app

database and adapters

Each microservice should have it's own database and mslite helps you with that. You could have a different database for each service. Eg mysql, mongodb, pouchdb etc.

By default, each project created with mslite comes with a disk based databased called sails-disk. There are other adapters you can use to have a different database like

  • sails-mysql
  • sails-postgresql
  • sails-mongo
  • sails-redis
  • sails-orientdb
  • sails-filemaker

see here for more info about adapters.

To add a different adapter for your project, simply install the appropriate adapter and make sure you have the database on your current machine as the adapter would try to make connection.

configure adapters

  1. Install required adapter eg.
npm i --save sails-mongo
  1. open config/adapters.js and require intalled adapter, also passing it an object name of your pleasing eg
module.exports = {
'sailsDisk': require('sails-disk'),
'sailsMongo': require('sails-mongo')
}

You can have any amount of adapters saved here for later use 3. Open config/connections.js create a connection object. Same as above, pass connection object to a name of your pleasing and specify the adapter from any defined in step 1

  module.exports = {
    'diskDb': {
      'adapter': 'sailsDisk'
    },
    myMongodbServer: {
      adapter: 'sailsMongo',//adapter's name, as defined above
      host: 'localhost',
      port: 27017,
      user: 'username', //optional
      password: 'password', //optional
      database: 'your_mongo_db_name_here' //optional
    }
  }
  1. Open cofig/models Tell your models to use the connection you want.
module.exports = {
  'connection': 'myMongodbServer', //change from diskDb
  'migrate': 'alter',
  'schema': true
}

test

NYD

examples

NYD

goal

The goal of the project is to make getting started with a microservice easy and painless, giving you basic features. The following features are on the roadmap

  • CLI for generating necessary files. eg
# generates a db model
mslite g model name [names...]
  • Easy connection to any database with the same api
  • .... got a feature in mind ? create an issue here

development

This project uses the following to keep things a bit sane around the house

  1. standardjs
  2. validate-commit-msg see http://conventionalcommits.org/
  3. Github flow

and is completly test driven TDD

microservice-lite's People

Contributors

robophil avatar

Watchers

 avatar

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.