import { middleware } from '#start/kernel';
import { resetToken } from '#start/limiter';
import router from '@adonisjs/core/services/router';
export default () => {
    router
        .group(() => {
        router.get('/', '#controllers/devices_controller.index').as('home');
        // ScammerGuard routes
        router.get('/scammer-guard', '#controllers/scammer_controller.index').as('scammer.index');
        router.post('/scammer-guard', '#controllers/scammer_controller.store').as('scammer.store');
        router.put('/scammer-guard/:id', '#controllers/scammer_controller.update').as('scammer.update').where('id', router.matchers.number());
        router.delete('/scammer-guard/:id', '#controllers/scammer_controller.destroy').as('scammer.destroy').where('id', router.matchers.number());
        router.post('/scammer-guard/:id/toggle', '#controllers/scammer_controller.toggle').as('scammer.toggle').where('id', router.matchers.number());
        router.get('/scammer-guard/export', '#controllers/scammer_controller.exportCsv').as('scammer.export');
        router.post('/scammer-guard/import', '#controllers/scammer_controller.importCsv').as('scammer.import');
        // Keywords
        router.post('/scammer-guard/keyword', '#controllers/scammer_controller.storeKeyword').as('scammer.keyword.store');
        router.delete('/scammer-guard/keyword/:id', '#controllers/scammer_controller.destroyKeyword').as('scammer.keyword.destroy').where('id', router.matchers.number());
        router.post('/scammer-guard/keyword/:id/toggle', '#controllers/scammer_controller.toggleKeyword').as('scammer.keyword.toggle').where('id', router.matchers.number());
        // Whitelist
        router.post('/scammer-guard/whitelist', '#controllers/scammer_controller.storeWhitelist').as('scammer.whitelist.store');
        router.delete('/scammer-guard/whitelist/:id', '#controllers/scammer_controller.destroyWhitelist').as('scammer.whitelist.destroy').where('id', router.matchers.number());
        // Logs
        router.post('/scammer-guard/logs/clear', '#controllers/scammer_controller.clearLogs').as('scammer.logs.clear');
        router.get('/scammer-guard/logs/export', '#controllers/scammer_controller.exportLogs').as('scammer.logs.export');
        // Settings
        router.post('/scammer-guard/settings', '#controllers/scammer_controller.saveSettings').as('scammer.settings.save');
        // Shared DB sync
        router.post('/scammer-guard/sync', '#controllers/scammer_controller.syncSharedDb').as('scammer.sync');
        router
            .group(() => {
            router.get('/', '#controllers/devices_controller.index').as('device');
            router
                .get('/:id', '#controllers/devices_controller.show')
                .where('id', router.matchers.number())
                .as('device.detail');
            router
                .get('/:id/reset-token', '#controllers/devices_controller.resetToken')
                .where('id', router.matchers.number())
                .as('device.resetToken')
                .use(resetToken);
            router
                .post('/:id/webhook', '#controllers/devices_controller.updateWebhook')
                .where('id', router.matchers.number())
                .as('device.updateWebhook');
            router.post('/create', '#controllers/devices_controller.create').as('device.create');
            router.delete('/:id', '#controllers/devices_controller.destroy').as('device.destroy');
        })
            .prefix('device');
        router.get('user/:id', '#controllers/users_controller.show').as('users.show');
        router.post('user/:id/update', '#controllers/users_controller.update').as('users.update');
        router.get('docs/webhook', '#controllers/docs_controller.webhook').as('docs.webhook');
        router
            .get('docs/api/message', '#controllers/docs_controller.api_message')
            .as('docs.api.message');
    })
        .use([middleware.auth(), middleware.wapi()]);
    router
        .group(() => {
        router.get('/login', '#controllers/auth_controller.login').as('login');
        router.post('/login/post', '#controllers/auth_controller.loginPost').as('login.post');
    })
        .use(middleware.guest());
    router.get('/logout', '#controllers/auth_controller.logout').as('logout').use(middleware.auth());
};
