export interface IError {
message: string;
code?: string;
stack?: string;
}
export interface IOrdering {
column: string;
order: 'asc' | 'desc';
}
export interface IPagination {
offset: number;
limit: number;
order: IOrdering[];
}
export interface IRecordList<T> extends IPagination {
total: number;
records: T[];
}
export interface IBasicResponse {
success: boolean;
deprecated?: boolean;
}
export interface IResponseRecord<T> extends IBasicResponse {
result: T;
}
export interface IResponseList<T> extends IBasicResponse {
result: IRecordList<T>;
}
export interface IResponseError extends IBasicResponse {
result: IError;
}
export interface IResponseCommon<T> extends IBasicResponse {
result: IError | IRecordList<T> | T;
}
Last active
October 18, 2020 10:05
-
-
Save chiro-hiro/cf4fdf757a12efdf5b67a5bbe51271ef to your computer and use it in GitHub Desktop.
Standardized your RESTful API in TypeScript
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment