forked from frontend-park-mail-ru/2018_1_RHA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (26 loc) · 913 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
'use strict';
const express = require('express'); // express
const bodyparser = require('body-parser');
const fallback = require('express-history-api-fallback');
const fileUpload = require('express-fileupload');
const path = require('path');
// const debug = require('debug');
// const logger = debug('mylogger');
const app = express(); // объект приложения
const root = path.resolve('./public/');
app.use(express.static(root)); // middleware
app.use(fallback('index.html', {root}));
app.use(bodyparser.json());
// app.use(fileUpload());
//todo сделать путь к sw
function sendIndex(req, res) {
let indexFile = root + '/' + 'index.html';
res.sendFile(indexFile);
}
app.get('/*', sendIndex);
// app.get('/singleplayer', sendIndex);
// app.get('/*', (req, res) => {
// res.sendFile(path.join(root, 'index.html'));
// });
const port = process.env.PORT || 3000;
app.listen(port);