@freshclinics/utils
v0.0.10
Published
A utility package tailored to support various functions and operations within the **FreshClinics** monorepo. Simplify your development process with reusable tools and helpers.
Readme
FreshClinics Utils
A utility package tailored to support various functions and operations within the FreshClinics monorepo. Simplify your development process with reusable tools and helpers.
Installation
pnpm install @freshclinics/utils
Usage
Import the utility functions you need into your project:
import buildApiResponse from '@repo/utils/buildApiResponse';
// Example usage of buildApiResponse for SuccessPayload.
const response = buildApiResponse({
status: 200,
data: {
id: 1,
name: 'John Doe',
},
message: 'Success',
});
console.log(response);
// Output: { status: 200, data: { id: 1, name: 'John Doe' }, message: 'Success' }
Utilities
API
buildApiResponse<T>(payload: SuccessPayload<T>): ApiResponse<T>
A helper function to create standardized API responses.Example
SuccessPayload<T>
:type SuccessPayload<T> = { data: T | T[]; meta?: Meta; message: string; status: HttpStatusCode; }; type ErrorPayload = { message: string; status: HttpStatusCode; code: ErrorCode; meta?: Meta; };
Validation
(Include validation utilities as they are added to the package.)
Note
This utility package is designed specifically for use within the FreshClinics monorepo. For external use, please check compatibility or consider adjusting imports.