node-js-restful-api-cli
v1.0.21
Published
command line interface create microservice
Downloads
14
Maintainers
Readme
Quick Start Nodejs Api Cli
Required
- nodejs version >= 6 . x . x
- npm version >= 3 . x . x
- mongodb
Installation
$ npm i -g node-js-restful-api-cli --save
1. Start Project
$ node-js-restful-api-cli new [Name Project]
- select "node-server"
- input Project name
2. Create Module
$ node-js-restful-api-cli g
input Module name
3. Install package
$ npm install
4. Start
$ npm start
Unit Test
$ npm test
- test connect database mongoDB
- test module
Support
- Docker
- RabbitMQ
- Microservice
- Circleci
RabiitMQ
config file src/module/core/controller/rabbitmq.js
1. Import
mq = require('../../core/controllers/rabbitmq')
2. Publish data or message to microservice other
var data = {
firstname:"nametest",
lastname:"lasttest"
}
mq.publish('id', 'dataid', JSON.stringify(data))
- "id" and "dataid" not duplicate
- send message only string
3. consume data or message
mq.consume('id', 'name', 'dataid', (msg) => {
console.log(msg.content.toString())
});
- link https://www.youtube.com/watch?v=pgRGXPJ_6wM&t=1s
Docker Run
Build the Dockerfile and tag the image as my_image :
$ docker build -t my_image .
Use the following command to run my_image inside a container:
$ docker run -d -p 3000:3000 --name my_image [namecontainer]