-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
23 lines (17 loc) · 1.06 KB
/
Copy pathserver.js
File metadata and controls
23 lines (17 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require('express');
const cors = require('cors');
const path = require('path');
const productsRouter = require('./src/routes/products.route');
const app = express();
const PORT = process.env.PORT || 3000;
// ── Middleware ────────────────────────────────────────────────
app.use(cors());
app.use(express.json());
// ── API routes ───────────────────────────────────────────────
app.use('/api/products', productsRouter);
// ── Static files (HTML template) ────────────────────────────
app.use(express.static(path.join(__dirname)));
// ── Start ────────────────────────────────────────────────────
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});