HotTRDealsBackend/routes/seller/seller.routes.js
2026-01-20 12:16:14 +00:00

35 lines
782 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const express = require("express")
const router = express.Router()
const authMiddleware = require("../../middleware/authMiddleware")
const { findCompanyFromLink } = require("../../services/seller/seller.service")
router.post("/from-link", authMiddleware, async (req, res) => {
try {
const seller = req.body.seller
if (!seller) {
return res.status(400).json({ error: "URL gerekli" })
}
const company = await findCompanyFromLink(url)
if (!company) {
return res.json({
sellerId: -1,
sellerName: null,
})
}
return res.json({
sellerId: company.id,
sellerName: company.name,
})
} catch (e) {
console.error(e)
res.status(500).json({ error: "Sunucu hatası" })
}
})
module.exports = router