HotTRDealsBackend/routes/seller.routes.js
2026-01-23 17:28:21 +00:00

32 lines
781 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 authRequiredMiddleware = require("../middleware/authRequired.middleware")
const authOptionalMiddleware = require("../middleware/authOptional.middleware")
const { findSellerFromLink } = require("../services/seller.service")
router.post("/from-link", authRequiredMiddleware
, async (req, res) => {
try {
const sellerUrl = req.body.url
const Seller = await findSellerFromLink(sellerUrl)
if (!Seller) {
return res.json({
sellerId: -1,
sellerName: null,
})
}
return res.json({
id: Seller.id,
name: Seller.name,
})
} catch (e) {
console.error(e)
res.status(500).json({ error: "Sunucu hatası" })
}
})
module.exports = router