-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (58 loc) · 1.19 KB
/
index.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
70
/*!
* @prettier
* @copyright (c) 2019 - present, HGC-AB
* @licence This source code is licensed under the MIT license described and found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Module dependency
*/
const dotenv = require('dotenv')
/**
* Validate .env variables
*/
const result = dotenv.config()
if (result.error) {
throw result.error
}
const http = require('http')
const express = require('express')
/**
* App configuration
*/
const appConfig = require('./config/appConfig')
/**
* Express.js app
*/
const app = express()
/**
* Express based server
*/
const server = http.createServer(app)
/**
* Load Express middleware
*/
require('./middleware')(app, appConfig)
/**
* Load node server routes
*/
require('./routes')(app, appConfig)
/**
* Load OAuth2 server routes
*/
require('./server/routes')(app, appConfig)
/**
* Load errors handler for the resource server
*/
require('./error-handler')(app, appConfig)
/**
* Listen on incoming request
*/
server.listen(appConfig.port, '0.0.0.0', function () {
console.log(`${appConfig.appName} listening on: http://localhost:${appConfig.port}`)
})
/**
* Expose server
* @public
*/
module.exports = server