import {
  mapProductForApi,
  parseMaterialsInput,
  slugify,
} from './api/_product-helpers.js'
import { registerAdminGalleryRoutes } from './api/admin-gallery.js'
import { registerAdminCategoryRoutes } from './api/admin-categories.js'
import { registerCatalogSliderRoutes } from './api/catalog-slider.js'
import { registerAdminOrderRoutes } from './api/admin-orders.js'
import { registerAdminProductRoutes } from './api/admin-products.js'
import { registerAdminReviewRoutes } from './api/admin-reviews.js'
import { registerAdminUserRoutes } from './api/admin-users.js'
import { registerInfoPageRoutes } from './api/info-page.js'
import { registerPublicCatalogRoutes } from './api/public-catalog.js'
import { registerPublicReviewRoutes } from './api/public-reviews.js'

export async function registerApiRoutes(fastify) {
  fastify.decorate('slugify', slugify)
  fastify.decorate('parseMaterialsInput', parseMaterialsInput)
  fastify.decorate('mapProductForApi', mapProductForApi)

  await registerPublicCatalogRoutes(fastify)
  await registerPublicReviewRoutes(fastify)
  await registerInfoPageRoutes(fastify)
  await registerCatalogSliderRoutes(fastify)

  await registerAdminProductRoutes(fastify)
  await registerAdminGalleryRoutes(fastify)
  await registerAdminCategoryRoutes(fastify)
  await registerAdminOrderRoutes(fastify)
  await registerAdminReviewRoutes(fastify)
  await registerAdminUserRoutes(fastify)
}

