Replace legacy checkBodyType with Zod
Start matchmaking integration Start rooms API Move existing room scene locations to roomtypes file Auth checkExpired util for client refreshing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { APIUtils } from "../../apiutils.ts";
|
||||
import express from "express";
|
||||
import Profile from "../../data/profiles.ts";
|
||||
import { z } from "zod";
|
||||
|
||||
export const route = APIUtils.createRouter("/account");
|
||||
|
||||
@@ -10,6 +11,12 @@ interface CreateAccountRequestBody {
|
||||
deviceId: string;
|
||||
}
|
||||
|
||||
const CreateAccountRequestBodySchema = z.object({
|
||||
platform: z.string(),
|
||||
platformId: z.string(),
|
||||
deviceId: z.string()
|
||||
});
|
||||
|
||||
const rateLimit = new APIUtils.RateLimiter(25, 5);
|
||||
|
||||
route.router.post("/create",
|
||||
@@ -17,11 +24,7 @@ route.router.post("/create",
|
||||
rateLimit.middle(),
|
||||
APIUtils.Authentication,
|
||||
express.urlencoded({ extended: true }),
|
||||
APIUtils.checkBodyTypes<CreateAccountRequestBody>({
|
||||
platform: "",
|
||||
platformId: "",
|
||||
deviceId: "",
|
||||
}),
|
||||
APIUtils.validateRequestBody(CreateAccountRequestBodySchema),
|
||||
|
||||
async (_rq, rs) => {
|
||||
const newAcc = await Profile.init();
|
||||
@@ -33,6 +36,7 @@ route.router.post("/create",
|
||||
value: await newAcc.export(),
|
||||
});
|
||||
},
|
||||
|
||||
);
|
||||
|
||||
route.router.get("/bulk",
|
||||
|
||||
Reference in New Issue
Block a user