Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/domain/creator/getOthers/getOthers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataModel[]>
export default async function getOthers(ids: string[], order: SortOrder, limit: number, offset: number, search: string | undefined = undefined): Promise<DataModel[]>
{
const defaultQuery: RecordQuery = { id: { NOT_IN: ids } };
const searchQuery: RecordQuery = {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/post/aggregate/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/domain/post/toggleRating/toggleRating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/domain/relation/explore/explore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataModel[]>
export default async function explore(requester: Requester, order: SortOrder, limit: number, offset: number, search: string | undefined = undefined): Promise<DataModel[]>
{
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 =>
{
Expand Down
4 changes: 2 additions & 2 deletions src/domain/relation/exploreAggregated/exploreAggregated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AggregatedData[]>
export default async function exploreAggregated(requester: Requester, order: SortOrder, range: Range, search: string | undefined = undefined): Promise<AggregatedData[]>
{
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)));
}
2 changes: 1 addition & 1 deletion src/integrations/database/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const LOGICAL_OPERATORS =

export default class Memory implements Driver
{
#memory = new Map<string, RecordData[]>();
readonly #memory = new Map<string, RecordData[]>();
#connected = false;
recordId = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NotConnected from '../../errors/NotConnected';

export default class Memory implements FileStore
{
#files = new Map<string, Buffer>();
readonly #files = new Map<string, Buffer>();
#connected = false;

get connected() { return this.#connected; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const BUCKET_NAME = 'comify';

export default class MinioFS implements FileStore
{
#configuration: ClientOptions;
readonly #configuration: ClientOptions;
#client?: Client;

constructor(configuration: ClientOptions)
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/http/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Http } from './definitions/interfaces';

export default class Memory implements Http
{
#implementation: Http;
#cache = new Map<string, Response>();
readonly #implementation: Http;
readonly #cache = new Map<string, Response>();

constructor(implementation: Http)
{
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/logging/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type VapidDetails = {

export default class WebPush implements NotificationService
{
#configuration: VapidDetails;
readonly #configuration: VapidDetails;
#subscriptions?: Map<string, PushSubscription>;

constructor(configuration: VapidDetails)
Expand Down
2 changes: 1 addition & 1 deletion src/integrations/runtime/errors/ValidationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BadRequest } from 'jitar';

export default class ValidationError extends BadRequest
{
#messages: Map<string, string>;
readonly #messages: Map<string, string>;

constructor(messages: Map<string, string>)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const sessions = new Map<string, Session>();

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[])
{
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/validation/definitions/ValidationResult.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

export default class ValidationResult
{
#invalid: boolean;
#messages: Map<string, string>;
readonly #invalid: boolean;
readonly #messages: Map<string, string>;

constructor(invalid: boolean, messages = new Map<string, string>())
{
Expand Down
2 changes: 1 addition & 1 deletion src/integrations/validation/implementations/zod/Zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ValidatorFunction = (value: ValidationTypes[keyof ValidationTypes]) => z.Zo

export default class Zod implements Validator
{
#validations = new Map<string, ValidatorFunction>();
readonly #validations = new Map<string, ValidatorFunction>();

constructor()
{
Expand Down
2 changes: 1 addition & 1 deletion src/webui/components/common/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type State = {

export default class Component extends ReactComponent<Props, State>
{
#promiseHandler = (event: PromiseRejectionEvent) =>
readonly #promiseHandler = (event: PromiseRejectionEvent) =>
{
this.setState({ error: event.reason });

Expand Down
2 changes: 1 addition & 1 deletion src/webui/features/hooks/useExploreCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

}, []);

Expand Down
12 changes: 6 additions & 6 deletions test/domain/relation/exploreAggregated.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down