mirror of
https://github.com/badges/shields.git
synced 2025-09-19 16:01:38 +03:00
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import { BaseService } from '../index.js'
|
|
|
|
const serverStartTime = new Date(new Date().toGMTString())
|
|
let bitFlip = false
|
|
|
|
export default class Debug extends BaseService {
|
|
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',
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|