// import express from 'express';
// import { Language } from '../langs/lang';

// export class RoutePublic {
//     static setup(app: express.Application) {

//         app.use(Language.apply)
//     }
// }

// import express from 'express';
// import { Language } from '../langs/lang';

// export class RoutePublic {
//     static setup(app: express.Application) {

//         app.use(Language.apply)
//     }
// }

import express from 'express';
import path from 'path';
import fs from 'fs';
import { Language } from '../langs/lang';

export class RoutePublic {
    static setup(app: express.Application) {
        app.use(Language.apply);

        // ⚠️ TAMBAHKAN INI - Serve static files untuk uploads
        app.use('/uploads', express.static(path.join(__dirname, '../../uploads')));

        // Atau dengan custom error handling (pilih salah satu):
        /*
        app.get('/uploads/*', (req, res) => {
            const filePath = path.join(__dirname, '../../', req.path);
            
            if (fs.existsSync(filePath)) {
                res.set({
                    'Cache-Control': 'public, max-age=86400',
                    'Access-Control-Allow-Origin': '*'
                });
                res.sendFile(filePath);
            } else {
                res.status(404).json({ 
                    success: false,
                    message: 'File not found' 
                });
            }
        });
        */
    }
}