diff --git a/packages/medusa-plugin-wishlist/src/api/index.js b/packages/medusa-plugin-wishlist/src/api/index.js new file mode 100644 index 0000000000..413cac01e5 --- /dev/null +++ b/packages/medusa-plugin-wishlist/src/api/index.js @@ -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 +} diff --git a/packages/medusa-plugin-wishlist/src/api/store/index.js b/packages/medusa-plugin-wishlist/src/api/store/index.js deleted file mode 100644 index ef5a12687d..0000000000 --- a/packages/medusa-plugin-wishlist/src/api/store/index.js +++ /dev/null @@ -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 -}