Complete refractor - we do sexy code only

This commit is contained in:
2024-05-09 04:00:05 +02:00
parent ca88c085e6
commit 8356a83431
28 changed files with 449 additions and 492 deletions

View File

@ -1,15 +0,0 @@
import { Map } from '@prisma/client';
import prisma from '../helpers/prisma'; // Import the global Prisma instance
class MapRepository {
async getFirst(): Promise<Map | null> {
try {
return await prisma.map.findFirst();
} catch (error) {
// Handle error
throw new Error(`Failed to get first map: ${error.message}`);
}
}
}
export default new MapRepository;

View File

@ -1,20 +0,0 @@
import prisma from '../helpers/prisma'; // Import the global Prisma instance
import { User } from '@prisma/client';
import bcrypt from 'bcryptjs';
class UserRepository {
async getByUsername(username: string): Promise<User | null> {
try {
return await prisma.user.findUnique({
where: {
username,
},
});
} catch (error) {
// Handle error
throw new Error(`Failed to get user by username: ${error.message}`);
}
}
}
export default new UserRepository;