feat(core): add application interfaces (repositories + services)
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
import type { Article } from "@/entities/models/article.js";
|
||||||
|
|
||||||
|
export interface IArticlesRepository {
|
||||||
|
getArticle(id: string): Promise<Article | undefined>;
|
||||||
|
getArticles(options?: {
|
||||||
|
status?: string;
|
||||||
|
authorId?: string;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
}): Promise<Article[]>;
|
||||||
|
createArticle(input: Article): Promise<Article>;
|
||||||
|
updateArticle(
|
||||||
|
id: string,
|
||||||
|
input: Partial<Article>
|
||||||
|
): Promise<Article | undefined>;
|
||||||
|
}
|
||||||
2
packages/core/src/application/repositories/index.ts
Normal file
2
packages/core/src/application/repositories/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export type { IUsersRepository } from "./users.repository.interface.js";
|
||||||
|
export type { IArticlesRepository } from "./articles.repository.interface.js";
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import type { User } from "@/entities/models/user.js";
|
||||||
|
|
||||||
|
export interface IUsersRepository {
|
||||||
|
getUser(id: string): Promise<User | undefined>;
|
||||||
|
getUserByUsername(username: string): Promise<User | undefined>;
|
||||||
|
createUser(input: User): Promise<User>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import type { Cookie } from "@/entities/models/cookie.js";
|
||||||
|
import type { Session } from "@/entities/models/session.js";
|
||||||
|
import type { User } from "@/entities/models/user.js";
|
||||||
|
|
||||||
|
export interface IAuthenticationService {
|
||||||
|
generateUserId(): string;
|
||||||
|
hashPassword(password: string): Promise<string>;
|
||||||
|
verifyPassword(hash: string, password: string): Promise<boolean>;
|
||||||
|
validateSession(
|
||||||
|
sessionId: string
|
||||||
|
): Promise<{ user: User; session: Session }>;
|
||||||
|
createSession(user: User): Promise<{ session: Session; cookie: Cookie }>;
|
||||||
|
invalidateSession(sessionId: string): Promise<{ blankCookie: Cookie }>;
|
||||||
|
}
|
||||||
2
packages/core/src/application/services/index.ts
Normal file
2
packages/core/src/application/services/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export type { IAuthenticationService } from "./auth.service.interface.js";
|
||||||
|
export type { ITelemetryService } from "./telemetry.service.interface.js";
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export interface ITelemetryService {
|
||||||
|
startSpan<T>(name: string, fn: () => T | Promise<T>): Promise<T>;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user