@@ -3,6 +3,7 @@
|
|||||||
const { NonMemoryCachingBaseService } = require('..')
|
const { NonMemoryCachingBaseService } = require('..')
|
||||||
|
|
||||||
const serverStartTime = new Date(new Date().toGMTString())
|
const serverStartTime = new Date(new Date().toGMTString())
|
||||||
|
let bitFlip = false
|
||||||
|
|
||||||
module.exports = class Debug extends NonMemoryCachingBaseService {
|
module.exports = class Debug extends NonMemoryCachingBaseService {
|
||||||
static get category() {
|
static get category() {
|
||||||
@@ -19,7 +20,7 @@ module.exports = class Debug extends NonMemoryCachingBaseService {
|
|||||||
static get route() {
|
static get route() {
|
||||||
return {
|
return {
|
||||||
base: 'debug',
|
base: 'debug',
|
||||||
pattern: ':which(time|starttime)',
|
pattern: ':which(time|starttime|flip)',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +36,22 @@ module.exports = class Debug extends NonMemoryCachingBaseService {
|
|||||||
label: 'start time',
|
label: 'start time',
|
||||||
message: new Date(serverStartTime).toUTCString(),
|
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',
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,3 +7,11 @@ const t = (module.exports = require('../tester').createServiceTester())
|
|||||||
t.create('start time')
|
t.create('start time')
|
||||||
.get('/starttime.json')
|
.get('/starttime.json')
|
||||||
.expectJSONTypes({ name: 'start time', value: Joi.date().required() })
|
.expectJSONTypes({ name: 'start time', value: Joi.date().required() })
|
||||||
|
|
||||||
|
t.create('Flip: first request')
|
||||||
|
.get('/flip.json')
|
||||||
|
.expectJSON({ name: 'flip', value: 'on' })
|
||||||
|
|
||||||
|
t.create('Flip: second request')
|
||||||
|
.get('/flip.json')
|
||||||
|
.expectJSON({ name: 'flip', value: 'off' })
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
const { NonMemoryCachingBaseService } = require('..')
|
|
||||||
|
|
||||||
let bitFlip = false
|
|
||||||
|
|
||||||
// Production cache debugging.
|
|
||||||
module.exports = class Flip extends NonMemoryCachingBaseService {
|
|
||||||
static get category() {
|
|
||||||
return 'debug'
|
|
||||||
}
|
|
||||||
|
|
||||||
static get route() {
|
|
||||||
return { base: 'flip', pattern: '' }
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
|
||||||
return { label: 'flip' }
|
|
||||||
}
|
|
||||||
|
|
||||||
static render({ bit }) {
|
|
||||||
if (bit) {
|
|
||||||
return { message: 'on', color: 'brightgreen' }
|
|
||||||
} else {
|
|
||||||
return { message: 'off', color: 'red' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handle() {
|
|
||||||
bitFlip = !bitFlip
|
|
||||||
return this.constructor.render({ bit: bitFlip })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
const t = (module.exports = require('../tester').createServiceTester())
|
|
||||||
|
|
||||||
t.create('First request')
|
|
||||||
.get('.json')
|
|
||||||
.expectJSON({ name: 'flip', value: 'on' })
|
|
||||||
|
|
||||||
t.create('Second request')
|
|
||||||
.get('.json')
|
|
||||||
.expectJSON({ name: 'flip', value: 'off' })
|
|
||||||
Reference in New Issue
Block a user