forked from FreezingMoon/AncientBeast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
27 lines (23 loc) · 839 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
// This script is only used on Heroku; for gh-pages we host /deploy directly
const path = require('path');
const compression = require('compression');
const express = require('express');
const app = express();
const port = process.env.PORT || 8383;
const ip = process.env.IP || null; // Use specified IP to bind to otherwise, bind to default for the API
// Enable gzip compression
app.use(compression());
// Assets are hashed so they can be in the cache for longer
app.use(
'/assets/',
express.static(path.join(__dirname, 'deploy', 'assets'), {
maxAge: '1d',
}),
);
app.use(express.static(path.join(__dirname, 'deploy')));
// Listen for server, and use static routing for deploy directory
app.listen(port, ip, () => {
console.log(
`Server listening at port ${port}.\nOpen http://localhost:${port} in Chrome/Chromium.`,
);
});