UNPKG

medusa-plugin-reviews-and-ratings

Version:

Medusa plugin to add product reviews and ratings functionality in the project.

51 lines (44 loc) 1.36 kB
const express = require("express"); const { GracefulShutdownServer } = require("medusa-core-utils"); const loaders = require("@medusajs/medusa/dist/loaders/index").default; (async () => { async function start() { const app = express(); const directory = process.cwd(); try { const { container } = await loaders({ directory, expressApp: app, }); const configModule = container.resolve("configModule"); const port = 8000; const server = GracefulShutdownServer.create( app.listen(8000, (err) => { if (err) { return; } console.log(`Server is ready on port: 9002`); }) ); // Handle graceful shutdown const gracefulShutDown = () => { server .shutdown() .then(() => { console.info("Gracefully stopping the server."); process.exit(0); }) .catch((e) => { console.error("Error received when shutting down the server.", e); process.exit(1); }); }; process.on("SIGTERM", gracefulShutDown); process.on("SIGINT", gracefulShutDown); } catch (err) { console.error("Error starting server", err); process.exit(1); } } await start(); })();