-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.js
83 lines (78 loc) · 1.92 KB
/
validate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'use strict';
const Joi = require('joi');
const options = Joi.object().keys({
level: Joi.string().valid('silly', 'debug', 'verbose', 'info', 'warn', 'error'),
fileLogger: Joi.object().keys({
filename: Joi.string(),
logDirectory: Joi.string(),
datePattern: Joi.string(),
prepend: Joi.boolean(),
zippedArchive: Joi.boolean(),
maxDays: Joi.number()
.integer()
.min(0),
}),
queryApi: Joi.object().keys({
active: Joi.boolean(),
path: Joi.string().uri({
allowRelative: true,
relativeOnly: true,
}),
user: Joi.string().min(3),
password: Joi.string().min(5),
security: Joi.object()
.keys({
jwt: Joi.object()
.keys({
key: Joi.string().required(),
algorithm: Joi.string().valid(
'HS256',
'HS384',
'HS512',
'RS256',
'RS384',
'RS512',
'ES256',
'ES384',
'ES512',
'none'
),
cookieOptions: Joi.object().keys({
ttl: Joi.number()
.integer()
.min(0),
isSecure: Joi.boolean(),
isHttpOnly: Joi.boolean(),
encoding: Joi.string(),
clearInvalid: Joi.boolean(),
strictHeader: Joi.boolean(),
}),
})
.required(),
})
.required(),
}),
});
const authData = Joi.object().keys({
u: Joi.string()
.min(3)
.required(),
pwd: Joi.string()
.min(5)
.required(),
});
const queryOptions = Joi.object().keys({
from: Joi.date().max(Joi.ref('until')),
until: Joi.date(),
limit: Joi.number()
.integer()
.positive(),
start: Joi.number().integer(),
order: Joi.string().valid('desc', 'asc'),
fields: Joi.array().items(Joi.string().required()),
});
module.exports = {
options,
authData,
queryOptions,
};