-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (25 loc) · 757 Bytes
/
server.js
File metadata and controls
33 lines (25 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// backend/server.js
const express = require('express');
const cors = require('cors');
const dotenv = require('dotenv');
// Load environment variables
dotenv.config();
// Import route files
const formRoutes = require('./routes/formRoutes');
// Initialize express app
const app = express();
// Middleware
app.use(cors()); // Allow cross-origin requests from frontend
app.use(express.json()); // Parse JSON request bodies
// Routes
app.use('/api/forms', formRoutes);
// Basic route for testing
app.get('/', (req, res) => {
res.send('Backend server is running!');
});
// Configure port
const PORT = process.env.PORT || 5000;
// Start server
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});