-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.js
29 lines (24 loc) · 918 Bytes
/
app.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
'use strict'
require('dotenv').config()
const isDev = process.env.NODE_ENV === 'development'
const port = process.env.PORT
const src = isDev ? './src/index' : './build/index'
const fs = require('fs')
const https = require('https')
let options
if (isDev) {
// needed to run the app
require('@babel/register')
options = {
key: fs.readFileSync(process.env.LOCAL_KEY),
cert: fs.readFileSync(process.env.LOCAL_CERT),
}
}
//Here we're assigning the server to a variable because
//we're going to want to manually rip down the server in testing
const app = require(src).default
const server = isDev ? https.createServer(options, app.callback()).listen(port) : app.listen(port)
console.log('https://localhost:' + port)
console.log('Running in ' + process.env.NODE_ENV + ' v' + process.env.NPM_PACKAGE_VERSION)
//Exporting the actual server here for testing availability
module.exports = { server: server }