Skip to content

Commit addcf17

Browse files
Feature: Add logs when start PM2 server in development mode
1 parent 07989c4 commit addcf17

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
## Node API
55

6-
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.
6+
### Description
7+
Node API is production ready and open source project in Node, Express and MongoDB
8+
9+
### Support
10+
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
711

812
### Showcase
913

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

15-
1619
## Routes
1720

1821
#### Projects
@@ -73,23 +76,27 @@ Application in Node, Express, MongoDB and PM2 to give support to Front End devel
7376
- Routes ```./src/routes```
7477
- Models ```./src/models```
7578
- Actions ```./src/actions```
79+
- Services ```./src/services```
7680
- Configurations of Express ```./config/express.js```
7781
- Database configurations ```./config/database.js```
7882
- Server configurations ```./server.js```
7983

8084
## Configuring the API locally
8185

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

8692
## API Dependencies
8793

8894
- Dependency express - <a href="https://www.npmjs.com/package/express">https://www.npmjs.com/package/express</a>
8995
- Dependency body-parser - <a href="https://www.npmjs.com/package/body-parser">https://www.npmjs.com/package/body-parser</a>
9096
- Dependency cors - <a href="https://www.npmjs.com/package/cors">https://www.npmjs.com/package/cors</a>
91-
- Dependency express-load - <a href="https://www.npmjs.com/package/express-load">https://www.npmjs.com/package/express-load</a>
97+
- Dependency consign - <a href="https://www.npmjs.com/package/consign">https://www.npmjs.com/package/consign</a>
9298
- Dependency PM2 - <a href="http://pm2.keymetrics.io/">http://pm2.keymetrics.io/</a>
99+
- Dependency mongoose - <a href="https://www.npmjs.com/package/mongoose">https://www.npmjs.com/package/mongoose</a>
93100

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "rest_api_node",
2+
"name": "node_api",
33
"version": "2.1.0",
4-
"description": "NodeJS REST API is a open code NodeJS Back End API",
4+
"description": "Node API is production ready and open source project in Node, Express, MongoDB and PM2",
55
"scripts": {
66
"preinstall": "npm i -g pm2 && pm2 install pm2-logrotate",
7-
"dev": "pm2 start server.js --watch",
7+
"dev": "pm2 start server.js --watch && pm2 logs",
88
"start": "node ./node_modules/.bin/pm2 start server.js"
99
},
1010
"author": "Renan Lopes",

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ require('./config/database');
55
const PORT = process.env.PORT || 3000;
66

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

0 commit comments

Comments
 (0)