Skip to content

Commit

Permalink
feat(type): service-response
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD committed Dec 30, 2022
1 parent d4b3a95 commit 18f8be3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions core/type/src/service-response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export type AlwatrServiceResponseFailed = {
ok: false;
statusCode: number;
errorCode: string;
meta?: Record<string, unknown>;
data?: never;
};

export type AlwatrServiceResponseSuccess<TData = Record<string, unknown>> = {
ok: true;
statusCode?: number;
errorCode?: never;
meta?: never;
data: TData;
};

export type AlwatrServiceResponseSuccessWithMeta<TData = Record<string, unknown>, TMeta = Record<string, unknown>> = {
ok: true;
statusCode?: number;
errorCode?: never;
meta: TMeta;
data: TData;
};

export type AlwatrServiceResponse<TData = Record<string, unknown>, TMeta = Record<string, unknown>> =
| AlwatrServiceResponseSuccess<TData>
| AlwatrServiceResponseSuccessWithMeta<TData, TMeta>
| AlwatrServiceResponseFailed;

0 comments on commit 18f8be3

Please sign in to comment.