diff --git a/server/api-mongodb.js b/server/api-mongodb.js index be04975..25f9151 100644 --- a/server/api-mongodb.js +++ b/server/api-mongodb.js @@ -725,5 +725,18 @@ app.put('/api/auth/update-email', async (req, res) => { const PORT = process.env.PORT || 4000; const HOST = process.env.HOST || '0.0.0.0'; +if (import.meta.url === `file://${process.argv[1]}`) { + initDb() + .then(() => { + app.listen(PORT, HOST, () => { + console.log(`Backend API running on http://${HOST}:${PORT}`); + }); + }) + .catch((err) => { + console.error('Failed to initialize MongoDB in standalone mode:', err); + process.exit(1); + }); +} + export { initDb }; export default app;