fix: more eslint stuff
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import libraryManager from "~/server/internal/library";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, [
|
||||
"game:delete",
|
||||
]);
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["game:delete"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const query = getQuery(h3);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineEventHandler, createError, readBody } from "h3";
|
||||
import { defineEventHandler, createError } from "h3";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import newsManager from "~/server/internal/news";
|
||||
import { handleFileUpload } from "~/server/internal/utils/handlefileupload";
|
||||
@@ -21,7 +21,7 @@ export default defineEventHandler(async (h3) => {
|
||||
statusMessage: "Failed to upload file",
|
||||
});
|
||||
|
||||
const [imageId, options, pull, dump] = uploadResult;
|
||||
const [imageId, options, pull, _dump] = uploadResult;
|
||||
|
||||
const title = options.title;
|
||||
const description = options.description;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AuthMec, Invitation } from "@prisma/client";
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { createHashArgon2 } from "~/server/internal/security/simple";
|
||||
import * as jdenticon from "jdenticon";
|
||||
@@ -63,7 +63,7 @@ export default defineEventHandler(async (h3) => {
|
||||
profilePictureId,
|
||||
async () => jdenticon.toPng(user.username, 256),
|
||||
{},
|
||||
[`internal:read`, `${userId}:read`]
|
||||
[`internal:read`, `${userId}:read`],
|
||||
);
|
||||
const [linkMec] = await prisma.$transaction([
|
||||
prisma.linkedAuthMec.create({
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
export default defineEventHandler((h3) => {
|
||||
|
||||
})
|
||||
export default defineEventHandler((_h3) => {});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
@@ -33,7 +32,7 @@ export default defineEventHandler(async (h3) => {
|
||||
const versionDir = path.join(
|
||||
libraryManager.fetchLibraryPath(),
|
||||
game.libraryBasePath,
|
||||
versionName
|
||||
versionName,
|
||||
);
|
||||
if (!fs.existsSync(versionDir))
|
||||
throw createError({
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
@@ -20,7 +19,7 @@ export default defineClientEventHandler(async (h3, { fetchUser }) => {
|
||||
const successful = await userLibraryManager.collectionRemove(
|
||||
gameId,
|
||||
id,
|
||||
user.id
|
||||
user.id,
|
||||
);
|
||||
if (!successful)
|
||||
throw createError({
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
@@ -12,6 +11,9 @@ export default defineClientEventHandler(async (h3, { fetchUser }) => {
|
||||
throw createError({ statusCode: 400, statusMessage: "Requires name" });
|
||||
|
||||
// Create the collection using the manager
|
||||
const newCollection = await userLibraryManager.collectionCreate(name, user.id);
|
||||
const newCollection = await userLibraryManager.collectionCreate(
|
||||
name,
|
||||
user.id,
|
||||
);
|
||||
return newCollection;
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { DropManifest } from "~/server/internal/downloads/manifest";
|
||||
|
||||
export default defineClientEventHandler(async (h3, {}) => {
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
const query = getQuery(h3);
|
||||
const id = query.id?.toString();
|
||||
if (!id)
|
||||
@@ -23,9 +22,9 @@ export default defineClientEventHandler(async (h3, {}) => {
|
||||
const mappedVersions = versions
|
||||
.map((version) => {
|
||||
if (!version.dropletManifest) return undefined;
|
||||
|
||||
|
||||
const newVersion = { ...version, dropletManifest: undefined };
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error idk why we delete an undefined object
|
||||
delete newVersion.dropletManifest;
|
||||
return {
|
||||
...newVersion,
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import { ClientCapabilities } from "@prisma/client";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import { applicationSettings } from "~/server/internal/config/application-configuration";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineClientEventHandler(
|
||||
async (h3, { fetchClient, fetchUser }) => {
|
||||
const client = await fetchClient();
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
});
|
||||
export default defineClientEventHandler(async (_h3, { fetchClient }) => {
|
||||
const client = await fetchClient();
|
||||
if (!client.capabilities.includes(ClientCapabilities.CloudSaves))
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Capability not allowed.",
|
||||
});
|
||||
|
||||
const slotLimit = await applicationSettings.get("saveSlotCountLimit");
|
||||
const sizeLimit = await applicationSettings.get("saveSlotSizeLimit");
|
||||
const history = await applicationSettings.get("saveSlotHistoryLimit");
|
||||
return { slotLimit, sizeLimit, history };
|
||||
}
|
||||
);
|
||||
const slotLimit = await applicationSettings.get("saveSlotCountLimit");
|
||||
const sizeLimit = await applicationSettings.get("saveSlotSizeLimit");
|
||||
const history = await applicationSettings.get("saveSlotHistoryLimit");
|
||||
return { slotLimit, sizeLimit, history };
|
||||
});
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import userLibraryManager from "~/server/internal/userlibrary";
|
||||
|
||||
export default defineClientEventHandler(async (h3, { fetchUser }) => {
|
||||
export default defineClientEventHandler(async (_h3, { fetchUser }) => {
|
||||
const user = await fetchUser();
|
||||
const library = await userLibraryManager.fetchLibrary(user.id);
|
||||
return library.entries.map((e) => e.game);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default defineEventHandler((h3) => {
|
||||
export default defineEventHandler((_h3) => {
|
||||
return {
|
||||
appName: "Drop",
|
||||
};
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import notificationSystem from "~/server/internal/notifications";
|
||||
import session from "~/server/internal/session";
|
||||
import { parse as parseCookies } from "cookie-es";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
|
||||
// TODO add web socket sessions for horizontal scaling
|
||||
// Peer ID to user ID
|
||||
const socketSessions: { [key: string]: string } = {};
|
||||
const socketSessions = new Map<string, string>();
|
||||
|
||||
export default defineWebSocketHandler({
|
||||
async open(peer) {
|
||||
@@ -25,7 +23,7 @@ export default defineWebSocketHandler({
|
||||
userIds.push("system");
|
||||
}
|
||||
|
||||
socketSessions[peer.id] = userId;
|
||||
socketSessions.set(peer.id, userId);
|
||||
|
||||
for (const listenUserId of userIds) {
|
||||
notificationSystem.listen(listenUserId, peer.id, (notification) => {
|
||||
@@ -33,8 +31,8 @@ export default defineWebSocketHandler({
|
||||
});
|
||||
}
|
||||
},
|
||||
async close(peer, details) {
|
||||
const userId = socketSessions[peer.id];
|
||||
async close(peer, _details) {
|
||||
const userId = socketSessions.get(peer.id);
|
||||
if (!userId) {
|
||||
console.log(`skipping websocket close for ${peer.id}`);
|
||||
return;
|
||||
@@ -42,6 +40,6 @@ export default defineWebSocketHandler({
|
||||
|
||||
notificationSystem.unlisten(userId, peer.id);
|
||||
notificationSystem.unlisten("system", peer.id); // In case we were listening as 'system'
|
||||
delete socketSessions[peer.id];
|
||||
socketSessions.delete(peer.id);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import session from "~/server/internal/session";
|
||||
import taskHandler, { TaskMessage } from "~/server/internal/tasks";
|
||||
import { parse as parseCookies } from "cookie-es";
|
||||
import taskHandler from "~/server/internal/tasks";
|
||||
import type { MinimumRequestObject } from "~/server/h3";
|
||||
|
||||
// TODO add web socket sessions for horizontal scaling
|
||||
// ID to admin
|
||||
const socketHeaders: { [key: string]: MinimumRequestObject } = {};
|
||||
const socketHeaders = new Map<string, MinimumRequestObject>();
|
||||
|
||||
export default defineWebSocketHandler({
|
||||
async open(peer) {
|
||||
@@ -15,25 +13,26 @@ export default defineWebSocketHandler({
|
||||
return;
|
||||
}
|
||||
|
||||
socketHeaders[peer.id] = {
|
||||
socketHeaders.set(peer.id, {
|
||||
headers: request.headers ?? new Headers(),
|
||||
};
|
||||
});
|
||||
peer.send(`connect`);
|
||||
},
|
||||
message(peer, message) {
|
||||
if (!peer.id) return;
|
||||
if (socketHeaders[peer.id] === undefined) return;
|
||||
const headers = socketHeaders.get(peer.id);
|
||||
if (headers === undefined) return;
|
||||
const text = message.text();
|
||||
if (text.startsWith("connect/")) {
|
||||
const id = text.substring("connect/".length);
|
||||
taskHandler.connect(peer.id, id, peer, socketHeaders[peer.id]);
|
||||
taskHandler.connect(peer.id, id, peer, headers);
|
||||
return;
|
||||
}
|
||||
},
|
||||
close(peer, details) {
|
||||
close(peer, _details) {
|
||||
if (!peer.id) return;
|
||||
if (socketHeaders[peer.id] === undefined) return;
|
||||
delete socketHeaders[peer.id];
|
||||
if (!socketHeaders.has(peer.id)) return;
|
||||
socketHeaders.delete(peer.id);
|
||||
|
||||
taskHandler.disconnectAll(peer.id);
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import clientHandler from "~/server/internal/clients/handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserIdACL(h3, ["clients:revoke"]);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { APITokenMode } from "@prisma/client";
|
||||
import aclManager, { userACLs } from "~/server/internal/acls";
|
||||
import { userACLDescriptions } from "~/server/internal/acls/descriptions";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
@@ -25,17 +24,23 @@ export default defineEventHandler(async (h3) => {
|
||||
statusMessage: "Token requires more than zero ACLs",
|
||||
});
|
||||
|
||||
const invalidACLs = acls.filter((e) => userACLs.findIndex((v) => e == v) == -1);
|
||||
if(invalidACLs.length > 0) throw createError({statusCode: 400, statusMessage: `Invalid ACLs: ${invalidACLs.join(", ")}`});
|
||||
const invalidACLs = acls.filter(
|
||||
(e) => userACLs.findIndex((v) => e == v) == -1,
|
||||
);
|
||||
if (invalidACLs.length > 0)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: `Invalid ACLs: ${invalidACLs.join(", ")}`,
|
||||
});
|
||||
|
||||
const token = await prisma.aPIToken.create({
|
||||
data: {
|
||||
mode: APITokenMode.User,
|
||||
name: name,
|
||||
userId: userId,
|
||||
acls: acls,
|
||||
}
|
||||
})
|
||||
|
||||
return token;
|
||||
const token = await prisma.aPIToken.create({
|
||||
data: {
|
||||
mode: APITokenMode.User,
|
||||
name: name,
|
||||
userId: userId,
|
||||
acls: acls,
|
||||
},
|
||||
});
|
||||
|
||||
return token;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user