import {createRouteDefiners, HttpMethod, HttpStatus} from '@rest-vir/api';
type MyCustomProps = {
requiresAuth: boolean;
};
export const {defineCustomEndpoint, defineCustomWebSocket} =
createRouteDefiners<MyCustomProps>();
const usersEndpoint = defineCustomEndpoint({
path: '/users',
requests: {
[HttpMethod.Get]: {
customProps: {requiresAuth: true},
responses: {[HttpStatus.Ok]: {responseData: undefined}},
},
},
});
Factory that produces a pair of route definers (
defineCustomEndpoint,defineCustomWebSocket) whose inputs are constrained to require acustomPropsfield of the suppliedCustomPropsshape on every method definition. The returned functions otherwise behave exactly like the standard defineEndpoint and defineWebSocket functions.