Skip to content

Commit

Permalink
Feature: Add logs when start PM2 server in development mode
Browse files Browse the repository at this point in the history
  • Loading branch information
renanlopescoder committed Feb 8, 2018
1 parent 07989c4 commit addcf17
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

## Node API

Application in Node, Express, MongoDB and PM2 to give support to Front End development, this application serving a bunch of AJAX requests to give and manipulate data from database.
### Description
Node API is production ready and open source project in Node, Express and MongoDB

### Support
This application is hosted on Heroku and serve a bunch of AJAX requests to give and manipulate data from database and give a support to test front end applications

### Showcase

Expand All @@ -12,7 +16,6 @@ Application in Node, Express, MongoDB and PM2 to give support to Front End devel
|https://typescript-angular4.herokuapp.com/ | https://github.com/renanlopescoder/typescript-angular4 |
|http://mobx-react.herokuapp.com/ | https://github.com/renanlopescoder/mobx-react |


## Routes

#### Projects
Expand Down Expand Up @@ -73,23 +76,27 @@ Application in Node, Express, MongoDB and PM2 to give support to Front End devel
- Routes ```./src/routes```
- Models ```./src/models```
- Actions ```./src/actions```
- Services ```./src/services```
- Configurations of Express ```./config/express.js```
- Database configurations ```./config/database.js```
- Server configurations ```./server.js```

## Configuring the API locally

- Download or clone the project access the project folder with the terminal and execute the CLI <code>npm install</code>.
- Run the server <code>npm start</code> (Nodemon)
- Access in your browser <a href="http://localhost:3000">http://localhost:3000</a>
- Download or clone the project access the project folder with the terminal and execute the CLI <code>npm install</code>
- Config your database in ```./congig/database.js``` change ```mongoose.connect('mongodb://localhost/yourDatabaseName');```
- Run the server in development mode <code>npm run dev</code>
- <code>Ctrl + c</code> to exit of logs and run <code>pm2 kill</code> to kill all process of pm2
- Access in your browser <a href="http://localhost:3000/projects">http://localhost:3000/projects</a>

## API Dependencies

- Dependency express - <a href="https://www.npmjs.com/package/express">https://www.npmjs.com/package/express</a>
- Dependency body-parser - <a href="https://www.npmjs.com/package/body-parser">https://www.npmjs.com/package/body-parser</a>
- Dependency cors - <a href="https://www.npmjs.com/package/cors">https://www.npmjs.com/package/cors</a>
- Dependency express-load - <a href="https://www.npmjs.com/package/express-load">https://www.npmjs.com/package/express-load</a>
- Dependency consign - <a href="https://www.npmjs.com/package/consign">https://www.npmjs.com/package/consign</a>
- Dependency PM2 - <a href="http://pm2.keymetrics.io/">http://pm2.keymetrics.io/</a>
- Dependency mongoose - <a href="https://www.npmjs.com/package/mongoose">https://www.npmjs.com/package/mongoose</a>

By: <a href="http://renanlopes.com">Renan Lopes</a>

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "rest_api_node",
"name": "node_api",
"version": "2.1.0",
"description": "NodeJS REST API is a open code NodeJS Back End API",
"description": "Node API is production ready and open source project in Node, Express, MongoDB and PM2",
"scripts": {
"preinstall": "npm i -g pm2 && pm2 install pm2-logrotate",
"dev": "pm2 start server.js --watch",
"dev": "pm2 start server.js --watch && pm2 logs",
"start": "node ./node_modules/.bin/pm2 start server.js"
},
"author": "Renan Lopes",
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ require('./config/database');
const PORT = process.env.PORT || 3000;

server.listen(PORT, () => {
console.log('Servidor Iniciado');
console.log(`Server running on port ${PORT}`);
});

0 comments on commit addcf17

Please sign in to comment.