Skip to content

Commit

Permalink
update firestorm
Browse files Browse the repository at this point in the history
also other dependencies
  • Loading branch information
3vorp committed Feb 23, 2024
1 parent 066ae40 commit b45f1f1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 59 deletions.
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/body-parser": "^1.19.5",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.11",
"@types/node": "^20.11.19",
"@types/node": "^20.11.20",
"@types/swagger-ui-express": "^4.1.6",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
Expand All @@ -32,7 +32,7 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"nodemon": "^3.0.3",
"nodemon": "^3.1.0",
"prettier": "^3.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
Expand All @@ -45,11 +45,11 @@
"cloudflare": "^2.9.1",
"cors": "^2.8.5",
"discord-api-types": "^0.37.70",
"dotenv": "^16.4.4",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"firestorm-db": "^1.11.1",
"firestorm-db": "^1.12.0",
"form-data": "^4.0.0",
"isomorphic-dompurify": "^2.3.0",
"isomorphic-dompurify": "^2.4.0",
"multer": "^1.4.5-lts.1",
"response-time": "^2.3.2",
"statuses": "^2.0.1",
Expand Down
6 changes: 3 additions & 3 deletions src/v2/repository/contributions.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import {
PackID,
} from "../interfaces";
import { contributions, users } from "../firestorm";
import { selectDistinct } from "../tools/firestorm";

export default class ContributionFirestormRepository implements ContributionsRepository {
getContributionById(id: string): Promise<Contribution> {
return contributions.get(id);
}

getPacks(): Promise<PackID[]> {
return selectDistinct(contributions, "pack", true);
return contributions.values({ field: "pack" });
}

searchContributionsFrom(authors: Array<string>, packs: Array<string>): Promise<Contributions> {
Expand Down Expand Up @@ -63,7 +62,8 @@ export default class ContributionFirestormRepository implements ContributionsRep
const out = {};

return (
selectDistinct(contributions, "authors", true)
contributions
.values({ field: "authors", flatten: true })
.then((authors) =>
authors.forEach((id) => {
if (!out[id]) out[id] = { id, contributions: 1 };
Expand Down
3 changes: 1 addition & 2 deletions src/v2/repository/packs.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from "~/v2/interfaces";
import { contributions, packs } from "../firestorm";
import SubmissionFirestormRepository from "./submissions.repository";
import { selectDistinct } from "../tools/firestorm";

export default class PackFirestormRepository implements PackRepository {
private readonly submissionRepo = new SubmissionFirestormRepository();
Expand All @@ -35,7 +34,7 @@ export default class PackFirestormRepository implements PackRepository {
}

getAllTags(): Promise<string[]> {
return selectDistinct(packs, "tags", true).then((res) => res.sort());
return packs.values({ field: "tags", flatten: true }).then((res) => res.sort());
}

search(params: PackSearch): Promise<Packs> {
Expand Down
13 changes: 6 additions & 7 deletions src/v2/repository/texture.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { NotFoundError } from "../tools/ApiError";
import { textures, paths, uses, contributions, settings } from "../firestorm";
import { MinecraftSorter } from "../tools/sorter";
import { selectDistinct } from "../tools/firestorm";

export default class TextureFirestormRepository implements TextureRepository {
async getByNameIdAndTag(
Expand Down Expand Up @@ -139,21 +138,21 @@ export default class TextureFirestormRepository implements TextureRepository {
}

public getEditions() {
return selectDistinct(uses, "edition").then((res) => res.sort());
return uses.values({ field: "edition" }).then((res) => res.sort());
}

public getResolutions(): Promise<Array<number>> {
return selectDistinct(contributions, "resolution").then((res) => res.sort());
return contributions.values({ field: "resolution" }).then((res) => res.sort());
}

public getTags(): Promise<Array<string>> {
return selectDistinct(textures, "tags", true).then((res) => res.sort());
return textures.values({ field: "tags", flatten: true }).then((res) => res.sort());
}

public getVersions(): Promise<Array<string>> {
return selectDistinct(paths, "versions", true).then((res) =>
res.sort(MinecraftSorter).reverse(),
);
return paths
.values({ field: "versions", flatten: true })
.then((res) => res.sort(MinecraftSorter).reverse());
}

public getVersionByEdition(edition: Edition): Promise<Array<string>> {
Expand Down
3 changes: 1 addition & 2 deletions src/v2/repository/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
Username,
UserProfile,
} from "../interfaces";
import { selectDistinct } from "../tools/firestorm";

// eslint-disable-next-line no-underscore-dangle
const __transformUser = (user: Partial<User>): User => ({
Expand Down Expand Up @@ -129,7 +128,7 @@ export default class UserFirestormRepository implements UserRepository {
}

getRoles(): Promise<Array<string>> {
return selectDistinct(users, "roles", true);
return users.values({ field: "roles", flatten: true });
}

getContributionsById(id: string): Promise<Contributions> {
Expand Down
16 changes: 0 additions & 16 deletions src/v2/tools/firestorm.ts

This file was deleted.

0 comments on commit b45f1f1

Please sign in to comment.