build: move server.js into src directory

This commit is contained in:
Ryan Mwangi 2024-11-21 14:44:10 +03:00
parent ab09b64ed5
commit 42cbb15463
1 changed files with 22 additions and 0 deletions

22
src/server.js Normal file
View File

@ -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}`);
});