feat(ai): add ai chat to dashboard
This commit is contained in:
28
apps/api/src/routes/ai.router.ts
Normal file
28
apps/api/src/routes/ai.router.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as controller from '@/controllers/ai.controller';
|
||||
import { activateRateLimiter } from '@/utils/rate-limiter';
|
||||
import type { FastifyPluginCallback, FastifyRequest } from 'fastify';
|
||||
|
||||
const aiRouter: FastifyPluginCallback = async (fastify) => {
|
||||
await activateRateLimiter<
|
||||
FastifyRequest<{
|
||||
Querystring: {
|
||||
projectId: string;
|
||||
};
|
||||
}>
|
||||
>({
|
||||
fastify,
|
||||
max: process.env.NODE_ENV === 'production' ? 20 : 100,
|
||||
timeWindow: '300 seconds',
|
||||
keyGenerator: (req) => {
|
||||
return req.query.projectId;
|
||||
},
|
||||
});
|
||||
|
||||
fastify.route({
|
||||
method: 'POST',
|
||||
url: '/chat',
|
||||
handler: controller.chat,
|
||||
});
|
||||
};
|
||||
|
||||
export default aiRouter;
|
||||
Reference in New Issue
Block a user