Microservice-lite is a very small package for getting started with microservices on node. It covers everything a simple microservice should have.
# for pre-release do npm i -g microservice-lite@nextnpm i -g microservice-lite
# for pre-release do yarn global add microservice-lite@nextyarn global add microservice-lite
# creates new projectmslite new sample
# New responder has been created as src/app/foo.responder.jsmslite g responder foo [...othernames]
# New requester has been created as src/app/foo.requester.jsmslite 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
# New subscriber has been created as src/app/foo.subscriber.jsmslite g subscriber foo [...othernames]
# New publisher has been created as src/app/foo.publisher.jsmslite 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
# New model has been created as src/models/foo.jsmslite 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
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
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.
npm i --save sails-mongo
config/adapters.jsand require intalled adapter, also passing it an object name of your pleasing eg
You can have any amount of adapters saved here for later use
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
moduleexports ='diskDb':'adapter': 'sailsDisk'myMongodbServer:adapter: 'sailsMongo'//adapter's name, as defined abovehost: 'localhost'port: 27017user: 'username' //optionalpassword: 'password' //optionaldatabase: 'your_mongo_db_name_here' //optional
cofig/modelsTell your models to use the connection you want.
moduleexports ='connection': 'myMongodbServer' //change from diskDb'migrate': 'alter''schema': true
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
# generates a db modelmslite g model name [names...]
This project uses the following to keep things a bit sane around the house
and is completly test driven TDD