Self-hosting! (#49)

* added self-hosting
This commit is contained in:
Carl-Gerhard Lindesvärd
2024-08-28 09:28:44 +02:00
committed by GitHub
parent f0b7526847
commit df05e2dab3
70 changed files with 2310 additions and 272 deletions

View File

@@ -5,6 +5,7 @@ import icoToPng from 'ico-to-png';
import sharp from 'sharp';
import { createHash } from '@openpanel/common';
import { ch, TABLE_NAMES } from '@openpanel/db';
import { getRedisCache } from '@openpanel/redis';
interface GetFaviconParams {
@@ -110,3 +111,37 @@ export async function clearFavicons(
}
return reply.status(404).send('OK');
}
export async function ping(
request: FastifyRequest<{
Body: {
domain: string;
count: number;
};
}>,
reply: FastifyReply
) {
try {
await ch.insert({
table: TABLE_NAMES.self_hosting,
values: [
{
domain: request.body.domain,
count: request.body.count,
created_at: new Date(),
},
],
format: 'JSONEachRow',
});
reply.status(200).send({
message: `Success`,
count: request.body.count,
domain: request.body.domain,
});
} catch (e) {
logger.error(e, 'Failed to insert ping');
reply.status(500).send({
error: 'Failed to insert ping',
});
}
}