-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·34 lines (26 loc) · 1009 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
'use strict'
const fs = require('fs')
const gateway = require('express-gateway')
const path = require('path')
require('dotenv').config()
const SSL_KEY_PATH = process.env.SSL_KEY_PATH
const SSL_CERT_PATH = process.env.SSL_CERT_PATH
const JWT_KEY_PATH = process.env.JWT_PUBLIC_KEY_PATH
// API_REFERENCE: express-apigw-base-plugin
process.env.API_REFERENCE_PATH_FILE=path.join(__dirname, 'api-reference.js')
if (!fs.existsSync(SSL_KEY_PATH)) {
console.error(`SSL key required!\nPlease provide the ssl key in the .env file in SSL_KEY_PATH.`)
process.exit()
}
if (!fs.existsSync(SSL_CERT_PATH)) {
console.error(`SSL certificate required!\nPlease provide the ssl certificate in the .env file in SSL_CERT_PATH.`)
process.exit()
}
if (!fs.existsSync(JWT_KEY_PATH)) {
console.error(`JWT public key required!\nPlease provide the jwt public key in the .env file in JWT_PUBLIC_KEY_PATH.`)
process.exit()
}
/* Start Gateway */
gateway()
.load(path.join(__dirname, 'config'))
.run()