1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/lib/routes/client-api/metrics-schema.js

39 lines
926 B
JavaScript
Raw Normal View History

'use strict';
2020-01-02 19:23:52 +01:00
const joi = require('@hapi/joi');
2016-11-11 15:46:59 +01:00
2017-11-02 09:23:38 +01:00
const countSchema = joi
.object()
.options({ stripUnknown: true })
.keys({
yes: joi
.number()
.min(0)
.empty('')
2017-11-02 09:23:38 +01:00
.default(0),
no: joi
.number()
.min(0)
.empty('')
2017-11-02 09:23:38 +01:00
.default(0),
2019-02-07 22:15:03 +01:00
variants: joi.object().pattern(joi.string(), joi.number().min(0)),
2017-11-02 09:23:38 +01:00
});
2017-11-02 09:23:38 +01:00
const clientMetricsSchema = joi
.object()
.options({ stripUnknown: true })
.keys({
appName: joi.string().required(),
instanceId: joi.string().required(),
bucket: joi
.object()
.required()
.keys({
start: joi.date().required(),
stop: joi.date().required(),
toggles: joi.object().pattern(/.*/, countSchema),
}),
});
2016-11-11 15:46:59 +01:00
module.exports = { clientMetricsSchema };