random route stuff
This commit is contained in:
parent
d27ff64a74
commit
9a63772401
8 changed files with 143 additions and 124 deletions
23
lib/app.js
23
lib/app.js
|
|
@ -1,7 +1,6 @@
|
|||
const fs = require('fs')
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
const express = require('express')
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
|
||||
const routes = require('./routes')
|
||||
|
|
@ -11,7 +10,10 @@ const verifySchema = require('./verify-schema')
|
|||
const settingsLoader = require('./settings-loader')
|
||||
const options = require('./options')
|
||||
|
||||
const devMode = argv.dev || argv.http || options.http
|
||||
const devMode = argv.dev || options.http
|
||||
|
||||
const version = require('../package.json').version
|
||||
logger.info('Version: %s', version)
|
||||
|
||||
function run () {
|
||||
let count = 0
|
||||
|
|
@ -31,9 +33,6 @@ function run () {
|
|||
}
|
||||
|
||||
function runOnce () {
|
||||
const app = express()
|
||||
const localApp = express()
|
||||
|
||||
return verifySchema.valid()
|
||||
.then(() => settingsLoader.loadLatest())
|
||||
.then(settings => {
|
||||
|
|
@ -46,23 +45,15 @@ function runOnce () {
|
|||
}
|
||||
|
||||
const server = devMode
|
||||
? http.createServer(app)
|
||||
: https.createServer(httpsServerOptions, app)
|
||||
? http.createServer(routes.app)
|
||||
: https.createServer(httpsServerOptions, routes.app)
|
||||
|
||||
const port = 3000
|
||||
const localPort = 3030
|
||||
const localServer = http.createServer(localApp)
|
||||
const localServer = http.createServer(routes.localApp)
|
||||
|
||||
if (options.devMode) logger.info('In dev mode')
|
||||
|
||||
const opts = {
|
||||
app,
|
||||
localApp,
|
||||
devMode
|
||||
}
|
||||
|
||||
routes.init(opts)
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log('lamassu-server listening on port ' +
|
||||
port + ' ' + (devMode ? '(http)' : '(https)'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue