feat: implement error handling and validation middleware, enhance result handling

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Jose Selesan
2026-04-23 16:35:57 -03:00
parent 7bfa3b390e
commit 20d6018836
14 changed files with 306 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
import { Prisma } from '@/generated/prisma/client';
import { Prisma, Sport } from '@/generated/prisma/client';
import { db } from '@/lib/prisma';
import { ok, Result } from '@/lib/result';
import { v7 as uuidv7 } from 'uuid';
export type CreateSportInput = {
@@ -51,10 +52,11 @@ async function buildUniqueSlug(source: string, excludeSportId?: string): Promise
}
}
export async function listSports() {
return db.sport.findMany({
export async function listSports(): Promise<Result<Sport[]>> {
const sports = await db.sport.findMany({
orderBy: { name: 'asc' },
});
return ok(sports);
}
export async function createSport(input: CreateSportInput) {