diff --git a/src/domain/creator/getOthers/getOthers.ts b/src/domain/creator/getOthers/getOthers.ts index 26ac7dc8..06abe6e4 100644 --- a/src/domain/creator/getOthers/getOthers.ts +++ b/src/domain/creator/getOthers/getOthers.ts @@ -4,7 +4,7 @@ import database, { QueryStatement, RecordQuery, RecordSort, SortDirections } fro import { RECORD_TYPE, SortOrder, SortOrders } from '../definitions'; import type { DataModel } from '../types'; -export default async function getOthers(ids: string[], order: SortOrder, search: string | undefined = undefined, limit: number, offset: number): Promise +export default async function getOthers(ids: string[], order: SortOrder, limit: number, offset: number, search: string | undefined = undefined): Promise { const defaultQuery: RecordQuery = { id: { NOT_IN: ids } }; const searchQuery: RecordQuery = { diff --git a/src/domain/post/aggregate/aggregate.ts b/src/domain/post/aggregate/aggregate.ts index eaf4941d..e78e3f48 100644 --- a/src/domain/post/aggregate/aggregate.ts +++ b/src/domain/post/aggregate/aggregate.ts @@ -12,7 +12,7 @@ export default async function aggregate(requester: Requester, data: DataModel): const [creatorData, comicData, hasRated] = await Promise.all([ getRelationData(requester.id, data.creatorId), getComicData(data.comicId), - ratingExists(requester.id, data.id, undefined), + ratingExists(requester.id, data.id), ]); return { diff --git a/src/domain/post/toggleRating/toggleRating.ts b/src/domain/post/toggleRating/toggleRating.ts index 901f1221..944a52c5 100644 --- a/src/domain/post/toggleRating/toggleRating.ts +++ b/src/domain/post/toggleRating/toggleRating.ts @@ -15,7 +15,7 @@ export default async function toggleRating(requester: Requester, postId: string) try { - ratingId = await updateRating(requester, postId, undefined); + ratingId = await updateRating(requester, postId); if (ratingId === undefined) { @@ -28,7 +28,7 @@ export default async function toggleRating(requester: Requester, postId: string) const post = await getPost(postId); - await createNotification(Types.RATED_POST, requester.id, post.creatorId, postId, undefined); + await createNotification(Types.RATED_POST, requester.id, post.creatorId, postId); return true; } @@ -38,7 +38,7 @@ export default async function toggleRating(requester: Requester, postId: string) if (ratingId !== undefined) { - await updateRating(requester, postId, undefined); + await updateRating(requester, postId); } throw error; diff --git a/src/domain/relation/explore/explore.ts b/src/domain/relation/explore/explore.ts index 8b82af7a..b19dd761 100644 --- a/src/domain/relation/explore/explore.ts +++ b/src/domain/relation/explore/explore.ts @@ -6,13 +6,13 @@ import type { SortOrder } from '../definitions'; import getFollowing from '../getFollowing'; import type { DataModel } from '../types'; -export default async function explore(requester: Requester, order: SortOrder, search: string | undefined = undefined, limit: number, offset: number): Promise +export default async function explore(requester: Requester, order: SortOrder, limit: number, offset: number, search: string | undefined = undefined): Promise { const followingData = await getFollowing(requester, requester.id); const followingIds = followingData.map(data => data.followingId); followingIds.push(requester.id); - const creatorData = await getOtherCreators(followingIds, order, search, limit, offset); + const creatorData = await getOtherCreators(followingIds, order, limit, offset, search); return creatorData.map(data => { diff --git a/src/domain/relation/exploreAggregated/exploreAggregated.ts b/src/domain/relation/exploreAggregated/exploreAggregated.ts index 3109116d..58457569 100644 --- a/src/domain/relation/exploreAggregated/exploreAggregated.ts +++ b/src/domain/relation/exploreAggregated/exploreAggregated.ts @@ -6,11 +6,11 @@ import aggregate, { AggregatedData } from '../aggregate'; import type { SortOrder } from '../definitions'; import explore from '../explore'; -export default async function exploreAggregated(requester: Requester, order: SortOrder, search: string | undefined = undefined, range: Range): Promise +export default async function exploreAggregated(requester: Requester, order: SortOrder, range: Range, search: string | undefined = undefined): Promise { validateRange(range); - const data = await explore(requester, order, search, range.limit, range.offset); + const data = await explore(requester, order, range.limit, range.offset, search); return Promise.all(data.map(item => aggregate(item))); } diff --git a/src/integrations/database/Database.ts b/src/integrations/database/Database.ts index fe7da949..efcf17dc 100644 --- a/src/integrations/database/Database.ts +++ b/src/integrations/database/Database.ts @@ -6,7 +6,7 @@ import { RecordData, RecordField, RecordId, RecordQuery, RecordSort, RecordType export default class Database implements Driver { - #driver: Driver; + readonly #driver: Driver; constructor(driver: Driver) { diff --git a/src/integrations/database/implementations/memory/Memory.ts b/src/integrations/database/implementations/memory/Memory.ts index c9a54a35..dab90713 100644 --- a/src/integrations/database/implementations/memory/Memory.ts +++ b/src/integrations/database/implementations/memory/Memory.ts @@ -26,7 +26,7 @@ const LOGICAL_OPERATORS = export default class Memory implements Driver { - #memory = new Map(); + readonly #memory = new Map(); #connected = false; recordId = 0; diff --git a/src/integrations/database/implementations/mongodb/MongoDb.ts b/src/integrations/database/implementations/mongodb/MongoDb.ts index 0b11ecbf..740cc171 100644 --- a/src/integrations/database/implementations/mongodb/MongoDb.ts +++ b/src/integrations/database/implementations/mongodb/MongoDb.ts @@ -40,8 +40,8 @@ const MONGO_ID = '_id'; export default class MongoDB implements Driver { - #connectionString: string; - #databaseName: string; + readonly #connectionString: string; + readonly #databaseName: string; #client?: MongoClient; #database?: Db; diff --git a/src/integrations/filestore/implementations/memory/Memory.ts b/src/integrations/filestore/implementations/memory/Memory.ts index 53059551..3019e0f0 100644 --- a/src/integrations/filestore/implementations/memory/Memory.ts +++ b/src/integrations/filestore/implementations/memory/Memory.ts @@ -5,7 +5,7 @@ import NotConnected from '../../errors/NotConnected'; export default class Memory implements FileStore { - #files = new Map(); + readonly #files = new Map(); #connected = false; get connected() { return this.#connected; } diff --git a/src/integrations/filestore/implementations/minio/MinioFS.ts b/src/integrations/filestore/implementations/minio/MinioFS.ts index f433fc56..cde91a94 100644 --- a/src/integrations/filestore/implementations/minio/MinioFS.ts +++ b/src/integrations/filestore/implementations/minio/MinioFS.ts @@ -9,7 +9,7 @@ const BUCKET_NAME = 'comify'; export default class MinioFS implements FileStore { - #configuration: ClientOptions; + readonly #configuration: ClientOptions; #client?: Client; constructor(configuration: ClientOptions) diff --git a/src/integrations/http/Client.ts b/src/integrations/http/Client.ts index 3b6f336b..ed737c1b 100644 --- a/src/integrations/http/Client.ts +++ b/src/integrations/http/Client.ts @@ -4,8 +4,8 @@ import { Http } from './definitions/interfaces'; export default class Memory implements Http { - #implementation: Http; - #cache = new Map(); + readonly #implementation: Http; + readonly #cache = new Map(); constructor(implementation: Http) { diff --git a/src/integrations/logging/Logger.ts b/src/integrations/logging/Logger.ts index ece5fa64..2d1a67fb 100644 --- a/src/integrations/logging/Logger.ts +++ b/src/integrations/logging/Logger.ts @@ -3,8 +3,8 @@ import { LogProcessor } from './definitions/interfaces'; export default class Logger implements LogProcessor { - #processor: LogProcessor; - #debugEnabled: boolean; + readonly #processor: LogProcessor; + readonly #debugEnabled: boolean; constructor(processor: LogProcessor, debugEnabled = false) { diff --git a/src/integrations/notification/implementations/webpush/WebPush.ts b/src/integrations/notification/implementations/webpush/WebPush.ts index 1aab0d7c..304e9fb4 100644 --- a/src/integrations/notification/implementations/webpush/WebPush.ts +++ b/src/integrations/notification/implementations/webpush/WebPush.ts @@ -13,7 +13,7 @@ type VapidDetails = { export default class WebPush implements NotificationService { - #configuration: VapidDetails; + readonly #configuration: VapidDetails; #subscriptions?: Map; constructor(configuration: VapidDetails) diff --git a/src/integrations/runtime/errors/ValidationError.ts b/src/integrations/runtime/errors/ValidationError.ts index 5c48daca..7abcf5d7 100644 --- a/src/integrations/runtime/errors/ValidationError.ts +++ b/src/integrations/runtime/errors/ValidationError.ts @@ -3,7 +3,7 @@ import { BadRequest } from 'jitar'; export default class ValidationError extends BadRequest { - #messages: Map; + readonly #messages: Map; constructor(messages: Map) { diff --git a/src/integrations/runtime/middlewares/AuthenticationMiddleware.ts b/src/integrations/runtime/middlewares/AuthenticationMiddleware.ts index db0f81de..6d2ad4fe 100644 --- a/src/integrations/runtime/middlewares/AuthenticationMiddleware.ts +++ b/src/integrations/runtime/middlewares/AuthenticationMiddleware.ts @@ -20,10 +20,10 @@ const sessions = new Map(); export default class AuthenticationMiddleware implements Middleware { - #identityProvider: IdentityProvider; - #authProcedures: AuthProcedures; - #redirectUrl: string; - #whiteList: string[]; + readonly #identityProvider: IdentityProvider; + readonly #authProcedures: AuthProcedures; + readonly #redirectUrl: string; + readonly #whiteList: string[]; constructor(identityProvider: IdentityProvider, authProcedures: AuthProcedures, redirectUrl: string, whiteList: string[]) { diff --git a/src/integrations/validation/definitions/ValidationResult.ts b/src/integrations/validation/definitions/ValidationResult.ts index 97a25e68..a8fb5ffc 100644 --- a/src/integrations/validation/definitions/ValidationResult.ts +++ b/src/integrations/validation/definitions/ValidationResult.ts @@ -1,8 +1,8 @@ export default class ValidationResult { - #invalid: boolean; - #messages: Map; + readonly #invalid: boolean; + readonly #messages: Map; constructor(invalid: boolean, messages = new Map()) { diff --git a/src/integrations/validation/implementations/zod/Zod.ts b/src/integrations/validation/implementations/zod/Zod.ts index 7bd8738c..e484ff5a 100644 --- a/src/integrations/validation/implementations/zod/Zod.ts +++ b/src/integrations/validation/implementations/zod/Zod.ts @@ -14,7 +14,7 @@ type ValidatorFunction = (value: ValidationTypes[keyof ValidationTypes]) => z.Zo export default class Zod implements Validator { - #validations = new Map(); + readonly #validations = new Map(); constructor() { diff --git a/src/webui/components/common/ErrorBoundary.tsx b/src/webui/components/common/ErrorBoundary.tsx index c7e50dc9..faa92e4a 100644 --- a/src/webui/components/common/ErrorBoundary.tsx +++ b/src/webui/components/common/ErrorBoundary.tsx @@ -16,7 +16,7 @@ type State = { export default class Component extends ReactComponent { - #promiseHandler = (event: PromiseRejectionEvent) => + readonly #promiseHandler = (event: PromiseRejectionEvent) => { this.setState({ error: event.reason }); diff --git a/src/webui/features/hooks/useExploreCreators.ts b/src/webui/features/hooks/useExploreCreators.ts index b104639b..c3ba3b70 100644 --- a/src/webui/features/hooks/useExploreCreators.ts +++ b/src/webui/features/hooks/useExploreCreators.ts @@ -12,7 +12,7 @@ export default function useExploreCreators() const getData = useCallback((page: number) => { - return exploreRelations(requester, 'popular', undefined, { limit, offset: page * limit }); + return exploreRelations(requester, 'popular', { limit, offset: page * limit }); }, []); diff --git a/test/domain/relation/exploreAggregated.spec.ts b/test/domain/relation/exploreAggregated.spec.ts index f4e61d9a..049b3452 100644 --- a/test/domain/relation/exploreAggregated.spec.ts +++ b/test/domain/relation/exploreAggregated.spec.ts @@ -15,7 +15,7 @@ describe('domain/relation/exploreAggregated', () => { it('should explore relations based on popularity', async () => { - const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, undefined, VALUES.RANGE); + const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, VALUES.RANGE); expect(relations).toHaveLength(3); expect(relations[0].following?.id).toBe(VALUES.IDS.CREATOR5); expect(relations[1].following?.id).toBe(VALUES.IDS.CREATOR4); @@ -24,7 +24,7 @@ describe('domain/relation/exploreAggregated', () => it('should explore relations based on recent', async () => { - const relations = await explore(REQUESTERS.FIRST, SortOrders.RECENT, undefined, VALUES.RANGE); + const relations = await explore(REQUESTERS.FIRST, SortOrders.RECENT, VALUES.RANGE); expect(relations).toHaveLength(3); expect(relations[0].following?.id).toBe(VALUES.IDS.CREATOR4); expect(relations[1].following?.id).toBe(VALUES.IDS.CREATOR6); @@ -33,27 +33,27 @@ describe('domain/relation/exploreAggregated', () => it('should find no relations based on search', async () => { - const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, 'or2', VALUES.RANGE); + const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, VALUES.RANGE, 'or2'); expect(relations).toHaveLength(0); }); it('should find relations based on search full name', async () => { - const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, 'or 4', VALUES.RANGE); + const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, VALUES.RANGE, 'or 4'); expect(relations).toHaveLength(1); expect(relations[0].following?.id).toBe(VALUES.IDS.CREATOR4); }); it('should find relations based on search nickname', async () => { - const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, 'creator4', VALUES.RANGE); + const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, VALUES.RANGE, 'creator4'); expect(relations).toHaveLength(1); expect(relations[0].following?.id).toBe(VALUES.IDS.CREATOR4); }); it('should find relations based on search full name and nickname', async () => { - const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, 'five', VALUES.RANGE); + const relations = await explore(REQUESTERS.FIRST, SortOrders.POPULAR, VALUES.RANGE, 'five'); expect(relations).toHaveLength(2); expect(relations[0].following?.id).toBe(VALUES.IDS.CREATOR5); expect(relations[1].following?.id).toBe(VALUES.IDS.CREATOR6);