import router from '@adonisjs/core/services/router';
import { middleware } from '#start/kernel';
export default () => {
    // Public read-only API routes (no auth needed for shared DB sync)
    router
        .group(() => {
        router.route('/message', ['GET', 'POST'], '#controllers/api/message_controller.index');
        router.post('/message/query', '#controllers/api/message_controller.query');
        router.route('/group/fetch', ['GET', 'POST'], '#controllers/api/group_controller.index');
        // ScammerGuard read-only API
        router.get('/scammer-guard', '#controllers/api/scammer_guard_controller.index');
        router.post('/scammer-guard/check', '#controllers/api/scammer_guard_controller.check');
        // Keyword API
        router.get('/scammer-guard/keywords', '#controllers/api/scammer_guard_controller.keywords');
        // Whitelist API
        router.get('/scammer-guard/whitelist', '#controllers/api/scammer_guard_controller.whitelistIndex');
        router.post('/scammer-guard/whitelist/check', '#controllers/api/scammer_guard_controller.whitelistCheck');
        // Logs API
        router.get('/scammer-guard/logs', '#controllers/api/scammer_guard_controller.logs');
    })
        .prefix('api');

    // Bug #8 fix: Write operations require wapi authentication
    router
        .group(() => {
        router.post('/scammer-guard', '#controllers/api/scammer_guard_controller.store');
        router.delete('/scammer-guard/:id', '#controllers/api/scammer_guard_controller.destroy').where('id', router.matchers.number());
    })
        .prefix('api')
        .use(middleware.wapi());

    router
        .post('example/webhook', '#controllers/api/example_webhook_controller.index')
        .as('api.example.webhook');
};
