386 B · text History 1619312
// Parses the app's configuration; throws on anything it can't read.
export interface Config {
  name: string;
  retries: number;
}

export function parseConfig(input: string): Config {
  const parsed = JSON.parse(input);
  if (typeof parsed.retries !== "number") {
    throw new Error("retries must be a number");
  }
  return { name: String(parsed.name), retries: parsed.retries };
}