-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (20 loc) · 767 Bytes
/
server.js
File metadata and controls
26 lines (20 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const express = require('express');
const dotenv = require('dotenv');
//dotenv package initialization
dotenv.config();
const app = express();
//use port defined in .env files or 3000 if not defined in the .env file
const PORT = process.env.PORT || 3000;
//simple route
app.get('/', (req, resp, next) => {
resp.send('Hello from Node Server ! this is a minimalist nodejs server to get you started')
} );
//app starts a server and listens on port defined in PORT variable for connections.
app.listen(PORT, () => {
console.log(`server listenning on port ${PORT}`)
});
//-USAGE
//type in your console : 'npm run dev' to run in development mode
//--OR
//type in your console : 'npm run start' to run in production mode
//visit localhost:3002 in your browser