Skip to content

Commit

Permalink
chore: define symbols for DI
Browse files Browse the repository at this point in the history
  • Loading branch information
laminne committed Dec 16, 2024
1 parent a33ac55 commit ae429c2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion pkg/notification/adaptor/repository/dummy/notification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Option, Result } from '@mikuroxina/mini-fn';
import { Ether, Option, Result } from '@mikuroxina/mini-fn';
import type {
Notification,
NotificationID,
Expand All @@ -8,6 +8,7 @@ import {
NOTIFICATION_MAX_LIMIT,
type NotificationFilter,
type NotificationRepository,
notificationRepoSymbol,
} from '../../../model/repository/notification.js';

export class InMemoryNotificationRepository implements NotificationRepository {
Expand Down Expand Up @@ -89,3 +90,8 @@ export class InMemoryNotificationRepository implements NotificationRepository {
return Result.ok(undefined);
}

Check warning on line 91 in pkg/notification/adaptor/repository/dummy/notification.ts

View check run for this annotation

Codecov / codecov/patch

pkg/notification/adaptor/repository/dummy/notification.ts#L89-L91

Added lines #L89 - L91 were not covered by tests
}
export const inMemoryNotificationRepo = (data?: Notification[]) =>
Ether.newEther(
notificationRepoSymbol,
() => new InMemoryNotificationRepository(data),
);

Check warning on line 97 in pkg/notification/adaptor/repository/dummy/notification.ts

View check run for this annotation

Codecov / codecov/patch

pkg/notification/adaptor/repository/dummy/notification.ts#L94-L97

Added lines #L94 - L97 were not covered by tests
8 changes: 7 additions & 1 deletion pkg/notification/adaptor/repository/prisma/notification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Option, Result } from '@mikuroxina/mini-fn';
import { Ether, Option, Result } from '@mikuroxina/mini-fn';

Check warning on line 1 in pkg/notification/adaptor/repository/prisma/notification.ts

View check run for this annotation

Codecov / codecov/patch

pkg/notification/adaptor/repository/prisma/notification.ts#L1

Added line #L1 was not covered by tests
import type { Prisma, PrismaClient } from '@prisma/client';
import type { AccountID } from '../../../../accounts/model/account.js';
import {
Expand All @@ -12,6 +12,7 @@ import {
NOTIFICATION_MAX_LIMIT,
type NotificationFilter,
type NotificationRepository,
notificationRepoSymbol,
} from '../../../model/repository/notification.js';

export class PrismaNotificationRepository implements NotificationRepository {
Expand Down Expand Up @@ -239,3 +240,8 @@ export class PrismaNotificationRepository implements NotificationRepository {
}
}
}
export const prismaNotificationRepo = (client: PrismaClient) =>
Ether.newEther(
notificationRepoSymbol,
() => new PrismaNotificationRepository(client),
);

Check warning on line 247 in pkg/notification/adaptor/repository/prisma/notification.ts

View check run for this annotation

Codecov / codecov/patch

pkg/notification/adaptor/repository/prisma/notification.ts#L229-L247

Added lines #L229 - L247 were not covered by tests
4 changes: 3 additions & 1 deletion pkg/notification/model/repository/notification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Option, Result } from '@mikuroxina/mini-fn';
import { Ether, type Option, type Result } from '@mikuroxina/mini-fn';
import type { Notification, NotificationID } from '../notification.js';

export interface NotificationFilter {
Expand Down Expand Up @@ -77,3 +77,5 @@ export interface NotificationRepository {
*/
updateReadAt(notification: Notification): Promise<Result.Result<Error, void>>;
}
export const notificationRepoSymbol =
Ether.newEtherSymbol<NotificationRepository>();

0 comments on commit ae429c2

Please sign in to comment.