v3: code quality pass

This commit is contained in:
khannurien
2026-03-24 18:47:05 +00:00
parent cd4076343b
commit c293f3e706
39 changed files with 1464 additions and 1555 deletions

View File

@@ -16,7 +16,10 @@ import {
} from "../services/vote-service.ts";
import { getUnreadCount } from "../services/notification-service.ts";
import { getUserById } from "../services/user-service.ts";
import { APIException } from "../model/interfaces.ts";
import {
APIException,
type ClientToServerMessage,
} from "../model/interfaces.ts";
const router = new Router();
@@ -78,7 +81,7 @@ router.get("/ws", async (ctx) => {
});
socket.addEventListener("message", (event) => {
let msg: { type: string; dumpId?: string };
let msg: ClientToServerMessage;
try {
msg = JSON.parse(event.data as string);
} catch {
@@ -109,7 +112,7 @@ router.get("/ws", async (ctx) => {
function handleVote(
client: WsClient,
dumpId: string | undefined,
dumpId: string,
action: "cast" | "remove",
): void {
const { socket } = client;
@@ -121,11 +124,6 @@ function handleVote(
return;
}
if (!dumpId) {
socket.send(JSON.stringify({ type: "error", message: "Missing dumpId" }));
return;
}
try {
const newCount = action === "cast"
? castVote(dumpId, client.userId)