|
| 1 | +import assert from "node:assert/strict"; |
| 2 | +import fs from "node:fs"; |
| 3 | +import path from "node:path"; |
| 4 | +import { describe, it } from "node:test"; |
| 5 | + |
| 6 | +// The Lambda talks to the other ChurchApps APIs with the hosts in config/<stage>.json. Demo used to fall |
| 7 | +// back to dev.json, whose hosts are localhost, so every people-search lookup (groups, attendance, |
| 8 | +// donations) failed in demo and matched nobody. The legacy per-module hostnames redirect across hosts, |
| 9 | +// which drops the Authorization header, so prod has to name the api.churchapps.org/<module> form too. |
| 10 | +const modules = ["membership", "attendance", "content", "doing", "giving", "messaging", "reporting"]; |
| 11 | +const stages: { [file: string]: string } = { |
| 12 | + "demo.json": "https://api.demo.churchapps.org", |
| 13 | + "staging.json": "https://api.staging.churchapps.org", |
| 14 | + "prod.json": "https://api.churchapps.org" |
| 15 | +}; |
| 16 | + |
| 17 | +describe("stage configs", () => { |
| 18 | + for (const [file, base] of Object.entries(stages)) { |
| 19 | + it(`${file} points every module host at ${base}/<module>`, () => { |
| 20 | + const config = JSON.parse(fs.readFileSync(path.resolve("config", file), "utf8")); |
| 21 | + for (const m of modules) { |
| 22 | + assert.equal(config[`${m}Api`], `${base}/${m}`, `${file} ${m}Api`); |
| 23 | + } |
| 24 | + }); |
| 25 | + } |
| 26 | +}); |
0 commit comments