import { Router } from 'express'

import authRouter from './admin/auth.js'
import auditLogsRouter from './admin/audit-logs.js'
import dashboardRouter from './admin/dashboard.js'
import inventoryRouter from './admin/inventory.js'
import manualRedeemRouter from './admin/manual-redeem.js'
import messageDeliveriesRouter from './admin/message-deliveries.js'
import ordersRouter from './admin/orders.js'
import platformConfigRouter from './admin/platform-config.js'
import { requireAdminSession } from './admin/shared.js'
import tasksRouter from './admin/tasks.js'
import usersRouter from './admin/users.js'
import webhookEventsRouter from './admin/webhook-events.js'
import { buildNotFoundPayload } from '../utils/http.js'

const router = Router()

router.use(authRouter)
router.use(requireAdminSession)
router.use(dashboardRouter)
router.use(usersRouter)
router.use(auditLogsRouter)
router.use(platformConfigRouter)
router.use(ordersRouter)
router.use(tasksRouter)
router.use(manualRedeemRouter)
router.use(inventoryRouter)
router.use(messageDeliveriesRouter)
router.use(webhookEventsRouter)

router.use((req, res) => {
  res.status(404).json(buildNotFoundPayload(req))
})

export default router
