From 257252f228dc273bf24fd529fcb941d87c468b75 Mon Sep 17 00:00:00 2001 From: Evorp <3vorpgaming@gmail.com> Date: Thu, 21 Dec 2023 14:15:42 -0800 Subject: [PATCH] prettier/eslint conflict fix --- src/v2/controller/addon.controller.ts | 48 +++++++++---------- src/v2/interfaces/modpacks.ts | 2 +- src/v2/interfaces/mods.ts | 2 +- src/v2/interfaces/posts.ts | 2 +- .../repository/firestorm/path.repository.ts | 4 +- src/v2/repository/firestorm/use.repository.ts | 2 +- src/v2/service/texture.service.ts | 37 +++++++------- src/v2/service/use.service.ts | 16 ++++--- 8 files changed, 60 insertions(+), 53 deletions(-) diff --git a/src/v2/controller/addon.controller.ts b/src/v2/controller/addon.controller.ts index 9de85f7..4b865f5 100644 --- a/src/v2/controller/addon.controller.ts +++ b/src/v2/controller/addon.controller.ts @@ -36,40 +36,40 @@ export class AddonController extends Controller { private async getAddonProperty(id: number, property: AddonProperty): Promise { switch (property) { - case "files": - return (await this.service.getFiles(id)).map((f) => { - if ((f.use === "header" || f.use === "screenshot") && f.source.startsWith("/")) - f.source = process.env.DB_IMAGE_ROOT + f.source; - - if ( - f.use === "download" && - !f.source.startsWith("https://") && - !f.source.startsWith("http://") - ) - f.source = `http://${f.source}`; - - return f; - }); - - case "all": - default: - return this.service.getAll(id).then((addon: AddonAll) => { - addon.files = addon.files.map((f) => { + case "files": + return (await this.service.getFiles(id)).map((f) => { if ((f.use === "header" || f.use === "screenshot") && f.source.startsWith("/")) f.source = process.env.DB_IMAGE_ROOT + f.source; if ( f.use === "download" && - !f.source.startsWith("https://") && - !f.source.startsWith("http://") + !f.source.startsWith("https://") && + !f.source.startsWith("http://") ) f.source = `http://${f.source}`; return f; }); - return addon; - }); + case "all": + default: + return this.service.getAll(id).then((addon: AddonAll) => { + addon.files = addon.files.map((f) => { + if ((f.use === "header" || f.use === "screenshot") && f.source.startsWith("/")) + f.source = process.env.DB_IMAGE_ROOT + f.source; + + if ( + f.use === "download" && + !f.source.startsWith("https://") && + !f.source.startsWith("http://") + ) + f.source = `http://${f.source}`; + + return f; + }); + + return addon; + }); } } @@ -175,7 +175,7 @@ export class AddonController extends Controller { @Get("{id_or_slug}/{property}") public async getAddonPropertyById( @Path() id_or_slug: string, - property: AddonProperty, + property: AddonProperty, ): Promise { return this.service .getAddonFromSlugOrId(id_or_slug) diff --git a/src/v2/interfaces/modpacks.ts b/src/v2/interfaces/modpacks.ts index 4d9a01d..256fcce 100644 --- a/src/v2/interfaces/modpacks.ts +++ b/src/v2/interfaces/modpacks.ts @@ -13,7 +13,7 @@ export interface Modpack { export interface Modpacks extends Array {} -export interface FirestormModpack extends Modpack {}; +export interface FirestormModpack extends Modpack {} export interface ModpacksRepository { getRaw(): Promise>; diff --git a/src/v2/interfaces/mods.ts b/src/v2/interfaces/mods.ts index 31cc164..ec805ce 100644 --- a/src/v2/interfaces/mods.ts +++ b/src/v2/interfaces/mods.ts @@ -13,7 +13,7 @@ export interface Mod { export interface Mods extends Array {} -export interface FirestormMod extends Mod {}; +export interface FirestormMod extends Mod {} export interface ModsRepository { getRaw(): Promise>; diff --git a/src/v2/interfaces/posts.ts b/src/v2/interfaces/posts.ts index 5363af6..34aca3b 100644 --- a/src/v2/interfaces/posts.ts +++ b/src/v2/interfaces/posts.ts @@ -30,7 +30,7 @@ export interface WebsitePost extends CreateWebsitePost { id: string; } -export interface FirestormPost extends WebsitePost {}; +export interface FirestormPost extends WebsitePost {} export interface WebsitePostRepository { getRaw(): Promise>; diff --git a/src/v2/repository/firestorm/path.repository.ts b/src/v2/repository/firestorm/path.repository.ts index d315f10..0839beb 100644 --- a/src/v2/repository/firestorm/path.repository.ts +++ b/src/v2/repository/firestorm/path.repository.ts @@ -29,11 +29,11 @@ export default class PathFirestormRepository implements PathRepository { createPath(path: InputPath): Promise { // breaks without structuredClone, not sure why - return paths.add(structuredClone(path)).then((id) => ({ ...structuredClone(path), id }) ); + return paths.add(structuredClone(path)).then((id) => ({ ...structuredClone(path), id })); } createPathBulk(pathArray: InputPath[]): Promise { - return paths.addBulk(pathArray).then((ids) => paths.searchKeys(ids)) + return paths.addBulk(pathArray).then((ids) => paths.searchKeys(ids)); } removePathById(path_id: string): Promise { diff --git a/src/v2/repository/firestorm/use.repository.ts b/src/v2/repository/firestorm/use.repository.ts index 4c93388..51f2900 100644 --- a/src/v2/repository/firestorm/use.repository.ts +++ b/src/v2/repository/firestorm/use.repository.ts @@ -59,7 +59,7 @@ export default class UseFirestormRepository implements UseRepository { } setMultiple(useArray: Use[]): Promise { - const use_ids = useArray.map(u => u.id); + const use_ids = useArray.map((u) => u.id); return uses.setBulk(use_ids, useArray).then(() => uses.searchKeys(use_ids)); } diff --git a/src/v2/service/texture.service.ts b/src/v2/service/texture.service.ts index aadb3b0..2718939 100644 --- a/src/v2/service/texture.service.ts +++ b/src/v2/service/texture.service.ts @@ -97,28 +97,31 @@ export default class TextureService { const texture_id = created_texture.id; // create uses - const [use_ids, full_uses_to_create]: [string[], Use[]] = input.uses.reduce((acc,u,ui) => { - const use_id = String(texture_id) + String.fromCharCode("a".charCodeAt(0) + ui); - const use = { - name: u.name, - edition: u.edition, - texture: Number.parseInt(texture_id, 10), - id: use_id, - } - acc[0].push(use_id) - acc[1].push(use) - return acc - }, [[],[]]); + const [use_ids, full_uses_to_create]: [string[], Use[]] = input.uses.reduce( + (acc, u, ui) => { + const use_id = String(texture_id) + String.fromCharCode("a".charCodeAt(0) + ui); + const use = { + name: u.name, + edition: u.edition, + texture: Number.parseInt(texture_id, 10), + id: use_id, + }; + acc[0].push(use_id); + acc[1].push(use); + return acc; + }, + [[], []], + ); await this.useService.createMultipleUses(full_uses_to_create); // create paths const paths_to_add = input.uses.reduce((acc, u, ui) => { - const paths: InputPath[] = u.paths.map(p => ({ + const paths: InputPath[] = u.paths.map((p) => ({ ...p, - use: use_ids[ui] - })) - return [ ...acc, ...paths ] - }, [] as InputPath[]) + use: use_ids[ui], + })); + return [...acc, ...paths]; + }, [] as InputPath[]); await this.pathService.createMultiplePaths(paths_to_add); return created_texture; diff --git a/src/v2/service/use.service.ts b/src/v2/service/use.service.ts index 1ac85c1..77ebcb2 100644 --- a/src/v2/service/use.service.ts +++ b/src/v2/service/use.service.ts @@ -83,11 +83,15 @@ export default class UseService { } createMultipleUses(uses: Use[]): Promise { - return Promise.all(uses.map(u => new Promise((resolve, reject) => { - this.getUseByIdOrNameAndCatch(u.id) - .then(() => reject()) - .catch(() => resolve(undefined)) - }))) - .then(() => this.useRepo.setMultiple(uses)) + return Promise.all( + uses.map( + (u) => + new Promise((resolve, reject) => { + this.getUseByIdOrNameAndCatch(u.id) + .then(() => reject()) + .catch(() => resolve(undefined)); + }), + ), + ).then(() => this.useRepo.setMultiple(uses)); } }