chore: prettier pass

This commit is contained in:
Huskydog9988
2025-04-15 21:46:34 -04:00
parent d361e01eef
commit 87215c4a1e
62 changed files with 247 additions and 236 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ export default defineEventHandler(async (h3) => {
if (!allowed) throw createError({ statusCode: 403 });
const enabledMechanisms: AuthMec[] = await applicationSettings.get(
"enabledAuthencationMechanisms"
"enabledAuthencationMechanisms",
);
return enabledMechanisms;
+1 -3
View File
@@ -3,9 +3,7 @@ import prisma from "~/server/internal/db/database";
import { handleFileUpload } from "~/server/internal/utils/handlefileupload";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"game:image:new",
]);
const allowed = await aclManager.allowSystemACL(h3, ["game:image:new"]);
if (!allowed) throw createError({ statusCode: 403 });
const form = await readMultipartFormData(h3);
+1 -3
View File
@@ -3,9 +3,7 @@ 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:read",
]);
const allowed = await aclManager.allowSystemACL(h3, ["game:read"]);
if (!allowed) throw createError({ statusCode: 403 });
const query = getQuery(h3);
+1 -3
View File
@@ -2,9 +2,7 @@ import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"game:update",
]);
const allowed = await aclManager.allowSystemACL(h3, ["game:update"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readBody(h3);
+1 -3
View File
@@ -3,9 +3,7 @@ import prisma from "~/server/internal/db/database";
import { handleFileUpload } from "~/server/internal/utils/handlefileupload";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"game:update",
]);
const allowed = await aclManager.allowSystemACL(h3, ["game:update"]);
if (!allowed) throw createError({ statusCode: 403 });
const form = await readMultipartFormData(h3);
@@ -2,9 +2,7 @@ import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"game:version:delete",
]);
const allowed = await aclManager.allowSystemACL(h3, ["game:version:delete"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readBody(h3);
@@ -2,9 +2,7 @@ import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"game:version:update",
]);
const allowed = await aclManager.allowSystemACL(h3, ["game:version:update"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readBody(h3);
@@ -30,13 +28,13 @@ export default defineEventHandler(async (h3) => {
versionIndex: versionIndex,
},
select: {
versionIndex: true,
versionName: true,
platform: true,
delta: true,
}
})
)
versionIndex: true,
versionName: true,
platform: true,
delta: true,
},
}),
),
);
return newVersions;
+1 -3
View File
@@ -2,9 +2,7 @@ import aclManager from "~/server/internal/acls";
import libraryManager from "~/server/internal/library";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"import:game:read",
]);
const allowed = await aclManager.allowSystemACL(h3, ["import:game:read"]);
if (!allowed) throw createError({ statusCode: 403 });
const unimportedGames = await libraryManager.fetchAllUnimportedGames();
@@ -7,9 +7,7 @@ import type {
} from "~/server/internal/metadata/types";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"import:game:new",
]);
const allowed = await aclManager.allowSystemACL(h3, ["import:game:new"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readBody(h3);
@@ -30,7 +28,6 @@ export default defineEventHandler(async (h3) => {
statusMessage: "Invalid unimported game path",
});
if (!metadata || !metadata.id || !metadata.sourceId) {
console.log(metadata);
return await metadataHandler.createGameWithoutMetadata(path);
@@ -2,9 +2,7 @@ import aclManager from "~/server/internal/acls";
import metadataHandler from "~/server/internal/metadata";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"import:game:read",
]);
const allowed = await aclManager.allowSystemACL(h3, ["import:game:read"]);
if (!allowed) throw createError({ statusCode: 403 });
const query = getQuery(h3);
@@ -2,9 +2,7 @@ import aclManager from "~/server/internal/acls";
import libraryManager from "~/server/internal/library";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"import:version:read",
]);
const allowed = await aclManager.allowSystemACL(h3, ["import:version:read"]);
if (!allowed) throw createError({ statusCode: 403 });
const query = await getQuery(h3);
@@ -15,9 +13,8 @@ export default defineEventHandler(async (h3) => {
statusMessage: "Missing id in request params",
});
const unimportedVersions = await libraryManager.fetchUnimportedVersions(
gameId
);
const unimportedVersions =
await libraryManager.fetchUnimportedVersions(gameId);
if (!unimportedVersions)
throw createError({ statusCode: 400, statusMessage: "Invalid game ID" });
@@ -4,9 +4,7 @@ import libraryManager from "~/server/internal/library";
import { parsePlatform } from "~/server/internal/utils/parseplatform";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"import:version:new",
]);
const allowed = await aclManager.allowSystemACL(h3, ["import:version:new"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readBody(h3);
@@ -2,9 +2,7 @@ import aclManager from "~/server/internal/acls";
import libraryManager from "~/server/internal/library";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"import:version:read",
]);
const allowed = await aclManager.allowSystemACL(h3, ["import:version:read"]);
if (!allowed) throw createError({ statusCode: 403 });
const query = await getQuery(h3);
@@ -18,7 +16,7 @@ export default defineEventHandler(async (h3) => {
const preload = await libraryManager.fetchUnimportedVersionInformation(
gameId,
versionName
versionName,
);
if (!preload)
throw createError({
@@ -19,4 +19,4 @@ export default defineEventHandler(async (h3) => {
await newsManager.delete(id);
return { success: true };
});
});
+1 -2
View File
@@ -27,8 +27,7 @@ export default defineEventHandler(async (h3) => {
take: parseInt(query.limit as string),
skip: parseInt(query.skip as string),
orderBy: orderBy,
...(tags && { tags: tags
.map((e) => e.toString()) }),
...(tags && { tags: tags.map((e) => e.toString()) }),
search: query.search as string,
};
+3 -3
View File
@@ -13,9 +13,9 @@ export default defineEventHandler(async (h3) => {
authMecs: {
select: {
mec: true,
}
}
}
},
},
},
});
return users;
+1 -1
View File
@@ -31,7 +31,7 @@ export default defineEventHandler(async (h3) => {
const certificateAuthority = useCertificateAuthority();
const bundle = await certificateAuthority.generateClientCertificate(
clientId,
metadata.data.name
metadata.data.name,
);
const client = await clientHandler.finialiseClient(clientId);
@@ -1,5 +1,4 @@
import type {
InternalClientCapability} from "~/server/internal/clients/capabilities";
import type { InternalClientCapability } from "~/server/internal/clients/capabilities";
import capabilityManager, {
validCapabilities,
} from "~/server/internal/clients/capabilities";
@@ -34,7 +33,7 @@ export default defineClientEventHandler(
const isValid = await capabilityManager.validateCapabilityConfiguration(
capability,
configuration
configuration,
);
if (!isValid)
throw createError({
@@ -45,7 +44,7 @@ export default defineClientEventHandler(
await capabilityManager.upsertClientCapability(
capability,
configuration,
clientId
clientId,
);
const client = await fetchClient();
@@ -59,5 +58,5 @@ export default defineClientEventHandler(
});
return {};
}
},
);
@@ -49,5 +49,5 @@ export default defineClientEventHandler(
});
if (!save)
throw createError({ statusCode: 404, statusMessage: "Save not found" });
}
},
);
@@ -51,5 +51,5 @@ export default defineClientEventHandler(
throw createError({ statusCode: 404, statusMessage: "Save not found" });
return save;
}
},
);
@@ -44,9 +44,9 @@ export default defineClientEventHandler(
user.id,
slotIndex,
h3.node.req,
client.id
client.id,
);
return;
}
},
);
@@ -33,5 +33,5 @@ export default defineClientEventHandler(
});
return saves;
}
},
);
@@ -58,5 +58,5 @@ export default defineClientEventHandler(
});
return newSlot;
}
},
);
+1 -1
View File
@@ -19,5 +19,5 @@ export default defineClientEventHandler(
});
return saves;
}
},
);
+1 -1
View File
@@ -27,5 +27,5 @@ export default defineClientEventHandler(
});
return token.token;
}
},
);
@@ -23,7 +23,7 @@ export default defineEventHandler(async (h3) => {
const successful = await userLibraryManager.collectionRemove(
gameId,
id,
userId
userId,
);
if (!successful)
throw createError({
+1 -1
View File
@@ -7,7 +7,7 @@ export default defineEventHandler(async (h3) => {
throw createError({
statusCode: 403,
});
const collections = await userLibraryManager.fetchCollections(userId);
return collections;
});
-2
View File
@@ -16,7 +16,6 @@ export default defineEventHandler(async (h3) => {
statusCode: 400,
message: "Missing news ID",
});
const news = await newsManager.fetchById(id);
if (!news)
@@ -25,6 +24,5 @@ export default defineEventHandler(async (h3) => {
message: "News article not found",
});
return news;
});
+1 -1
View File
@@ -9,7 +9,7 @@ export default defineEventHandler(async (h3) => {
const hasSystemPerms = await aclManager.allowSystemACL(h3, [
"notifications:mark",
]);
if(hasSystemPerms){
if (hasSystemPerms) {
userIds.push("system");
}
+1 -1
View File
@@ -30,7 +30,7 @@ export default defineEventHandler(async (h3) => {
setHeader(
h3,
"Cache-Control",
"private, max-age=31536000, s-maxage=31536000, immutable"
"private, max-age=31536000, s-maxage=31536000, immutable",
);
return object.data;
});
+1 -1
View File
@@ -18,7 +18,7 @@ export default defineEventHandler(async (h3) => {
const result = await objectHandler.writeWithPermissions(
id,
async () => buffer,
userId
userId,
);
return { success: result };
});
+1 -2
View File
@@ -10,7 +10,6 @@ These use public HTTPS certificate, and while are authenticated, are 'public' in
Drop clients use P2P mTLS aided by the P2P co-ordinator to transfer chunks between themselves. This happens over HTTP.
## Private mTLS Wireguard tunnels
Drop clients can establish P2P Wireguard
Drop clients can establish P2P Wireguard
+4 -3
View File
@@ -38,7 +38,8 @@ export const userACLDescriptions: ObjectFromList<typeof userACLs> = {
};
export const systemACLDescriptions: ObjectFromList<typeof systemACLs> = {
"auth:read": "Fetch the list of enabled authentication mechanisms configured.",
"auth:read":
"Fetch the list of enabled authentication mechanisms configured.",
"auth:simple:invitation:read": "Fetch simple auth invitations.",
"auth:simple:invitation:new": "Create new simple auth invitations.",
"auth:simple:invitation:delete": "Delete a simple auth invitation.",
@@ -66,8 +67,8 @@ export const systemACLDescriptions: ObjectFromList<typeof systemACLs> = {
"import:game:new": "Import a game.",
"user:read": "Fetch any user's information.",
"news:read": "Read news articles.",
"news:create": "Create a new news article.",
"news:delete": "Delete a news article."
"news:delete": "Delete a news article.",
};
@@ -1,4 +1,4 @@
import type { ApplicationSettings} from "@prisma/client";
import type { ApplicationSettings } from "@prisma/client";
import { AuthMec } from "@prisma/client";
import prisma from "../db/database";
@@ -24,7 +24,7 @@ class ApplicationConfiguration {
private async init() {
if (this.currentApplicationSettings === undefined) {
const applicationSettingsCount = await prisma.applicationSettings.count(
{}
{},
);
if (applicationSettingsCount > 0) {
await applicationSettings.pullConfiguration();
@@ -60,7 +60,7 @@ class ApplicationConfiguration {
async set<T extends keyof ApplicationSettings>(
key: T,
value: ApplicationSettings[T]
value: ApplicationSettings[T],
) {
await this.init();
if (!this.currentApplicationSettings)
@@ -73,7 +73,9 @@ class ApplicationConfiguration {
}
}
async get<T extends keyof ApplicationSettings>(key: T): Promise<ApplicationSettings[T]> {
async get<T extends keyof ApplicationSettings>(
key: T,
): Promise<ApplicationSettings[T]> {
await this.init();
if (!this.currentApplicationSettings)
throw new Error("Somehow, failed to initialise application settings");
+6 -6
View File
@@ -1,15 +1,15 @@
import { PrismaClient } from '@prisma/client'
import { PrismaClient } from "@prisma/client";
const prismaClientSingleton = () => {
return new PrismaClient({});
}
return new PrismaClient({});
};
declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();
export default prisma;
if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
+1 -1
View File
@@ -8,4 +8,4 @@ The game name is only used for initial matching, and doesn't affect actual metad
## /{game name}/{version name}
The version name can be anything. Versions have to manually imported within the web UI. There, you can change the order of the updates and mark them as deltas. Delta updates apply files over the previous versions.
The version name can be anything. Versions have to manually imported within the web UI. There, you can change the order of the updates and mark them as deltas. Delta updates apply files over the previous versions.
+7 -7
View File
@@ -1,6 +1,6 @@
import type { Developer, Publisher } from "@prisma/client";
import { MetadataSource } from "@prisma/client";
import type { MetadataProvider} from ".";
import type { MetadataProvider } from ".";
import { MissingMetadataProviderConfig } from ".";
import type {
GameMetadataSearchResult,
@@ -87,7 +87,7 @@ export class GiantBombProvider implements MetadataProvider {
if (!apikey)
throw new MissingMetadataProviderConfig(
"GIANT_BOMB_API_KEY",
this.name()
this.name(),
);
this.apikey = apikey;
@@ -105,7 +105,7 @@ export class GiantBombProvider implements MetadataProvider {
resource: string,
url: string,
query: { [key: string]: string },
options?: AxiosRequestConfig
options?: AxiosRequestConfig,
) {
const queryString = new URLSearchParams({
...query,
@@ -120,7 +120,7 @@ export class GiantBombProvider implements MetadataProvider {
baseURL: "",
};
const response = await axios.request<GiantBombResponseType<T>>(
Object.assign({}, options, overlay)
Object.assign({}, options, overlay),
);
return response;
}
@@ -198,7 +198,7 @@ export class GiantBombProvider implements MetadataProvider {
: DateTime.fromISO(
`${gameData.expected_release_year ?? new Date().getFullYear()}-${
gameData.expected_release_month ?? 1
}-${gameData.expected_release_day ?? 1}`
}-${gameData.expected_release_day ?? 1}`,
).toJSDate();
const metadata: GameMetadata = {
@@ -229,7 +229,7 @@ export class GiantBombProvider implements MetadataProvider {
const results = await this.request<Array<CompanySearchResult>>(
"search",
"",
{ query, resources: "company" }
{ query, resources: "company" },
);
// Find the right entry
@@ -256,7 +256,7 @@ export class GiantBombProvider implements MetadataProvider {
return metadata;
}
async fetchDeveloper(
params: _FetchDeveloperMetadataParams
params: _FetchDeveloperMetadataParams,
): Promise<DeveloperMetadata> {
return await this.fetchPublisher(params);
}
+11 -11
View File
@@ -1,6 +1,6 @@
import type { Developer, Publisher } from "@prisma/client";
import { MetadataSource } from "@prisma/client";
import type { MetadataProvider} from ".";
import type { MetadataProvider } from ".";
import { MissingMetadataProviderConfig } from ".";
import type {
GameMetadataSearchResult,
@@ -144,7 +144,7 @@ export class IGDBProvider implements MetadataProvider {
if (!client_secret)
throw new MissingMetadataProviderConfig(
"IGDB_CLIENT_SECRET",
this.name()
this.name(),
);
this.clientId = client_id;
@@ -188,14 +188,14 @@ export class IGDBProvider implements MetadataProvider {
private async request<T extends object>(
resource: string,
body: string,
options?: AxiosRequestConfig
options?: AxiosRequestConfig,
) {
await this.refreshCredentials();
// prevent calling api before auth is complete
if (this.accessToken.length <= 0)
throw new Error(
"IGDB either failed to authenticate, or has not done so yet"
"IGDB either failed to authenticate, or has not done so yet",
);
const finalURL = `https://api.igdb.com/v4/${resource}`;
@@ -213,7 +213,7 @@ export class IGDBProvider implements MetadataProvider {
},
};
const response = await axios.request<T[] | IGDBErrorResponse[]>(
Object.assign({}, options, overlay)
Object.assign({}, options, overlay),
);
if (response.status !== 200) {
@@ -224,7 +224,7 @@ export class IGDBProvider implements MetadataProvider {
});
throw new Error(
`Error in igdb \nStatus Code: ${response.status} \nCause: ${cause}`
`Error in igdb \nStatus Code: ${response.status} \nCause: ${cause}`,
);
}
@@ -323,7 +323,7 @@ export class IGDBProvider implements MetadataProvider {
const involved_company_response =
await this.request<IGDBInvolvedCompany>(
"involved_companies",
`where id = ${involvedCompany}; fields *;`
`where id = ${involvedCompany}; fields *;`,
);
for (const foundInvolved of involved_company_response) {
// now we need to get the actual company so we can get the name
@@ -348,7 +348,7 @@ export class IGDBProvider implements MetadataProvider {
shortDescription: this.trimMessage(response[i].summary, 280),
description: response[i].summary,
released: DateTime.fromSeconds(
response[i].first_release_date
response[i].first_release_date,
).toJSDate(),
reviewCount: response[i]?.total_rating_count ?? 0,
@@ -372,7 +372,7 @@ export class IGDBProvider implements MetadataProvider {
}: _FetchPublisherMetadataParams): Promise<PublisherMetadata> {
const response = await this.request<IGDBCompany>(
"companies",
`where name = "${query}"; fields *; limit 1;`
`where name = "${query}"; fields *; limit 1;`,
);
for (const company of response) {
@@ -382,7 +382,7 @@ export class IGDBProvider implements MetadataProvider {
for (const companySite of company.websites) {
const companySiteRes = await this.request<IGDBCompanyWebsite>(
"company_websites",
`where id = ${companySite}; fields *;`
`where id = ${companySite}; fields *;`,
);
for (const site of companySiteRes) {
@@ -406,7 +406,7 @@ export class IGDBProvider implements MetadataProvider {
throw new Error("No results found");
}
async fetchDeveloper(
params: _FetchDeveloperMetadataParams
params: _FetchDeveloperMetadataParams,
): Promise<DeveloperMetadata> {
return await this.fetchPublisher(params);
}
+4 -2
View File
@@ -5,8 +5,10 @@ import { ObjectTransactionalHandler } from "../objects/transactional";
export async function handleFileUpload(
h3: H3Event<EventHandlerRequest>,
metadata: { [key: string]: string },
permissions: Array<string>
): Promise<[string | undefined, {[key: string]: string}, Pull, Dump] | undefined> {
permissions: Array<string>,
): Promise<
[string | undefined, { [key: string]: string }, Pull, Dump] | undefined
> {
const formData = await readMultipartFormData(h3);
if (!formData) return undefined;
const transactionalHandler = new ObjectTransactionalHandler();