FBI_kingmohbil
FBI_kingmohbil
HHono
Created by FBI_kingmohbil on 8/24/2024 in #help
how can I specify the return type of the response of API response
Ah okay thanks
9 replies
HHono
Created by FBI_kingmohbil on 8/24/2024 in #help
how can I specify the return type of the response of API response
this is my typed definition
createMiddleware(async (c): TypedResponse<LoginResponse | ErrorResponseType>
createMiddleware(async (c): TypedResponse<LoginResponse | ErrorResponseType>
9 replies
HHono
Created by FBI_kingmohbil on 8/24/2024 in #help
how can I specify the return type of the response of API response
Okay I'm using it inside createMiddleware how can I do that TypedResponse<LoginResponse | ErrorResponseType>
9 replies
HHono
Created by FBI_kingmohbil on 8/24/2024 in #help
how can I specify the return type of the response of API response
That's perfect thanks
9 replies
HHono
Created by FBI_kingmohbil on 8/24/2024 in #help
how can I specify the return type of the response of API response
The thing is I want to have control over the API responses to define for example this type
interface Response<T> {
message: string;
data: T;
}
interface Response<T> {
message: string;
data: T;
}
and I want to enforce that on every single route, just so I don't forget to write those and to stay semantic as possible in the responses so then in the development time, I would need less time writing unit-tests and the typescript compiler will let me know if I violated this, which I'm not saying I shouldn't write unit tests defiantly I should but this will make my development easier to manages especially If I'm working with a team that isn't that solid to grasp these points
9 replies