Microservice Generator
This tool to generate microservice based on swagger, express js and mongoose js which can do CRUD operation using REST APIs.
Use like a node module
$ npm install --save microservice-generator
- import microservice-generator to your project and pass the schema json.
const generator = ; var schema = "name": "User Details" "api": "/user" "port": 3000 "database": "users" "schema": "name": "String" "email": "type": "String" "unique": true "required": true "password": "String" "contactNos": "code": "String" "number": "Number" "gender": "String" "address": "houseNo": "String" "street": "String" "city": "String" "state": "String" "country": "String" "pincode": "Number" generator;
Use with command line interface
$ npm install -g microservice-generator $ misgen -h Usage: misgen [options] <name> Options: -V, --version output the version number -d, --dir Directory name -h, --help output usage information # [-d generates microservice for all the schema files in a directory
$ misgen schema.json #The project folder will be generated at the location of schema.json file
Schema JSON Structure
"name":"User Details" //Required. Name of this microservice "api":"/user" //Optional. API URL of this microservice "port":3000 //Optional. Port number in which this microservice will be running "database":"users" //Optional. Name of database in which this microservice will create it's collection "schema": //mongoose schema
- Example mongoose schema
"name": "String" "email": "type": "String" "unique": true "required": true "password": "String" "contactNos": "code": "String" "number": "Number" "gender": "String" "address": "houseNo": "String" "street": "String" "city": "String" "state": "String" "country": "String" "pincode": "Number"
License
MIT