Skip to content

Commit

Permalink
remove unnecessary bind
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosparajua committed May 2, 2024
1 parent 40179a1 commit dcb99fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/controllers/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export class UsersController extends BaseController<User, UserCreateDto> {
}

async create(req: Request, res: Response, next: NextFunction) {
if (req.body.password !== req.body.repeatPassword) {
next(new HttpError(400, 'Bad Request', 'Passwords do not match'));
return;
}

if (!req.body.password || typeof req.body.password !== 'string') {
next(
new HttpError(
Expand Down
4 changes: 0 additions & 4 deletions src/repositories/users.sql.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ export class UsersSqlRepo implements WithLoginRepo<User, UserCreateDto> {
}

async create(data: UserCreateDto): Promise<User> {
if (data.password !== data.repeatPassword) {
throw new HttpError(400, 'Bad Request', 'Passwords do not match');
}

try {
const newUser = await this.prisma.user.create({ data, select });
return newUser as User;
Expand Down
2 changes: 1 addition & 1 deletion src/routers/files.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class FilesRouter {

this.router.post(
'/',
interceptor.singleFile('avatar').bind(interceptor),
interceptor.singleFile('avatar'),
interceptor.upload.bind(interceptor),
controller.fileHandler.bind(controller)
);
Expand Down
2 changes: 1 addition & 1 deletion src/routers/users.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class UsersRouter {
this.router.post(
'/signup',
filesInterceptor.singleFile('avatar'),
filesInterceptor.upload.bind(filesInterceptor),

controller.create.bind(controller)
);
this.router.post('/login', controller.login.bind(controller));
Expand Down

0 comments on commit dcb99fc

Please sign in to comment.