// routes/user.js
const express = require("express")
const router = express.Router()

const userService = require("../services/user.service")
const userProfileAdapter = require("../adapters/responses/userProfile.adapter")

router.get("/:userName", async (req, res) => {
  try {
    const data = await userService.getUserProfileByUsername(req.params.userName)
    res.json(userProfileAdapter.mapUserProfileToResponse(data))
  } catch (err) {
    console.error(err)
    const status = err.statusCode || 500
    res.status(status).json({ message: err.message || "Profil bilgileri alınamadı." })
  }
})

module.exports = router
