Initial commit

This commit is contained in:
2025-07-25 19:00:06 -04:00
commit e604c7a437
52 changed files with 96098 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
import { createHonoRoute, routeImporter } from "../../util/import.ts";
export const route = createHonoRoute('/accounts');
await routeImporter(route.app, 'src/routes/accounts/', [
'routes'
]);

View File

@@ -0,0 +1,38 @@
import { createHonoRoute } from "../../../util/import.ts";
import { authenticate } from "../../../util/api.ts";
import Server from "../../../server/server.ts";
import z from "zod";
import { typedZValidator } from "../../../util/validators.ts";
export const route = createHonoRoute('/account');
const transformNumber = (arg: string, ctx: z.RefinementCtx<string>) => {
const int = parseInt(arg);
if (isNaN(int) || !Number.isSafeInteger(int)) ctx.addIssue('Number is not valid');
else return int;
}
const bulkAccountQuerySchema = z.object({
id: z.union([ z.string().transform(transformNumber), z.array(z.string().transform(transformNumber)) ])
});
route.app.get('/bulk', typedZValidator('query', bulkAccountQuerySchema), async c => {
const { id } = c.req.valid('query');
let ids: number[] = [];
if (!id) return c.json([]);
if (typeof id == 'number') ids = [id];
else ids = id.filter(val => typeof val == 'number');
return c.json((await Promise.all(ids.map(id => Server.Profiles.get(id))))
.filter(val => val !== null)
.map(prof => prof.export())
.filter(val => val !== null)
);
});
route.app.use('*', authenticate);
route.app.get('/me', c => {
const profile = c.get('profile');
return c.json(profile.selfExport());
});