-
Notifications
You must be signed in to change notification settings - Fork 71.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6135 from nightscout/dev
Nightscout 14.0.5 Liquorice
- Loading branch information
Showing
23 changed files
with
383 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,46 @@ | ||
'use strict'; | ||
|
||
const express = require('express'); | ||
const path = require('path'); | ||
var _ = require('lodash'); | ||
|
||
var head = '<!DOCTYPE html><html><head><title>Nightscout - Boot Error</title></head><body><h1>Nightscout - Boot Error</h1><dl>'; | ||
var tail = '</dl></body></html>'; | ||
function bootError(env, ctx) { | ||
|
||
function bootError(ctx) { | ||
const app = new express(); | ||
let locals = {}; | ||
|
||
app.set('view engine', 'ejs'); | ||
app.engine('html', require('ejs').renderFile); | ||
app.set("views", path.join(__dirname, "../../views/")); | ||
|
||
app.get('*', (req, res, next) => { | ||
|
||
if (req.url.includes('images')) return next(); | ||
|
||
return function pageHandler (req, res) { | ||
var errors = _.map(ctx.bootErrors, function (obj) { | ||
obj.err = _.pick(obj.err, Object.getOwnPropertyNames(obj.err)); | ||
return '<dt>' + obj.desc + '</dt><dd>' + JSON.stringify(obj.err).replace(/\\n/g, '<br/>') + '</dd>'; | ||
|
||
let message; | ||
|
||
if (typeof obj.err === 'string' || obj.err instanceof String) { | ||
message = obj.err; | ||
} else { | ||
message = JSON.stringify(_.pick(obj.err, Object.getOwnPropertyNames(obj.err))); | ||
} | ||
return '<dt>' + obj.desc + '</dt><dd>' + message.replace(/\\n/g, '<br/>') + '</dd>'; | ||
}).join(' '); | ||
|
||
res.set('Content-Type', 'text/html'); | ||
res.send(head + errors + tail); | ||
res.render('error.html', { | ||
errors, | ||
locals | ||
}); | ||
|
||
}); | ||
|
||
app.setLocals = function (_locals) { | ||
locals = _locals; | ||
} | ||
|
||
return app; | ||
} | ||
|
||
module.exports = bootError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.