MCPcopy Index your code
hub / github.com/cameri/nostream / GetInvoiceController

Class GetInvoiceController

src/controllers/invoices/get-invoice-controller.ts:13–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import { getPublicPathPrefix } from '../../utils/http'
12
13export class GetInvoiceController implements IController {
14 public async handleRequest(req: Request, res: Response): Promise<void> {
15 const settings = createSettings()
16
17 if (
18 pathEq(['payments', 'enabled'], true, settings) &&
19 pathEq(['payments', 'feeSchedules', 'admission', '0', 'enabled'], true, settings)
20 ) {
21 const name = path<string>(['info', 'name'])(settings)
22 const feeSchedule = path<FeeSchedule>(['payments', 'feeSchedules', 'admission', '0'], settings)
23 const page = getTemplate('./resources/get-invoice.html')
24 .replaceAll('{{name}}', escapeHtml(name))
25 .replaceAll('{{path_prefix}}', escapeHtml(getPublicPathPrefix(req, settings)))
26 .replaceAll('{{processor_json}}', safeJsonForScript(settings.payments.processor))
27 .replaceAll('{{amount}}', (BigInt(feeSchedule.amount) / 1000n).toString())
28 .replaceAll('{{nonce}}', res.locals.nonce)
29
30 res.status(200).setHeader('content-type', 'text/html; charset=utf8').send(page)
31 } else {
32 res.status(404).send()
33 }
34 }
35}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected