| 1 | import os from "node:os"; |
| 2 | import path from "node:path |
| 3 | import { z } |
| 4 | |
| 5 | const configSchema = z |
| 6 | PORT: z.coerce |
| 7 | IMPORTER_SECRET: z.string |
| 8 | // Where the importer reaches the API, for its callbacks and for `git push`. Inside a private network this is the internal name, not the public origin. |
| 9 | GHOST_API_URL: z.url |
| 10 | IMPORTER_CONCURRENCY: z.coerce |
| 11 | IMPORTER_WORKDIR: z |
| 12 | .string() |
| 13 | .default(path.join |
| 14 | }); |
| 15 | |
| 16 | export type Config |
| 17 | |
| 18 | export function loadConfig(env |
| 19 | const parsed = |
| 20 | if (!parsed.success |
| 21 | throw new Error( |
| 22 | `Invalid importer configuration: ${z.prettifyError |
| 23 | ); |
| 24 | } |
| 25 | return parsed.data |
| 26 | } |