forked from dilan-dio4/Keagate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvoiceClient.ts
32 lines (29 loc) · 1.28 KB
/
invoiceClient.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { FastifyInstance, RouteShorthandOptions } from 'fastify';
import fastifyStatic from '@fastify/static';
import path from 'path';
import fastifyPlugin from 'fastify-plugin';
import { Type } from '@sinclair/typebox';
export default fastifyPlugin(async function createInvoiceClientRoute(server: FastifyInstance) {
server.register(fastifyStatic, {
root: path.join(__dirname, '..', '..', '..', 'invoice-client', 'dist'),
prefix: '/static-invoice',
});
const opts: RouteShorthandOptions = {
schema: {
tags: ['Invoice'],
description: `Route for Keagate's built-in invoice interface.`,
summary: `Route for Keagate's built-in invoice interface`,
params: Type.Object({
currency: Type.String({
description: `Shorthand name of a payment's corresponding currency.`,
}),
invoiceId: Type.String({
description: `Invoice identifier. This is generated automatically as the internal id of the payment encrypted with aes-256-cbc plus your config's INVOICE_ENC_KEY.`,
}),
}),
},
};
server.get('/invoice/:currency/:invoiceId', opts, (request, reply) => {
reply.sendFile('index.html');
});
});