diff options
Diffstat (limited to 'backend/src/index.js')
| -rw-r--r-- | backend/src/index.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/backend/src/index.js b/backend/src/index.js new file mode 100644 index 0000000..3dfe7a4 --- /dev/null +++ b/backend/src/index.js @@ -0,0 +1,27 @@ +import dotenv from "dotenv"; +import connectDB from "./config/database.js"; +import app from "./app.js"; + +dotenv.config({ + path: "./.env", +}); + +const PORT = process.env.PORT || 8000; + +const startServer = async () => { + try { + await connectDB(); + app.on('error', (error) => { + console.log('ERROR', error) + throw error + }) + + app.listen(PORT, () => { + console.log(`Server is running on port: ${PORT}`) + }) + } catch (error) { + console.log('Connection failed', error) + } +} + +startServer()
\ No newline at end of file |
