From 42cbb1546369dbfec81df6a3e6d871cb9d6a7cc0 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 21 Nov 2024 14:44:10 +0300 Subject: [PATCH] build: move server.js into src directory --- src/server.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/server.js diff --git a/src/server.js b/src/server.js new file mode 100644 index 0000000..9173a8d --- /dev/null +++ b/src/server.js @@ -0,0 +1,22 @@ +import express from 'express'; +import dotenv from 'dotenv'; +import path from 'path'; // Import the path module +import routes from './routes.js'; // Import routes from routes.js +import { validateEnvVariables } from './envValidator.js'; + +dotenv.config(); + +validateEnvVariables(); + +const app = express(); +const PORT = process.env.PORT || 3002; + +app.use(express.json()); + +app.use(express.static(path.join(process.cwd(), 'public'))); + +app.use('/', routes); + +app.listen(PORT, () => { + console.log(`Server is running on http://localhost:${PORT}`); +});