Refactor 4 with bugfixes
This commit is contained in:
11
server/src/cqrs/queries/handlers/getUserById.ts
Normal file
11
server/src/cqrs/queries/handlers/getUserById.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
import { AuthUserEntity } from '../../../entities';
|
||||
import { GetUserByIdQuery } from '../../types';
|
||||
import { rowToAuthUser } from '../../mappers';
|
||||
|
||||
export async function handleGetUserById(query: GetUserByIdQuery, dataSource: DataSource) {
|
||||
const repo = dataSource.getRepository(AuthUserEntity);
|
||||
const row = await repo.findOne({ where: { id: query.payload.userId } });
|
||||
|
||||
return row ? rowToAuthUser(row) : null;
|
||||
}
|
||||
Reference in New Issue
Block a user