website refactor
This commit is contained in:
37
apps/website/lib/contracts/services/Service.ts
Normal file
37
apps/website/lib/contracts/services/Service.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Service contract
|
||||
*
|
||||
* Orchestration boundary for server-side operations.
|
||||
* Returns API DTOs or Page DTOs only.
|
||||
* Must be stateless.
|
||||
*
|
||||
* Based on WEBSITE_CONTRACT.md:
|
||||
* - Services orchestrate IO and composition
|
||||
* - They do not prepare UI
|
||||
* - They return ApiDto or PageDto only
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base service interface for orchestration operations
|
||||
*/
|
||||
export interface Service<TApiDto = unknown, TPageDto = unknown> {
|
||||
/**
|
||||
* Execute a service operation
|
||||
* Returns either API Transport DTO or Page DTO
|
||||
*/
|
||||
execute(...args: unknown[]): Promise<TApiDto | TPageDto>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Service that returns API Transport DTOs
|
||||
*/
|
||||
export interface ApiService<TApiDto = unknown> extends Service<TApiDto, never> {
|
||||
execute(...args: unknown[]): Promise<TApiDto>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Service that returns Page DTOs
|
||||
*/
|
||||
export interface PageService<TPageDto = unknown> extends Service<never, TPageDto> {
|
||||
execute(...args: unknown[]): Promise<TPageDto>;
|
||||
}
|
||||
Reference in New Issue
Block a user