-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (20 loc) · 713 Bytes
/
server.js
File metadata and controls
26 lines (20 loc) · 713 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
const express = require('express');
const app = express();
const compression = require('compression');
const path = require('path');
const morgan = require('morgan');
const routes = require('./api/routes/index.router');
const contentPath = process.env.NODE_ENV === 'production' ? 'dist' : 'src';
const port = process.env.PORT || 1337;
// Middleware galore
app.use(morgan('dev')); // logging
app.use(compression()); // gzip
app.use(express.json()); // process post json
// Serve static folder
app.use(express.static(path.join(__dirname, contentPath)));
// Add API routes
app.use(routes);
app.listen(port, () => {
// eslint-disable-next-line no-console
console.log(`🌋 Listening on port: ${port}`);
});