-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server start time badge [debug] (#2631)
- Loading branch information
1 parent
5233a25
commit d97a5e4
Showing
3 changed files
with
49 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() }) |
This file was deleted.
Oops, something went wrong.