sveltekit 2 migration

This commit is contained in:
George Hotten committed 2025-05-18 18:26:14 +01:00
1 parent 5cbf27d25a
commit f05b0cdf47
36 files changed
+92 -91

No files matched your search

+5 -4
View File
@@ -10,16 +10,17 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-node": "^1.2.4",
"@sveltejs/kit": "^1.30.4",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-node": "^2.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/bcryptjs": "^2.4.2",
"@types/jsonwebtoken": "^9.0.2",
"svelte": "^4.0.0",
"svelte-check": "^3.4.3",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.3.0"
"vite": "^5.0.0"
},
"type": "module",
"dependencies": {
+2 -2
View File
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
+2 -2
View File
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
+4 -4
View File
@@ -10,7 +10,7 @@ export const load = async ({ params, fetch, }) => {
if (resBans.status == 200) {
recentBans = await resBans.json();
} else {
throw error(500, "Could not load recent bans.")
error(500, "Could not load recent bans.");
}
const resMutes = await fetch("/backend/mutes/recent");
@@ -19,7 +19,7 @@ export const load = async ({ params, fetch, }) => {
if (resMutes.status == 200) {
recentMutes = await resMutes.json();
} else {
throw error(500, "Could not load recent mutes.")
error(500, "Could not load recent mutes.");
}
const resStats = await fetch("/backend/public/onlinestats");
@@ -27,7 +27,7 @@ export const load = async ({ params, fetch, }) => {
if (resStats.status == 200) {
onlineStats = await resStats.json();
} else {
throw error(500, "Could not load online stats.")
error(500, "Could not load online stats.");
}
const resPunStats = await fetch("/backend/punish/stats");
@@ -35,7 +35,7 @@ export const load = async ({ params, fetch, }) => {
if (resPunStats.status == 200) {
punishStats = await resPunStats.json();
} else {
throw error(500, "Could not load punish stats.")
error(500, "Could not load punish stats.");
}
return {
@@ -8,14 +8,14 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
if (!sessionUser.admin) {
throw error(403, "Unauthorized.")
error(403, "Unauthorized.");
}
return {
+4 -4
View File
@@ -10,7 +10,7 @@ export const load = async ({ fetch, parent }) => {
if (resUnassigned.status == 200) {
unassigned = await resUnassigned.json();
} else {
throw error(500, "Server failed to get appeals.")
error(500, "Server failed to get appeals.");
}
const resMy = await fetch("/backend/appeals/by/" + sessionUser.uuid);
@@ -19,7 +19,7 @@ export const load = async ({ fetch, parent }) => {
if (resMy.status == 200) {
my = await resMy.json();
} else {
throw error(500, "Server failed to get appeals.")
error(500, "Server failed to get appeals.");
}
const resPending = await fetch("/backend/appeals/pending");
@@ -28,7 +28,7 @@ export const load = async ({ fetch, parent }) => {
if (resPending.status == 200) {
pending = await resPending.json();
} else {
throw error(500, "Server failed to get appeals.")
error(500, "Server failed to get appeals.");
}
const resClosed = await fetch("/backend/appeals/closed");
@@ -37,7 +37,7 @@ export const load = async ({ fetch, parent }) => {
if (resClosed.status == 200) {
closed = await resClosed.json();
} else {
throw error(500, "Server failed to get appeals.")
error(500, "Server failed to get appeals.");
}
return {
@@ -12,14 +12,14 @@ export const load = (async ({ locals, params }) => {
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
if (!sessionUser.admin) {
throw error(403, "Unauthorized.")
error(403, "Unauthorized.");
}
return {
@@ -29,7 +29,7 @@ export const load = (async ({ locals, params }) => {
export const actions = {
back: async (event) => {
throw redirect(303, '/appeals/');
redirect(303, '/appeals/');
},
claim: async (event) => {
@@ -43,7 +43,7 @@ export const actions = {
return fail(500, { success: false, message: "Server failed to claim appeal."})
}
throw redirect(303, '/appeals/' + appealId + '?message=claimed');
redirect(303, '/appeals/' + appealId + '?message=claimed');
},
accept: async (event) => {
@@ -70,7 +70,7 @@ export const actions = {
}
if (await revokePunishment((appeal.type == "Ban" ? "staffog_ban" : "staffog_mute"), appeal.pid, appeal.assigned, appeal.assigned_name + " (via Appeals)", comments.toString()) == false) {
throw redirect(303, '/appeals/' + appealId + '?message=closedrevokefail');
redirect(303, '/appeals/' + appealId + '?message=closedrevokefail');
}
let revokeTask: RevokePunishmentTask = {
@@ -79,7 +79,7 @@ export const actions = {
};
await queueTask("unpunish", JSON.stringify(revokeTask));
throw redirect(303, '/appeals/' + appealId + '?message=closed');
redirect(303, '/appeals/' + appealId + '?message=closed');
},
reject: async (event) => {
@@ -95,6 +95,6 @@ export const actions = {
return fail(500, { success: false, closeMessage: "Server failed to close appeal."})
}
throw redirect(303, '/appeals/' + appealId + '?message=closed');
redirect(303, '/appeals/' + appealId + '?message=closed');
}
}
@@ -11,7 +11,7 @@ export const load = async ({ url, params, fetch }) => {
if (resAppeal.status == 200) {
appeal = await resAppeal.json();
} else {
throw error(404, "Appeal not found.")
error(404, "Appeal not found.");
}
const resPunishment = await fetch("/backend/" + appeal.type.toLowerCase() + "s/" + appeal.pid);
@@ -20,7 +20,7 @@ export const load = async ({ url, params, fetch }) => {
if (resPunishment.status == 200) {
punishment = await resPunishment.json();
} else {
throw error(404, "Punishment not found.")
error(404, "Punishment not found.");
}
return {
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ export const load = async ({ params, fetch, url }) => {
if (resBan.status == 200) {
ban = await resBan.json();
} else {
throw error(404, "Punishment not found.")
error(404, "Punishment not found.");
}
return {
@@ -13,14 +13,14 @@ export const load = (async ({ locals, params }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
if (!sessionUser.admin) {
throw error(403, "Unauthorized.")
error(403, "Unauthorized.");
}
id = Number(params.slug);
@@ -67,6 +67,6 @@ export const actions = {
await addToAuditLog("punish_edit", JSON.stringify(auditEntry));
throw redirect(303, '/bans/' + id + '?result=edit')
redirect(303, '/bans/' + id + '?result=edit');
}
} satisfies Actions;
@@ -10,7 +10,7 @@ export const load = async ({ params, fetch, }) => {
if (resBan.status == 200) {
ban = await resBan.json();
} else {
throw error(404, "Punishment not found.")
error(404, "Punishment not found.");
}
return {
@@ -13,14 +13,14 @@ export const load = (async ({ locals, params }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
if (!sessionUser.admin) {
throw error(403, "Unauthorized.")
error(403, "Unauthorized.");
}
id = Number(params.slug);
@@ -55,6 +55,6 @@ export const actions = {
};
await queueTask("unpunish", JSON.stringify(data));
throw redirect(303, '/' + data.type.toLowerCase() + 's/' + id + '?result=revoke')
redirect(303, '/' + data.type.toLowerCase() + 's/' + id + '?result=revoke');
}
} satisfies Actions;
@@ -9,7 +9,7 @@ export const load = async ({ params, fetch, }) => {
if (resBan.status == 200) {
ban = await resBan.json();
} else {
throw error(404, "Punishment not found.");
error(404, "Punishment not found.");
}
const resOnline = await fetch("/backend/public/onlinestats");
@@ -18,7 +18,7 @@ export const load = async ({ params, fetch, }) => {
if (resOnline.status == 200) {
online = await resOnline.json();
} else {
throw error(500, "Couldn't get server status.")
error(500, "Couldn't get server status.");
}
return {
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
@@ -13,7 +13,7 @@ export const load = async ({ url, params, fetch }) => {
if (resReport.status == 200) {
report = await resReport.json();
} else {
throw error(404, "Report not found.")
error(404, "Report not found.");
}
return {
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
@@ -11,7 +11,7 @@ export const load = async ({ params, fetch, url }) => {
if (resMute.status == 200) {
mute = await resMute.json();
} else {
throw error(404, "Punishment not found.")
error(404, "Punishment not found.");
}
return {
@@ -13,14 +13,14 @@ export const load = (async ({ locals, params }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
if (!sessionUser.admin) {
throw error(403, "Unauthorized.")
error(403, "Unauthorized.");
}
id = Number(params.slug);
@@ -67,6 +67,6 @@ export const actions = {
await addToAuditLog("punish_edit", JSON.stringify(auditEntry));
throw redirect(303, '/mutes/' + id + '?result=edit')
redirect(303, '/mutes/' + id + '?result=edit');
}
} satisfies Actions;
@@ -9,7 +9,7 @@ export const load = async ({ params, fetch, }) => {
if (resMute.status == 200) {
mute = await resMute.json();
} else {
throw error(404, "Punishment not found.")
error(404, "Punishment not found.");
}
return {
@@ -13,14 +13,14 @@ export const load = (async ({ locals, params }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
if (!sessionUser.admin) {
throw error(403, "Unauthorized.")
error(403, "Unauthorized.");
}
id = Number(params.slug);
@@ -55,6 +55,6 @@ export const actions = {
};
await queueTask("unpunish", JSON.stringify(data));
throw redirect(303, '/' + data.type.toLowerCase() + 's/' + id + '?result=revoke')
redirect(303, '/' + data.type.toLowerCase() + 's/' + id + '?result=revoke');
}
} satisfies Actions;
@@ -9,7 +9,7 @@ export const load = async ({ params, fetch, }) => {
if (resMute.status == 200) {
mute = await resMute.json();
} else {
throw error(404, "Punishment not found.")
error(404, "Punishment not found.");
}
const resOnline = await fetch("/backend/public/onlinestats");
@@ -18,7 +18,7 @@ export const load = async ({ params, fetch, }) => {
if (resOnline.status == 200) {
online = await resOnline.json();
} else {
throw error(500, "Couldn't get server status.")
error(500, "Couldn't get server status.");
}
return {
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
@@ -5,7 +5,7 @@ export const load = async ({ params, fetch }) => {
let nameRres = await fetch("/backend/player/name/" + params.slug);
if (nameRres.status != 200) {
throw error(nameRres.status, "Player is not found.");
error(nameRres.status, "Player is not found.");
}
let name = await nameRres.text();
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
@@ -7,7 +7,7 @@ export const load = async ({ fetch, params }) => {
let nameRres = await fetch("/backend/player/name/" + staffUuid);
if (nameRres.status != 200) {
throw error(nameRres.status, "Player is not found.");
error(nameRres.status, "Player is not found.");
}
let staffName = await nameRres.text();
@@ -15,7 +15,7 @@ export const load = async ({ fetch, params }) => {
let punishments: PlayerPunishments;
if (resPunishments.status != 200) {
throw error(resPunishments.status, "Failed to get punsihments.");
error(resPunishments.status, "Failed to get punsihments.");
}
punishments = await resPunishments.json();
@@ -8,9 +8,9 @@ export const load = (async ({ locals }) => {
let check = await onPageLoadSecurityCheck(sessionUser, locals.userIp);
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
+4 -4
View File
@@ -10,7 +10,7 @@ export const load = async ({ fetch, parent }) => {
if (resUnassigned.status == 200) {
unassigned = await resUnassigned.json();
} else {
throw error(500, "Server failed to get reports.")
error(500, "Server failed to get reports.");
}
const resMy = await fetch("/backend/reports/by/" + sessionUser.uuid);
@@ -19,7 +19,7 @@ export const load = async ({ fetch, parent }) => {
if (resMy.status == 200) {
my = await resMy.json();
} else {
throw error(500, "Server failed to get reports.")
error(500, "Server failed to get reports.");
}
const resPending = await fetch("/backend/reports/pending");
@@ -28,7 +28,7 @@ export const load = async ({ fetch, parent }) => {
if (resPending.status == 200) {
pending = await resPending.json();
} else {
throw error(500, "Server failed to get reports.")
error(500, "Server failed to get reports.");
}
const resClosed = await fetch("/backend/reports/closed");
@@ -37,7 +37,7 @@ export const load = async ({ fetch, parent }) => {
if (resClosed.status == 200) {
closed = await resClosed.json();
} else {
throw error(500, "Server failed to get reports.")
error(500, "Server failed to get reports.");
}
return {
@@ -10,9 +10,9 @@ export const load = (async ({ locals, params }) => {
if (!check.allow) {
if (check.logout) {
throw redirect(303, '/login/out/silent');
redirect(303, '/login/out/silent');
} else {
throw redirect(303, '/login');
redirect(303, '/login');
}
}
@@ -23,7 +23,7 @@ export const load = (async ({ locals, params }) => {
export const actions = {
back: async (event) => {
throw redirect(303, '/reports/');
redirect(303, '/reports/');
},
claim: async (event) => {
@@ -37,7 +37,7 @@ export const actions = {
return fail(500, { success: false, message: "Server failed to claim report."})
}
throw redirect(303, '/reports/' + reportId + '?message=claimed');
redirect(303, '/reports/' + reportId + '?message=claimed');
},
accept: async (event) => {
@@ -53,7 +53,7 @@ export const actions = {
return fail(500, { success: false, closeMessage: "Server failed to close report."})
}
throw redirect(303, '/reports/' + reportId + '?message=closed');
redirect(303, '/reports/' + reportId + '?message=closed');
},
reject: async (event) => {
@@ -69,6 +69,6 @@ export const actions = {
return fail(500, { success: false, closeMessage: "Server failed to close report."})
}
throw redirect(303, '/reports/' + reportId + '?message=closed');
redirect(303, '/reports/' + reportId + '?message=closed');
}
}
@@ -11,7 +11,7 @@ export const load = async ({ url, params, fetch }) => {
if (resReport.status == 200) {
report = await resReport.json();
} else {
throw error(404, "Report not found.")
error(404, "Report not found.");
}
return {
@@ -11,7 +11,7 @@ export const load = (async ({ locals }) => {
const sessionUser: AuthResult = locals.user;
if (sessionUser) {
throw redirect(303, '/');
redirect(303, '/');
}
return {
@@ -75,13 +75,13 @@ export const actions = {
let newInfo: StaffIPInfo = { id: -1, uuid: userInfo.uuid, ip: event.getClientAddress(), initial: false, panel_acknowledged: true, panel_verified: false, game_verified: false };
await createIpEntry(newInfo);
throw redirect(303, "/login/verify?ingame=false");
redirect(303, "/login/verify?ingame=false");
}
if (!ipInfo.panel_verified) {
ipInfo.panel_acknowledged = true;
await updateIpEntry(ipInfo);
throw redirect(303, "/login/verify?ingame=true");
redirect(303, "/login/verify?ingame=true");
}
let token = createJWT(userInfo, ipInfo.ip);
@@ -97,6 +97,6 @@ export const actions = {
maxAge: 60 * 60 * 24
});
throw redirect(303, "/");
redirect(303, "/");
}
} satisfies Actions;
@@ -10,7 +10,7 @@ export const load = (async ({ locals }) => {
const sessionUser: AuthResult = locals.user;
if (sessionUser) {
throw redirect(303, '/');
redirect(303, '/');
}
return {
@@ -73,7 +73,7 @@ export const actions = {
ipInfo.panel_verified = true;
await updateIpEntry(ipInfo);
throw redirect(303, "/login?success=true");
redirect(303, "/login?success=true");
}
} satisfies Actions;
@@ -10,5 +10,5 @@ export const load = (async ({ cookies }) => {
maxAge: 0
});
throw redirect(302, "/login?success=out");
redirect(302, "/login?success=out");
}) satisfies PageServerLoad;
@@ -10,5 +10,5 @@ export const load = (async ({ cookies }) => {
maxAge: 0
});
throw redirect(302, "/login");
redirect(302, "/login");
}) satisfies PageServerLoad;
@@ -10,7 +10,7 @@ export const load = (async ({ locals }) => {
const sessionUser: AuthResult = locals.user;
if (sessionUser) {
throw redirect(303, '/');
redirect(303, '/');
}
return {
@@ -64,7 +64,7 @@ export const actions = {
ipInfo.panel_verified = true;
await updateIpEntry(ipInfo);
throw redirect(303, "/login?success=true");
redirect(303, "/login?success=true");
}
} satisfies Actions;
+1 -1
View File
@@ -1,5 +1,5 @@
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {