in src/parse.ts [334:358]
async function getAPI(
method: string,
endpointPath: string,
): Promise<Router.FindResult<ESRoute>> {
if (router.find("GET", "/") == undefined) {
if (!isBrowser) {
// load the Elasticsearch spec
await loadSchema(path.join(__dirname, "./schema.json"));
} else {
throw new Error("Specification is missing");
}
}
const formattedPath = endpointPath.startsWith("/")
? endpointPath
: `/${endpointPath}`;
const route = router.find(method, formattedPath);
if (!route) {
/* istanbul ignore next */
throw new Error(
`There is no handler for method '${method}' and url '${formattedPath}'`,
);
}
return route;
}