feat(auth): add MockUsersRepository with seed users

This commit is contained in:
2026-05-05 00:39:46 +02:00
parent 786f3c3420
commit 1becc23843

View File

@@ -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;
}
}