chore: migrate minimum from lab1
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ApiError } from '../common/filters/api-error';
|
||||
import { User } from '../common/store/domain';
|
||||
import { StoreService } from '../common/store/store.service';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
constructor(private readonly store: StoreService) {}
|
||||
|
||||
register(username: string, displayName: string): User {
|
||||
const user = this.store.createUser(username, displayName.trim());
|
||||
if (!user) {
|
||||
throw new ApiError('conflict', 'username is already taken');
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user