-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtestserver.js
35 lines (30 loc) · 913 Bytes
/
testserver.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
/* eslint-disable import/no-commonjs */
/* eslint-disable global-require */
/* eslint-disable import/no-nodejs-modules */
/* eslint-disable no-param-reassign */
/* eslint-disable callback-return */
/* eslint-disable fp/no-mutation */
/* eslint-disable import/no-extraneous-dependencies */
const PORT = 3001;
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
const ZERO = 0;
app.use(bodyParser.urlencoded({ extended: false }));
app.use((req, res, next) => {
if (path.extname(req.path).length > ZERO) {
next();
} else {
req.url = '/index.html';
next();
}
});
app.use(express.static(path.join(__dirname, '/dist')));
app.listen(PORT, (error) => {
if (error) {
console.error(error);
} else {
console.info('==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.', PORT);
}
});