-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (34 loc) · 855 Bytes
/
index.js
File metadata and controls
37 lines (34 loc) · 855 Bytes
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
'use strict'
/**
* Runs the server
******************************/
const http = require('http'),
LRU = require('lru-cache'),
options = {
max: 500,
maxAge: 1000 * 60 * 60,
dispose: function (key, n) {
n.close(1000, 'Session expired')
}
},
cache = new LRU(options),
Server = require('./src/lib/Server'),
release = require('./package.json'),
{ ENV, PORT } = require('./config')
/**
* Create server
**/
const httpServer = http.createServer((req, res) => {
console.info(`--> ${req.method} ${req.url}`)
res.end('Wubba lubba dub dub!')
})
const server = new Server(httpServer, cache)
// Catch all errors
server.on('error', console.error)
/**
* Start server
**/
httpServer.listen(PORT, () => {
console.info(`Started for Ciphora Server (${release.version}) - ${ENV}`)
console.info(`Running on port ${PORT}`)
})