export async function parseRequest()

in src/parse.ts [360:382]


export async function parseRequest(
  source: string,
  options?: ParseOptions,
): Promise<ParsedRequest> {
  source = source.replace(/^\s+|\s+$/g, ""); // trim whitespace
  const req = parseCommand(source, options ?? {});
  if (req.service == "es") {
    // for Elasticsearch URLs we can get API details
    try {
      const route = await getAPI(req.method, req.rawPath);
      req.api = route.handler.name;
      req.request = route.handler.request;
      if (Object.keys(route.params).length > 0) {
        req.params = route.params;
      }
    } catch (error) {
      if (!options?.ignoreErrors) {
        throw error;
      }
    }
  }
  return req;
}