-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (25 loc) · 990 Bytes
/
server.js
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
const express = require('express');
const bodyParser = require('body-parser');
require('dotenv').config();
const app = express();
app.use(bodyParser.json());
// Define a simple route to verify the server is working
app.get('/', (req, res) => {
res.send('Self-Governance App Backend is Running!');
});
// Example endpoint to get all proposals
app.get('/api/proposals', (req, res) => {
// This would query the database or blockchain for proposals
res.json({
proposals: [
{ id: 1, title: 'Universal Healthcare', description: 'Implement a universal healthcare system.' },
{ id: 2, title: 'Clean Energy Act', description: 'Pass a national clean energy bill.' }
]
});
});
// Start the server
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
Explanation: This basic Express server handles API routes. Later, we’ll add routes for creating proposals, voting, and interacting with the blockchain.