-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (28 loc) · 1.21 KB
/
app.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*********************************** Import ***********************************/
const express=require('express');
const path=require('path');
const cors=require('cors');
const routes=require('./router/routes');
const connectDB=require('./config/db');
/*********************************** Config ***********************************/
// Load variables in env file
require('dotenv').config({ path: path.resolve(__dirname, 'config', 'config.env') });
// Starting connection in DB
connectDB();
/*********************************** Constants ***********************************/
const PORT = process.env.PORT || 5000;
const app=express();
/*********************************** Middlewares ***********************************/
// Body Parser
app.use(express.json());
// Enable Cors
app.use(cors());
// configure routes file
app.use('/api/v1/stores', routes);
// Set static folder
app.use(express.static(path.join(__dirname, 'public')));
/*********************************** Routes ***********************************/
/*********************************** General ***********************************/
app.listen(PORT, () =>{
console.log(`Server running in ${process.env.NODE_ENV || "development"} mode on port ${process.env.PORT}`);
});