feat(auth): add MockUsersRepository with seed users
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import "reflect-metadata";
|
||||
import { injectable } from "inversify";
|
||||
|
||||
import type { IUsersRepository } from "../../application/repositories/users-repository.interface";
|
||||
import type { User } from "../../entities/user";
|
||||
|
||||
@injectable()
|
||||
export class MockUsersRepository implements IUsersRepository {
|
||||
private _users: User[] = [
|
||||
{ id: "1", username: "alice", passwordHash: "hashed_password_alice" },
|
||||
{ id: "2", username: "bob", passwordHash: "hashed_password_bob" },
|
||||
];
|
||||
|
||||
async getUser(id: string): Promise<User | undefined> {
|
||||
return this._users.find((u) => u.id === id);
|
||||
}
|
||||
|
||||
async getUserByUsername(username: string): Promise<User | undefined> {
|
||||
return this._users.find((u) => u.username === username);
|
||||
}
|
||||
|
||||
async createUser(input: User): Promise<User> {
|
||||
this._users.push(input);
|
||||
return input;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user