Files
shields/services/debug/debug.service.js
Caleb Cartwright 0b31461af6 convert some service classes to static props, run [date david debian debug dependabot] (#5539)
* refactor(date): convert to static props

* refactor(david): convert to static props

* refactor(debian): convert to static props

* refactor(debug): convert to static props

* refactor(dependabot): convert to static props

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-09-14 21:54:22 +00:00

45 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 category = 'debug'
static route = { base: 'debug', pattern: ':variant(time|starttime|flip)' }
static defaultBadgeData = { 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',
}
}
}
}
}