-
Notifications
You must be signed in to change notification settings - Fork 6
/
profile.js
42 lines (40 loc) · 1.33 KB
/
profile.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
const Joi = require('@hapi/joi');
const ProfileCtrl = require('modules/authorization/controllers/profile');
const User = require('models/authorization/user');
// GET /profile
exports.get = {
description: 'Get the user profile',
handler: ProfileCtrl.get
};
// PUT /profile
exports.update = {
description: 'Update the user profile',
handler: ProfileCtrl.update,
validate: {
payload: Joi.object({
username: Joi.string()
.min(User.USERNAME_MIN_LENGTH)
.max(User.USERNAME_MAX_LENGTH)
.description('The new username'),
name: Joi.string()
.min(User.NAME_MIN_LENGTH)
.max(User.NAME_MAX_LENGTH)
.description('The new name'),
email: Joi.string()
.email()
.description('The new email'),
password: Joi.string()
.min(User.PASSWORD_MIN_LENGTH)
.max(User.PASSWORD_MAX_LENGTH)
.description('The new password'),
avatar: Joi.string()
.uri({
scheme: ['http', 'https'],
allowRelative: true
})
.description('The new user avatar URI'),
roles: Joi.forbidden(),
active: Joi.forbidden()
})
}
};