-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (30 loc) · 1014 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
31
32
33
34
35
36
37
38
39
40
const dotenv = require('dotenv');
const express = require('express');
const axios = require('axios');
const bodyParser = require('body-parser');
// standard express logger
const morgan = require('morgan');
const path = require('path');
// load env variables
dotenv.config();
const routes = require('./api_routes/routes');
const app = express();
const PORT = process.env.PORT || 7080;
// Set axios request max size
axios.defaults.maxContentLength = Infinity;
axios.defaults.maxBodyLength = Infinity;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json({ limit: '4000mb' }));
app.use(morgan('dev'));
// Add routes
app.use('/api', routes);
// Serve up static assets
app.use(express.static(path.join(__dirname, 'pack')));
// Send every request to the React app
// Define any API routes before this runs
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'pack', 'index.html'));
});
app.listen(PORT, () => {
console.log(`🌎 ==> qgraph running on port ${PORT}!`);
});