1.1.0 #29
@@ -482,7 +482,7 @@ export const app = new Elysia()
|
||||
.group("/assessments", (app) => app
|
||||
.guard({ auth: true }, (app) => app
|
||||
.post("/me", async ({ body: { player, activityPerformances }, accountId }) => {
|
||||
await s.Assessments.create(player, activityPerformances, accountId);
|
||||
return await s.Assessments.create(player, activityPerformances, accountId);
|
||||
}, {
|
||||
body: t.Object({
|
||||
player: PlayerSchema,
|
||||
@@ -490,9 +490,13 @@ export const app = new Elysia()
|
||||
})
|
||||
})
|
||||
.get("/me", async ({ accountId }) => {
|
||||
const assessments = await s.Assessments.list({ filter: { accountId } });
|
||||
if (!assessments) throw new NotFoundError("Assessments not found");
|
||||
return assessments;
|
||||
return await s.Assessments.list({ filter: { accountId } });
|
||||
})
|
||||
.delete("/me/:id", async ({ params: { id }, accountId }) => {
|
||||
const deleted = await s.Assessments.delete(id, accountId);
|
||||
if (!deleted) throw new NotFoundError("Assessment not found");
|
||||
}, {
|
||||
params: t.Object({ id: t.String() })
|
||||
})
|
||||
)
|
||||
.guard({ authAdmin: true }, (app) => app
|
||||
|
||||
@@ -39,4 +39,12 @@ export class AssessmentsService {
|
||||
.$if(opt.offset !== undefined, (qb) => qb.offset(opt.offset!))
|
||||
.execute();
|
||||
}
|
||||
|
||||
async delete(id: string, accountId: string): Promise<boolean> {
|
||||
const result = await db.deleteFrom("assessments")
|
||||
.where("id", "=", id)
|
||||
.where("account_id", "=", accountId)
|
||||
.executeTakeFirst();
|
||||
return result.numDeletedRows > 0n;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user