Skip to content

Commit

Permalink
Server start time badge [debug] (#2631)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored Jan 4, 2019
1 parent 5233a25 commit d97a5e4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 28 deletions.
40 changes: 40 additions & 0 deletions services/debug/debug.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict'

const NonMemoryCachingBaseService = require('../base-non-memory-caching')

const serverStartTime = new Date(new Date().toGMTString())

module.exports = class Debug extends NonMemoryCachingBaseService {
static get category() {
return 'debug'
}

static get defaultBadgeData() {
return {
label: 'debug',
color: 'blue',
}
}

static get route() {
return {
base: 'debug',
pattern: ':which(time|starttime)',
}
}

async handle({ which }) {
switch (which) {
case 'time':
return {
label: 'time',
message: new Date().toUTCString(),
}
case 'starttime':
return {
label: 'start time',
message: new Date(serverStartTime).toUTCString(),
}
}
}
}
9 changes: 9 additions & 0 deletions services/debug/debug.tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

const Joi = require('joi')

const t = (module.exports = require('../create-service-tester')())

t.create('start time')
.get('/starttime.json')
.expectJSONTypes({ name: 'start time', value: Joi.date().required() })
28 changes: 0 additions & 28 deletions services/time/time.service.js

This file was deleted.

0 comments on commit d97a5e4

Please sign in to comment.