mirror of
https://github.com/hansputera/tiktok-dl.git
synced 2026-04-06 04:01:57 +02:00
28 lines
757 B
TypeScript
28 lines
757 B
TypeScript
import {FastifyInstance, FastifyPluginOptions} from 'fastify';
|
|
import {rateLimitConfig} from '../config';
|
|
import FastifyRateLimit from 'fastify-rate-limit';
|
|
import {client} from '../lib';
|
|
import {PingRoute, StoredLinksRoute, DownloadRoute} from './routers';
|
|
|
|
export default async (
|
|
fastify: FastifyInstance,
|
|
_: FastifyPluginOptions,
|
|
done: (err?: Error) => void) => {
|
|
if (rateLimitConfig.enable) {
|
|
fastify.register(FastifyRateLimit, {
|
|
redis: client,
|
|
global: false,
|
|
max: rateLimitConfig.maxRatelimit,
|
|
ban: rateLimitConfig.maxRatelimit-1,
|
|
cache: rateLimitConfig.ratelimitTime*1_000,
|
|
});
|
|
}
|
|
|
|
// routers
|
|
new PingRoute(fastify);
|
|
new StoredLinksRoute(fastify);
|
|
new DownloadRoute(fastify);
|
|
|
|
done();
|
|
};
|