Compare commits
2 commits
ab09b64ed5
...
bafb997fa6
Author | SHA1 | Date | |
---|---|---|---|
bafb997fa6 | |||
42cbb15463 |
2 changed files with 23 additions and 1 deletions
|
@ -6,7 +6,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node server.js"
|
"start": "node src/server.js"
|
||||||
},
|
},
|
||||||
"author": "ryan",
|
"author": "ryan",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|
22
src/server.js
Normal file
22
src/server.js
Normal 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}`);
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue