This commit is contained in:
olivermrbl
2021-08-26 13:57:30 +02:00
parent 5150a6b4d9
commit b1132eec23
2 changed files with 25 additions and 36 deletions

View File

@@ -0,0 +1,25 @@
import { Router } from "express"
import bodyParser from "body-parser"
import jwt from "jsonwebtoken"
const app = Router()
export default () => {
app.get("/wishlists/:token", bodyParser.json(), async (req, res) => {
const { token } = req.params
const JWT_SECRET = process.env.JWT_SECRET || ""
// decorde token with decode = jwt.decode(token, secret)
const decode = jwt.decode(token, JWT_SECRET)
console.log(decode)
// fetch customer.retrieve(decode.customer_id)
// get customer.metadata.wishlist
// respond with
// wishlist
// first_name
res.sendStatus(200)
})
return app
}

View File

@@ -1,36 +0,0 @@
import { Router } from "express"
import jwt from "jsonwebtoken"
import cors from "cors"
import { getConfigFile } from "medusa-core-utils"
export default () => {
const app = Router()
const JWT_SECRET = process.env.JWT_SECRET || ""
// const { configModule } = getConfigFile(rootDirectory, "medusa-config")
// const { projectConfig } = configModule
// const corsOptions = {
// origin: projectConfig.store_cors.split(","),
// credentials: true,
// }
// console.log(corsOptions)
// app.options("/wishlists/:token", cors(corsOptions))
app.get("/wishlists/:token", async (req, res) => {
const { token } = req.params
// decorde token with decode = jwt.decode(token, secret)
const decode = jwt.decode(token, JWT_SECRET)
console.log(decode)
// fetch customer.retrieve(decode.customer_id)
// get customer.metadata.wishlist
// respond with
// wishlist
// first_name
res.json("200")
})
return app
}