OptionalbypassSet this to true to bypass shape validation. You might want to use this, for example, for
large data sets that are being slow.
OptionalcustomAny additional data that you wish to attach to this endpoint. This won't be used by the service at all, it's merely a place for you to place extra data which will be passed along to your endpoint implementations.
All allowed (or not allowed) HTTP methods for this endpoint. Set true for each allowed
method and omit or set false for each blocked method.
Shape definition for request data. Set to undefined for no request data.
See the object-shape-tester package
for extra details on defining a shape.
OptionalrequiredSet a required client origin for this endpoint.
undefined, this endpoint allows any origins (regardless of the
service's origin requirement).Shape definition for response data. Set to undefined for no response data.
See the object-shape-tester package
for extra details on defining a shape.
OptionalsearchA shape used to verify search params. This should match the entire search params object.
Note the following:
import {exact, enumShape} from 'object-shape-tester';
const partialEndpointInit = {
searchParamsShape: {
// use `tupleShape` to ensure there's exactly one entry for this search param
userId: tupleShape(enumShape(MyEnum)),
date: tupleShape(exact('2')),
// don't use `tupleShape` here so that there can be any number of entries
colors: [''],
},
};
The type for setting up an individual endpoint, used in
defineService.Package
@rest-vir/define-service