duhhhhhhhh

This commit is contained in:
2025-09-11 13:47:30 -04:00
parent eef3667618
commit 317da3aaf7
53 changed files with 1395 additions and 212 deletions

View File

@@ -1,10 +1,11 @@
import { createHonoRoute } from "../../../util/import.ts";
import { authenticate, galvanicError, GalvanicErrors, RateLimiter, recNetError } from "../../../util/api.ts";
import { authenticate, galvanicError, GalvanicErrors, RateLimiter, recNetError, statusResponse } from "../../../util/api.ts";
import Server from "../../../server/server.ts";
import z from "zod";
import { transformStringToEnum, typedZValidator } from "../../../util/validators.ts";
import { transformCheckEnum, typedZValidator } from "../../../util/validators.ts";
import { PlatformType } from "../../../server/platforms/types.ts";
import Steam from "../../../util/steam/steam.ts";
import { HTTPStatus } from "@oneday/http-status";
export const route = createHonoRoute('/account');
@@ -28,7 +29,7 @@ route.app.get('/bulk', typedZValidator('query', bulkAccountQuerySchema), async c
const postCreateRateLimiter = new RateLimiter(60, 3);
const createAccountBodySchema = z.object({
platform: z.string().transform(transformStringToEnum<PlatformType>(PlatformType)),
platform: z.coerce.number().transform(transformCheckEnum<PlatformType>(PlatformType)),
platformId: z.string().min(14).max(20),
deviceId: z.string().min(32).max(64)
});
@@ -71,9 +72,16 @@ route.app.post('/create', postCreateRateLimiter.middle(), typedZValidator('form'
});
route.app.use(authenticate);
route.app.get('/me', c => {
route.app.get('/me', authenticate, c => {
const profile = c.get('profile');
return c.json(profile.selfExport());
});
const getAccountByIdParamSchema = z.object({
id: z.coerce.number().max(Math.pow(2, 31))
});
route.app.get('/:id', typedZValidator('param', getAccountByIdParamSchema), async c => {
const prof = await Server.Profiles.get(c.req.valid('param').id);
if (prof) return c.json(prof.export());
else return statusResponse(c, HTTPStatus.NotFound);
});