changed network log format, player settings

This commit is contained in:
2025-07-26 00:17:14 -04:00
parent e604c7a437
commit 2302290d34
8 changed files with 126 additions and 27 deletions

View File

@@ -3,6 +3,9 @@ import { authenticate } from "../../../util/api.ts";
import Server from "../../../server/server.ts";
import z from "zod";
import { typedZValidator } from "../../../util/validators.ts";
import Logging from "@proxnet/undead-logging";
const log = new Logging("AccountDebug");
export const route = createHonoRoute('/account');
@@ -29,10 +32,9 @@ route.app.get('/bulk', typedZValidator('query', bulkAccountQuerySchema), async c
);
});
route.app.use('*', authenticate);
route.app.use(authenticate);
route.app.get('/me', c => {
const profile = c.get('profile');
return c.json(profile.selfExport());
});

View File

@@ -0,0 +1,28 @@
import z from "zod";
import { authenticate, genericResponse } from "../../../util/api.ts";
import { createHonoRoute } from "../../../util/import.ts";
import { transformStringToEnum, typedZValidator } from "../../../util/validators.ts";
import { ProfileSetting } from "../../../server/profiles/content/Settings.ts";
import { trimTrailingSlash } from "@hono/hono/trailing-slash";
export const route = createHonoRoute('/settings');
route.app.use(authenticate, trimTrailingSlash());
route.app.get('/v2', async c => {
const profile = c.get('profile');
const settings = await profile.Settings.getAllSettings();
c.json(settings);
});
const settingsSetSchema = z.object({
Key: z.string().transform(transformStringToEnum<ProfileSetting>(ProfileSetting, true)),
Value: z.string()
});
route.app.post('/v2/set', typedZValidator('json', settingsSetSchema), async c => {
const { Key, Value } = c.req.valid('json');
if (!Key) return c.json(genericResponse(false, "Internal Server Error"), 500);
await c.get('profile').Settings.setSetting(Key, Value);
return c.status(200);
});