(
request: FastifyRequest<{
Body: {
domain: string;
count: number;
};
}>,
reply: FastifyReply,
)
| 428 | } |
| 429 | |
| 430 | export async function ping( |
| 431 | request: FastifyRequest<{ |
| 432 | Body: { |
| 433 | domain: string; |
| 434 | count: number; |
| 435 | }; |
| 436 | }>, |
| 437 | reply: FastifyReply, |
| 438 | ) { |
| 439 | try { |
| 440 | await ch.insert({ |
| 441 | table: TABLE_NAMES.self_hosting, |
| 442 | values: [ |
| 443 | { |
| 444 | domain: request.body.domain, |
| 445 | count: request.body.count, |
| 446 | created_at: formatClickhouseDate(new Date(), true), |
| 447 | }, |
| 448 | ], |
| 449 | format: 'JSONEachRow', |
| 450 | }); |
| 451 | reply.status(200).send({ |
| 452 | message: 'Success', |
| 453 | count: request.body.count, |
| 454 | domain: request.body.domain, |
| 455 | }); |
| 456 | } catch (error) { |
| 457 | request.log.error({ err: error }, 'Failed to insert ping'); |
| 458 | reply.status(500).send({ |
| 459 | error: 'Failed to insert ping', |
| 460 | }); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | export async function stats(request: FastifyRequest, reply: FastifyReply) { |
| 465 | const res = await getCache('api:stats', 60 * 60, async () => { |
nothing calls this directly
no test coverage detected