Add service response types for standardizing returns.

Typescript is currently having difficulty parsing Service class return
types. Providing more explicit return types should improve the
situation.
This commit is contained in:
themodrnhakr 2025-09-29 21:13:26 -05:00
parent 14ece0bed0
commit 0990cf5c56

View File

@ -0,0 +1,12 @@
type ServiceResponseSuccess<T, D> = {
status: T;
data?: D;
};
type ServiceResponseFailure<T, E> = {
status: T;
code?: E;
error?: Error | string;
};
export type ServiceResponse<D, E, S = "ok", F = "failure"> =
| ServiceResponseSuccess<S, D>
| ServiceResponseFailure<F, E>;