import { FastifyPluginAsync } from 'fastify';
// import configRoutes from './routes/ConfigRoutes';
import dummyGradesRoutes from './routes/DummyGradesRoutes';
import endpointsRoutes from './routes/EndpointsRoutes';
import { ChatGptController } from './http/controllers/ChatGptController';
import { ChatGptService } from './middleware/chatgpt/ChatGptService';

const canvasRoutes: FastifyPluginAsync = async (app) => {
    // app.register(configRoutes, { prefix: '/' });
    app.register(dummyGradesRoutes, { prefix: '/' });
    app.register(endpointsRoutes, { prefix: '/' });

    const chatGptService = new ChatGptService();
    const chatGptController = new ChatGptController(chatGptService);

    app.post('/chatgpt/completions', async (req, reply) => {
        await chatGptController.handleChatGptRequest(req, reply);
    });
};

export default canvasRoutes;
