-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (26 loc) · 976 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
const path = require('path');
const express = require('express');
const live = require('livereload');
const connect = require('connect-livereload');
const logger = require('morgan');
const serveIndex = require('serve-index');
const liveSrvr = new live.createServer({
extraExts: (process.env.EXTRA_EXTS || '').split(',')
});
liveSrvr.watch(__dirname);
liveSrvr.server.once('connection', () => {
setTimeout(() => {
liveSrvr.refresh('/');
}, 100);
});
const app = express();
app.set('port', process.env.PORT || 8080);
app.use(connect());
app.use(logger('dev'));
app.use('/invitations', express.static(__dirname), serveIndex(__dirname, { icons: true }));
app.get('/favicon.ico', (req, res) => res.sendFile(path.join(__dirname, 'favicon.ico')));
app.all('/*', (req, res) => res.type('html').send(`
Invalid page.<br>
<a href='/invitations'>Back to home</a>
`));
app.listen(app.get('port'), () => console.log(`Development server listening on port ${app.get('port')}.`))