forked from germancutraro/Shopping-Cart-MERN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (24 loc) · 764 Bytes
/
server.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
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
// App Init
const app = express();
// db
require('./libs/db-connection');
const PORT = process.env.PORT || 5000;
// Middlewares
app.use(require('helmet')());
app.use(require('cors')());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// Routes
app.use('/api/products', require('./routes/products'));
// Production
if (process.env.NODE_ENV === 'production') {
// Set static folder
app.use(express.static('client/build'));
app.get('*', (req, res) => {