mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 08:41:15 +10:00
feat: partial user platform support + statusMessage -> message
This commit is contained in:
@ -8,27 +8,27 @@ export default defineClientEventHandler(
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
message: "Capability not allowed.",
|
||||
});
|
||||
const user = await fetchUser();
|
||||
const gameId = getRouterParam(h3, "gameid");
|
||||
if (!gameId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No gameID in route params",
|
||||
message: "No gameID in route params",
|
||||
});
|
||||
|
||||
const slotIndexString = getRouterParam(h3, "slotindex");
|
||||
if (!slotIndexString)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No slotIndex in route params",
|
||||
message: "No slotIndex in route params",
|
||||
});
|
||||
const slotIndex = parseInt(slotIndexString);
|
||||
if (Number.isNaN(slotIndex))
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid slotIndex",
|
||||
message: "Invalid slotIndex",
|
||||
});
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
@ -36,7 +36,7 @@ export default defineClientEventHandler(
|
||||
select: { id: true },
|
||||
});
|
||||
if (!game)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
|
||||
throw createError({ statusCode: 400, message: "Invalid game ID" });
|
||||
|
||||
const save = await prisma.saveSlot.delete({
|
||||
where: {
|
||||
@ -48,6 +48,6 @@ export default defineClientEventHandler(
|
||||
},
|
||||
});
|
||||
if (!save)
|
||||
throw createError({ statusCode: 404, statusMessage: "Save not found" });
|
||||
throw createError({ statusCode: 404, message: "Save not found" });
|
||||
},
|
||||
);
|
||||
|
||||
@ -8,27 +8,27 @@ export default defineClientEventHandler(
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
message: "Capability not allowed.",
|
||||
});
|
||||
const user = await fetchUser();
|
||||
const gameId = getRouterParam(h3, "gameid");
|
||||
if (!gameId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No gameID in route params",
|
||||
message: "No gameID in route params",
|
||||
});
|
||||
|
||||
const slotIndexString = getRouterParam(h3, "slotindex");
|
||||
if (!slotIndexString)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No slotIndex in route params",
|
||||
message: "No slotIndex in route params",
|
||||
});
|
||||
const slotIndex = parseInt(slotIndexString);
|
||||
if (Number.isNaN(slotIndex))
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid slotIndex",
|
||||
message: "Invalid slotIndex",
|
||||
});
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
@ -36,7 +36,7 @@ export default defineClientEventHandler(
|
||||
select: { id: true },
|
||||
});
|
||||
if (!game)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
|
||||
throw createError({ statusCode: 400, message: "Invalid game ID" });
|
||||
|
||||
const save = await prisma.saveSlot.findUnique({
|
||||
where: {
|
||||
@ -48,7 +48,7 @@ export default defineClientEventHandler(
|
||||
},
|
||||
});
|
||||
if (!save)
|
||||
throw createError({ statusCode: 404, statusMessage: "Save not found" });
|
||||
throw createError({ statusCode: 404, message: "Save not found" });
|
||||
|
||||
return save;
|
||||
},
|
||||
|
||||
@ -9,27 +9,27 @@ export default defineClientEventHandler(
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
message: "Capability not allowed.",
|
||||
});
|
||||
const user = await fetchUser();
|
||||
const gameId = getRouterParam(h3, "gameid");
|
||||
if (!gameId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No gameID in route params",
|
||||
message: "No gameID in route params",
|
||||
});
|
||||
|
||||
const slotIndexString = getRouterParam(h3, "slotindex");
|
||||
if (!slotIndexString)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No slotIndex in route params",
|
||||
message: "No slotIndex in route params",
|
||||
});
|
||||
const slotIndex = parseInt(slotIndexString);
|
||||
if (Number.isNaN(slotIndex))
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid slotIndex",
|
||||
message: "Invalid slotIndex",
|
||||
});
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
@ -37,7 +37,7 @@ export default defineClientEventHandler(
|
||||
select: { id: true },
|
||||
});
|
||||
if (!game)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
|
||||
throw createError({ statusCode: 400, message: "Invalid game ID" });
|
||||
|
||||
await saveManager.pushSave(
|
||||
gameId,
|
||||
|
||||
@ -8,14 +8,14 @@ export default defineClientEventHandler(
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
message: "Capability not allowed.",
|
||||
});
|
||||
const user = await fetchUser();
|
||||
const gameId = getRouterParam(h3, "gameid");
|
||||
if (!gameId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No gameID in route params",
|
||||
message: "No gameID in route params",
|
||||
});
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
@ -23,7 +23,7 @@ export default defineClientEventHandler(
|
||||
select: { id: true },
|
||||
});
|
||||
if (!game)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
|
||||
throw createError({ statusCode: 400, message: "Invalid game ID" });
|
||||
|
||||
const saves = await prisma.saveSlot.findMany({
|
||||
where: {
|
||||
|
||||
@ -9,14 +9,14 @@ export default defineClientEventHandler(
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
message: "Capability not allowed.",
|
||||
});
|
||||
const user = await fetchUser();
|
||||
const gameId = getRouterParam(h3, "gameid");
|
||||
if (!gameId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "No gameID in route params",
|
||||
message: "No gameID in route params",
|
||||
});
|
||||
|
||||
const game = await prisma.game.findUnique({
|
||||
@ -24,7 +24,7 @@ export default defineClientEventHandler(
|
||||
select: { id: true },
|
||||
});
|
||||
if (!game)
|
||||
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
|
||||
throw createError({ statusCode: 400, message: "Invalid game ID" });
|
||||
|
||||
const saves = await prisma.saveSlot.findMany({
|
||||
where: {
|
||||
@ -40,7 +40,7 @@ export default defineClientEventHandler(
|
||||
if (saves.length + 1 > limit)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Out of save slots",
|
||||
message: "Out of save slots",
|
||||
});
|
||||
|
||||
let firstIndex = 0;
|
||||
|
||||
@ -8,7 +8,7 @@ export default defineClientEventHandler(
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
message: "Capability not allowed.",
|
||||
});
|
||||
const user = await fetchUser();
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ export default defineClientEventHandler(async (_h3, { fetchClient }) => {
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
message: "Capability not allowed.",
|
||||
});
|
||||
|
||||
const slotLimit = await applicationSettings.get("saveSlotCountLimit");
|
||||
|
||||
Reference in New Issue
Block a user