-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
61 lines (44 loc) · 1.44 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env nodejs
process.title = "senti_gateway"
const dotenv = require('dotenv').config()
if (dotenv.error) {
console.warn(dotenv.error)
}
const express = require('express')
const cors = require('cors')
const helmet = require('helmet')
const app = express()
// ACL Client
const sentiAuthClient = require('senti-apicore').sentiAuthClient
const authClient = new sentiAuthClient(process.env.AUTHCLIENTURL, process.env.PASSWORDSALT)
module.exports.authClient = authClient
const sentiAclBackend = require('senti-apicore').sentiAclBackend
const sentiAclClient = require('senti-apicore').sentiAclClient
const aclBackend = new sentiAclBackend(process.env.ACLBACKENDTURL)
const aclClient = new sentiAclClient(aclBackend)
module.exports.aclClient = aclClient
// API Request Parsers
const port = process.env.NODE_PORT || 3007
app.use(helmet())
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(cors())
// API Endpoints
const auth = require('./api/auth/auth')
app.use([auth])
//---Start the express server---------------------------------------------------
var printRoutes = require('./lib/printRoutes')
const startServer = () => {
console.clear()
printRoutes(app)
app.listen(port, () => {
console.log('Senti Service started on port', port)
}).on('error', (err) => {
if (err.errno === 'EADDRINUSE') {
console.log('Service not started, port ' + port + ' is busy')
} else {
console.log(err)
}
})
}
startServer()