diff --git a/src/api/produit/controllers/produit.ts b/src/api/produit/controllers/produit.ts index ac4c608..2426133 100644 --- a/src/api/produit/controllers/produit.ts +++ b/src/api/produit/controllers/produit.ts @@ -6,7 +6,7 @@ import { type Core, factories } from "@strapi/strapi"; import type { ExtendableContext } from "koa"; import Stripe from "stripe"; import { z } from "zod"; -import { io } from "../../.."; +// import { io } from "../../.."; const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: "2024-06-20", @@ -343,7 +343,7 @@ const createStripeCheckout = async ({ }, }); - io.to(existingOrder.user.id).emit("checkout", session.url); + // io.to(existingOrder.user.id).emit("checkout", session.url); await strapi.plugins.email.services.email.send({ to: existingOrder.user.email, from: "Strapi Ecommerce ", diff --git a/src/index.ts b/src/index.ts index afd3fc2..6a0fcd2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,12 @@ import type { Core } from "@strapi/strapi"; -import { Server } from "socket.io"; +// import { Server } from "socket.io"; -export const io = new Server(strapi.server.httpServer, { - cors: { - origin: `${process.env.FRONTEND_URL}`, - methods: ["GET", "POST"], - }, -}); +// export const io = new Server(strapi.server.httpServer, { +// cors: { +// origin: `${process.env.FRONTEND_URL}`, +// methods: ["GET", "POST"], +// }, +// }); export default { /** @@ -25,26 +25,26 @@ export default { * run jobs, or perform some special logic. */ bootstrap({ strapi }: { strapi: Core.Strapi }) { - io.use(async (socket, next) => { - try { - //Socket Authentication - const result = await strapi.plugins[ - "users-permissions" - ].services.jwt.verify(socket.handshake.query.token); + // io.use(async (socket, next) => { + // try { + // //Socket Authentication + // const result = await strapi.plugins[ + // "users-permissions" + // ].services.jwt.verify(socket.handshake.query.token); - console.log(result); - //Save the User ID to the socket connection - // @ts-ignore - socket.user = result.id; - next(); - } catch (error) { - console.log(error); - } - }).on("connection", (socket) => { - // @ts-ignore - socket.join(socket.user) - console.log(`socket connected ${socket.id}`); - socket.emit('confirmation') - }); + // console.log(result); + // //Save the User ID to the socket connection + // // @ts-ignore + // socket.user = result.id; + // next(); + // } catch (error) { + // console.log(error); + // } + // }).on("connection", (socket) => { + // // @ts-ignore + // socket.join(socket.user) + // console.log(`socket connected ${socket.id}`); + // socket.emit('confirmation') + // }); }, }; \ No newline at end of file