Skip to content

Commit f3d2ba2

Browse files
committed
feat(register): user name added
1 parent e7982d7 commit f3d2ba2

File tree

6 files changed

+228
-6
lines changed

6 files changed

+228
-6
lines changed

package-lock.json

Lines changed: 218 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "user-management",
3-
"version": "1.4.2",
3+
"version": "1.5.0",
44
"description": "Microservicio de administración de usuario con public key",
55
"main": "./src/index.js",
66
"type": "module",
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
9-
"dev": "node --trace-warnings --watch --env-file .env dist/index.js",
9+
"dev": "nodemon --env-file .env dist/index.js",
1010
"build": "tsc --watch"
1111
},
1212
"keywords": [
@@ -39,6 +39,7 @@
3939
"eslint-plugin-import": "2.28.1",
4040
"eslint-plugin-n": "16.1.0",
4141
"eslint-plugin-promise": "6.1.1",
42+
"nodemon": "^3.0.1",
4243
"typescript": "5.2.2"
4344
}
4445
}

src/controllers/user.controllers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { HttpStatusCode } from '../enums/httpStatusCodes.enums.js'
77
import jwt from 'jsonwebtoken'
88

99
export const createUserByEmail = async (req: Request, res: Response): Promise<Response> => {
10-
const { userEmail, dbNameSpace, userPassword, userRole, IDKey } = req.body as user
10+
const { userName, userEmail, dbNameSpace, userPassword, userRole, IDKey } = req.body as user
1111
try {
12-
const [query] = await pool.query('INSERT INTO users (id_user_api_key, user_email, user_password, id_user_role_fk, db_namespace) VALUES (?, ?, ?, ?, ?)', [IDKey, userEmail, userPassword, userRole, dbNameSpace])
12+
const [query] = await pool.query('INSERT INTO users (id_user_api_key, user_full_name, user_email, user_password, id_user_role_fk, db_namespace) VALUES (?, ?, ?, ?, ?)', [IDKey, userName, userEmail, userPassword, userRole, dbNameSpace])
1313
if (Array.isArray(query) && query.length === 0) throw new APIError('Ha ocurrido un error al ingresar los datos')
1414
return res.status(HttpStatusCode.OK).json({ msg: 'User created!' })
1515
} catch (error: any) {

src/interfaces/user.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface dbNameSpace {
66
}
77

88
export interface user extends dbNameSpace, publicKey {
9+
userName: string
910
userEmail: string
1011
userPassword: string
1112
userRole: number

src/middlewares/user.middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { pool } from '../config/dbconection.js'
99
import { type RowDataPacket } from 'mysql2'
1010

1111
export const checkUserData = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
12-
const { userEmail, userPassword, userRole, dbNameSpace } = req.body as user
12+
const { userName, userEmail, userPassword, userRole, dbNameSpace } = req.body as user
1313
try {
14-
const { error } = await userSchema.validateAsync({ userEmail, userPassword, userRole, dbNameSpace })
14+
const { error } = await userSchema.validateAsync({ userName, userEmail, userPassword, userRole, dbNameSpace })
1515
if (error !== undefined) throw new APIError('Los datos ingresados no son válidos, verifíquelos.')
1616
next()
1717
} catch (error: any) {

src/schemas/user.schemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Joi from 'joi'
33
const passwordPattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/
44

55
export const userSchema = Joi.object({
6+
userName: Joi
7+
.string().allow(null),
68
userEmail: Joi
79
.string().email().required(),
810
userPassword: Joi

0 commit comments

Comments
 (0)