-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
53 lines (40 loc) · 1.26 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
/**
* index.js file
* @authors Biswas, Maitz, Mitterdorfer
* @version 0.0.1
* @date 04/2020 * @description the main server file for the Moosify Web App
*/
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const db = require('./libs/database');
const checker = require('./checks/checks');
const app = express();
/** middleware */
const auth = require('./auth');
const api = require('./api');
app.use(express.static(path.join(__dirname, 'client/static')));
app.use(cookieParser());
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname + '/client/views/index.html'));
});
app.use(checker);
app.use('/auth', auth(db));
app.use('/api/v1', api(db));
app.get('/mood', (req, res) => {
res.sendFile(path.join(__dirname + '/client/views/mood.html'));
});
/** playlist created */
app.get('/created', (req, res) => {
res.sendFile(path.join(__dirname + '/client/views/created.html'));
});
/**
* called if no enpoint '/..' matches the endpoint specified in the URL
*/
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client/views/pageNotFound404.html'));
});
module.exports = app;
const port = process.env.PORT || 7000;
app.listen(port);
console.log(`Moosify listening on ${port}`);