import { FastifyInstance } from 'fastify';
import * as controller from './local.controller';

async function localRoutes(fastify: FastifyInstance) {
    fastify.post('/library/scan', controller.scanLibrary);
    fastify.get('/library/:type', controller.listEntries);
    fastify.get('/library/:type/:id', controller.getEntry);

    // Streaming básico (legacy)
    fastify.get('/library/stream/:type/:id/:unit', controller.streamUnit);
    fastify.post('/library/:type/:id/match', controller.matchEntry);
    fastify.get('/library/:id/units', controller.getUnits);
    fastify.get('/library/:unitId/manifest', controller.getManifest);
    fastify.get('/library/:unitId/resource/:resId', controller.getPage);
    fastify.post('/library/download/anime', controller.downloadAnime);
    fastify.post('/library/download/book', controller.downloadBook);
    fastify.get('/library/downloads/status', controller.getDownloadStatus);
    fastify.get('/library/stream/:type/:id/:unit/manifest', controller.getAnimeStreamManifest);
    fastify.get('/library/hls/:hash/:filename', controller.serveHLSFile);
}

export default localRoutes;