Some checks are pending
offline / test (push) Waiting to run
verae-staff-ui holds one review template for CS and access-staff. Staff cookies take STAFF_COOKIE_DOMAIN for a reverse-proxy host. /docs stays vendor Swagger with an integrator banner only.
27 lines
951 B
JavaScript
27 lines
951 B
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
export function reviewHtmlPath(fallback) {
|
|
const env = process.env.STAFF_UI_HTML;
|
|
const shared = path.join(HERE, '..', 'public', 'review.html');
|
|
const sibling = path.join(HERE, '..', '..', 'verae-staff-ui', 'public', 'review.html');
|
|
for (const p of [env, shared, sibling, fallback]) {
|
|
if (p && fs.existsSync(p)) return p;
|
|
}
|
|
return fallback;
|
|
}
|
|
|
|
export function loadReviewHtml(opts, fallback) {
|
|
const file = reviewHtmlPath(fallback);
|
|
let html = fs.readFileSync(file, 'utf8');
|
|
const map = {
|
|
'{{TITLE}}': opts.title || 'Staff review',
|
|
'{{KICKER}}': opts.kicker || 'staff',
|
|
'{{LEDE}}': opts.lede || 'Review prepaid balance, credits, usage, and payments in dollars.',
|
|
};
|
|
for (const [k, v] of Object.entries(map)) html = html.split(k).join(v);
|
|
return html;
|
|
}
|