-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (30 loc) · 858 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
36
37
38
/*
* Copyright 2019 Atom Learning
*
*/
const express = require('express')
const path = require('path')
const config = require('./config/server_config')
const apiRoute = require('./routes/api')
const competition = require("./server/competition");
//Set up express & sessions
const app = express()
//Don't advertise that this is express
app.disable('x-powered-by')
//Deply static files and views
app.use(express.static(config.web.public_location))
//Deploy API
app.use('/api', apiRoute.getRoute())
app.get('/', (req, res, next) => {
res.sendFile(path.join(config.web.public_location, 'index.html'))
})
/**
* Start server
* @type type
*/
const server = app.listen(config.web.port, function (err) {
if (err) return err
const port = server.address().port
console.log('(HTTP) App now running on port', port)
})
competition.setServer(server);