Implement basic verifications API endpoints
This commit is contained in:
+55
-1
@@ -1,5 +1,7 @@
|
||||
import {
|
||||
ActivityPerformanceSchema,
|
||||
ActivityVerificationsSchema,
|
||||
ActivityVideosSchema,
|
||||
PlayerSchema,
|
||||
} from "@blade-and-brawn/domain"
|
||||
import { cors } from "@elysiajs/cors";
|
||||
@@ -23,6 +25,7 @@ import { EventsService, EventStatusSchema } from "./services/events";
|
||||
import { AccountsService, type AccountRole } from "./services/accounts";
|
||||
import { Value } from "@sinclair/typebox/value";
|
||||
import { AssessmentsService } from "./services/assessments";
|
||||
import { VerificationsService, VerificationStatusSchema } from "./services/verifications";
|
||||
import { Not } from "@sinclair/typebox";
|
||||
|
||||
// CONSTANTS
|
||||
@@ -40,7 +43,8 @@ const s = (() => {
|
||||
const Accounts = new AccountsService(Calculator);
|
||||
const Events = new EventsService();
|
||||
const Assessments = new AssessmentsService();
|
||||
return { Standards, Calculator, Commerce, Accounts, Events, Assessments };
|
||||
const Verifications = new VerificationsService();
|
||||
return { Standards, Calculator, Commerce, Accounts, Events, Assessments, Verifications };
|
||||
})();
|
||||
|
||||
// QUEUES
|
||||
@@ -523,6 +527,56 @@ export const app = new Elysia()
|
||||
)
|
||||
)
|
||||
|
||||
// VERIFICATIONS
|
||||
.group("/verifications", (app) => app
|
||||
.guard({ auth: true }, (app) => app
|
||||
.post("/me", async ({ body: { assessmentId, activityVideoUrls }, accountId }) => {
|
||||
const requested = await s.Verifications.request(assessmentId, accountId, activityVideoUrls);
|
||||
if (!requested) throw new NotFoundError("Assessment not found");
|
||||
return requested;
|
||||
}, {
|
||||
body: t.Object({
|
||||
assessmentId: t.String(),
|
||||
activityVideoUrls: ActivityVideosSchema,
|
||||
})
|
||||
})
|
||||
)
|
||||
.guard({ authAdmin: true }, (app) => app
|
||||
.get("/", async ({ query }) => {
|
||||
return await s.Verifications.list({
|
||||
filter: { status: query.status },
|
||||
limit: query.limit,
|
||||
offset: query.offset,
|
||||
});
|
||||
}, {
|
||||
query: t.Object({
|
||||
status: t.Optional(VerificationStatusSchema),
|
||||
limit: t.Optional(t.Numeric()),
|
||||
offset: t.Optional(t.Numeric()),
|
||||
})
|
||||
})
|
||||
.post("/:id/request-action", async ({ params: { id }, body: { reviewerNotes, activityVerifications } }) => {
|
||||
const updated = await s.Verifications.requestAction(id, reviewerNotes ?? null, activityVerifications);
|
||||
if (!updated) throw new NotFoundError("Verification not found");
|
||||
}, {
|
||||
params: t.Object({ id: t.String() }),
|
||||
body: t.Object({
|
||||
reviewerNotes: t.Optional(t.String()),
|
||||
activityVerifications: ActivityVerificationsSchema,
|
||||
})
|
||||
})
|
||||
.post("/:id/complete", async ({ params: { id }, body: { activityVerifications }, accountId }) => {
|
||||
const updated = await s.Verifications.complete(id, accountId, activityVerifications);
|
||||
if (!updated) throw new NotFoundError("Verification not found");
|
||||
}, {
|
||||
params: t.Object({ id: t.String() }),
|
||||
body: t.Object({
|
||||
activityVerifications: ActivityVerificationsSchema,
|
||||
})
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
// WEBHOOKS
|
||||
.post("/webhooks/printful", async ({ body, query }) => {
|
||||
// https://webflow.com/integrations/printful
|
||||
|
||||
Reference in New Issue
Block a user