1.0.21 • Published 7 years ago
node-js-restful-api-cli v1.0.21
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 --save1. Start Project
$ node-js-restful-api-cli new [Name Project]- select "node-server"
- input Project name
2. Create Module
$ node-js-restful-api-cli ginput Module name
3. Install package
$ npm install4. Start
$ npm startUnit 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())
});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]