import app from '@adonisjs/core/services/app';
import router from '@adonisjs/core/services/router';
import limiter from '@adonisjs/limiter/services/main';
import { middleware } from './kernel.js';
import './lib/route_group_api_only.js';
import { AuthController } from './modules/auth/auth_provider.js';
import { AKJwtTokenType } from './modules/auth/jwt/jwt_service.js';
import AKEventController from './modules/events/event_controller.js';
import { AKAPIException } from './modules/exceptions/api_exception.js';
import AKHealthChecksController from './modules/health/health_checks_controller.js';
import AKOpenApiController from './modules/openapi/openapi_controller.js';
import { DeviceTokenController } from './modules/push_notifications/provider.js';
const authRateLimiter = limiter.define('auth', () => app.inTest
    ? limiter.noLimit()
    : limiter
        .allowRequests(10)
        .every('1 minute')
        .limitExceeded(() => {
        throw AKAPIException.tooManyRequests;
    }));
export var RouteName;
(function (RouteName) {
    RouteName["setPassword"] = "auth.verify-email";
    RouteName["openapiSpec"] = "openapi.spec";
})(RouteName || (RouteName = {}));
router
    .group(() => {
    router.post('/signup', [AuthController, 'signup']);
    router.post('/login', [AuthController, 'login']);
    router.get('/check', [AuthController, 'check']).use(middleware.auth());
    router
        .post('/refresh-tokens', [AuthController, 'refreshTokens'])
        .use(middleware.auth({ type: AKJwtTokenType.refresh }));
    router
        .post('/set-password', [AuthController, 'setPassword'])
        .use(middleware.auth({ type: [AKJwtTokenType.setPassword, AKJwtTokenType.access] }))
        .as(RouteName.setPassword);
    router.post('/forgot-password', [AuthController, 'forgotPassword']);
    router.post('/delete', [AuthController, 'delete']).use(middleware.auth());
})
    .prefix('/auth')
    .use(authRateLimiter)
    .openapi();
router
    .group(() => {
    router.post('/assign', [DeviceTokenController, 'assign']);
    router.post('/unassign', [DeviceTokenController, 'unassign']);
    router.post('/test', [DeviceTokenController, 'test']);
    router.get('/', [DeviceTokenController, 'list']);
})
    .prefix('/device-token')
    .use(middleware.auth())
    .openapi();
router.get('/health', [AKHealthChecksController]);
router.get('/openapi', [AKOpenApiController, 'spec']).as(RouteName.openapiSpec).openapi();
router.get('/docs', [AKOpenApiController, 'view']);
router.get('/event', [AKEventController, 'list']);
router
    .get('/event/email/preview/:event-name', [AKEventController, 'previewEmail'])
    .where('event-name', router.matchers.slug())
    .as('event.email.preview');
//# sourceMappingURL=routes.js.map