import { FastifyInstance } from 'fastify';
import { getBatches, getBatchById, createBatch, updateBatch } from '../controllers/batches.controller';

export async function batchRoutes(server: FastifyInstance) {
    server.addHook('onRequest', async (request) => {
        try {
            await request.jwtVerify();
        } catch (err) {
            throw err;
        }
    });

    server.get('/', getBatches);
    server.get('/:id', getBatchById);
    server.post('/', createBatch);
    server.put('/:id', updateBatch);
}
