-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (44 loc) · 1.04 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
/*!
* V4Fire Boilerplate
* https://github.com/V4Fire/Boilerplate
*
* Released under the MIT license
* https://github.com/V4Fire/Boilerplate/blob/master/LICENSE
*/
const
config = require('config'),
express = require('express'),
path = require('path');
const
{api, src} = config,
app = express();
module.exports = app;
app.use('/dist/client', express.static(src.clientOutput()));
app.use('/assets', express.static(src.assets()));
app.get('/api/users', (req, res) => res.send([
{
name: 'Bill',
type: 'Dwarf',
lvl: 80
}
]));
app.get('/api/users/skills', (req, res) => res.send([
'fight',
'magic'
]));
app.get('/api/users/inventory', (req, res) => res.send(
['sword+1']
));
app.get('/api/users/:id', (req, res) => res.send({
name: 'Bill',
type: 'Dwarf',
lvl: 80
}));
[['/**', 'p-root']].forEach(([route, file]) => {
file += '.html';
app.get(route, (req, res) => res.sendFile(path.join(src.clientOutput(), file)));
});
app.listen(api.port);
console.log('App launched');
console.log(`http://localhost:${api.port}`);