-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (50 loc) · 1.07 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict';
/*!
* Moodules and dependencies
*/
const Path = require('path');
const Express = require('express');
const Logger = require('morgan');
const BodyParser = require('body-parser');
/*!
* Routes
*/
const Api = require('./routes/api');
const Admin = require('./routes/admin');
/*!
* Local vars
*/
const publicPath = Path.join(__dirname, 'app/public');
const app = Express();
/*!
* Server configuration
*/
app.set('etag', 'strong');
app.use(Logger('tiny'));
app.use(BodyParser.json());
app.use(BodyParser.urlencoded({ extended: false }));
app.use(Express.static(publicPath));
/*!
* Basic Routing
*/
app.get('/', (req, res) => {
res.sendFile(publicPath + '/test.html');
});
app.get('/admin', (req, res) => {
res.redirect('/admin/dashboard');
});
app.get('/admin/dashboard', (req, res) => {
res.sendFile(publicPath + '/dashboard.html');
});
app.use('/api/', Api);
/*!
* Starting server
*/
app.listen(3000, '127.0.0.1', (err) => {
if (err) {
console.log(err);
return;
}
console.log('Server running on port 3000.');
});
module.exports = app;