Files
shields/services/debug/debug.service.js
chris48s 65dba94fa8 Stop calling variables "which"; affects [chocolatey codeclimate conda crates debug gem github mozillaobservatory nuget powershellgallery pub resharper vaadindirectory] (#3495)
* which --> variant

* which --> alias

* which --> format

* improve param names in codeclimate

* improve param names in github-issue-detail

* update github-issue-detail unit tests
2019-05-28 23:00:12 +01:00

58 lines
1.1 KiB
JavaScript

'use strict'
const { NonMemoryCachingBaseService } = require('..')
const serverStartTime = new Date(new Date().toGMTString())
let bitFlip = false
module.exports = class Debug extends NonMemoryCachingBaseService {
static get category() {
return 'debug'
}
static get route() {
return {
base: 'debug',
pattern: ':variant(time|starttime|flip)',
}
}
static get defaultBadgeData() {
return {
label: 'debug',
color: 'blue',
}
}
async handle({ variant }) {
switch (variant) {
case 'time':
return {
label: 'time',
message: new Date().toUTCString(),
}
case 'starttime':
return {
label: 'start time',
message: new Date(serverStartTime).toUTCString(),
}
// For production cache debugging.
case 'flip':
bitFlip = !bitFlip
if (bitFlip) {
return {
label: 'flip',
message: 'on',
color: 'brightgreen',
}
} else {
return {
label: 'flip',
message: 'off',
color: 'red',
}
}
}
}
}