Skip to content

Commit 03da41a

Browse files
committed
Ref(user.js): phone_number key changed to phone
1 parent 7814b62 commit 03da41a

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

.eslintrc.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,8 @@ module.exports = {
88
node: true,
99
mocha: true
1010
},
11-
extends: [
12-
'standard',
13-
'plugin:mocha/recommended',
14-
'plugin:security/recommended'
15-
],
16-
plugins: [
17-
'mocha',
18-
'security'
19-
],
11+
extends: ['standard', 'plugin:mocha/recommended', 'plugin:security/recommended'],
12+
plugins: ['mocha', 'security'],
2013
parserOptions: {
2114
ecmaVersion: 12
2215
},
@@ -29,10 +22,11 @@ module.exports = {
2922
'no-trailing-spaces': 'error',
3023
'consistent-return': 'error',
3124
'no-console': 'error',
25+
semi: 0,
3226

3327
// Custom mocha rules
3428
// 'mocha/no-skipped-tests': 'error',
3529
'mocha/no-exclusive-tests': 'error'
3630
},
3731
ignorePatterns: ['public/*']
38-
}
32+
};

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
3+
module.exports = {
4+
singleQuote: true,
5+
};

middlewares/validators/user.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const joi = require('joi')
1+
const joi = require('joi');
22

33
const createUser = async (req, res, next) => {
44
const schema = joi.object().keys({
5-
phone_number: joi.string().optional(),
5+
phone: joi.string().optional(),
66
email: joi.string().optional(),
77
company_name: joi.string().optional(),
88
username: joi.string().optional(),
@@ -21,20 +21,20 @@ const createUser = async (req, res, next) => {
2121
isMember: joi.boolean().optional(),
2222
tokens: joi.object().optional(),
2323
website: joi.string().optional()
24-
})
24+
});
2525

2626
try {
27-
await schema.validateAsync(req.body)
28-
next()
27+
await schema.validateAsync(req.body);
28+
next();
2929
} catch (error) {
30-
logger.error(`Error validating createUser payload : ${error}`)
31-
res.boom.badRequest(error.details[0].message)
30+
logger.error(`Error validating createUser payload : ${error}`);
31+
res.boom.badRequest(error.details[0].message);
3232
}
33-
}
33+
};
3434

3535
const updateUser = async (req, res, next) => {
3636
const schema = joi.object().keys({
37-
phone_number: joi.string().optional(),
37+
phone: joi.string().optional(),
3838
email: joi.string().optional(),
3939
company_name: joi.string().optional(),
4040
username: joi.string().optional(),
@@ -53,18 +53,18 @@ const updateUser = async (req, res, next) => {
5353
isMember: joi.boolean().optional(),
5454
tokens: joi.object().optional(),
5555
website: joi.string().optional()
56-
})
56+
});
5757

5858
try {
59-
await schema.validateAsync(req.body)
60-
next()
59+
await schema.validateAsync(req.body);
60+
next();
6161
} catch (error) {
62-
logger.error(`Error validating updateUser payload : ${error}`)
63-
res.boom.badRequest(error.details[0].message)
62+
logger.error(`Error validating updateUser payload : ${error}`);
63+
res.boom.badRequest(error.details[0].message);
6464
}
65-
}
65+
};
6666

6767
module.exports = {
6868
createUser,
6969
updateUser
70-
}
70+
};

0 commit comments

Comments
 (0)