-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (19 loc) · 669 Bytes
/
Copy pathindex.js
File metadata and controls
26 lines (19 loc) · 669 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
require('dotenv').config();
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const connectToMongoDB = require('./src/services/connectToMongoDB');
const { PORT } = process.env;
const app = express();
connectToMongoDB();
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(morgan('tiny'));
app.use(express.static(path.join(__dirname, 'client', 'build')));
app.use('/api', require('./src/routes'));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'client', 'build', 'index.html'));
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});