-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (26 loc) · 887 Bytes
/
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
const express = require('express');
const config = require('config');
const path = require('path');
const PORT = config.get('PORT') || 5000;
const url = config.get('baseUrl') + PORT;
const app = express();
app.use(express.json({ extended: true }))
app.use('/api/products', require('./routes/products.routes'))
app.use('/api/sendMail', require('./routes/sendMail.routes'))
if (process.env.NODE_ENV === 'production') {
app.use('/', express.static(path.join(__dirname, 'rb_test_client', 'build')))
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, "rb_test_client", "build", "index.html"));
})
}
async function start() {
try {
app.listen(PORT, () => {
console.log(`Server start. Address: ${url}`);
})
} catch (err) {
console.log('Server error: ', err.message);
process.exit(1);
}
}
start()