File size: 3,723 Bytes
757ca25
 
 
 
 
 
 
 
be76324
 
757ca25
 
 
be76324
 
757ca25
 
 
 
3d6c140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
757ca25
 
 
 
 
 
 
3d6c140
 
757ca25
 
3d6c140
 
 
 
 
757ca25
3d6c140
757ca25
 
3d6c140
 
 
757ca25
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const express = require('express');
const cors = require('cors');
const dotenv = require('dotenv');
const path = require('path');

dotenv.config();

const app = express();
// Use PORT from environment variable (for Hugging Face Spaces) or default to 3000
const PORT = process.env.PORT || 3000;

// Middleware
app.use(cors({
  // Updated CORS for Hugging Face Spaces deployment
  origin: ['http://localhost:8501', 'http://localhost:5173', 'http://frontend:5173', 'http://0.0.0.0:5173', 'https://n4sm-platform.hf.space', 'https://*.hf.space'],
  credentials: true
}));
app.use(express.json());

// In-memory data for prototype (no database required)
const missions = [
  {
    id: 1,
    name: 'Regenerative Economy',
    description: 'Climate, energy, biodiversity, jobs',
    objectives: 'Reduce carbon emissions, promote renewable energy, protect biodiversity, create green jobs',
    target_actors: 'Government agencies, environmental organizations, businesses',
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString()
  },
  {
    id: 2,
    name: 'Well-being for All',
    description: 'Health, education, social protection',
    objectives: 'Improve healthcare access, enhance education quality, strengthen social protection systems',
    target_actors: 'Healthcare providers, educational institutions, social services',
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString()
  },
  {
    id: 3,
    name: 'Just Digital Transition',
    description: 'Infrastructure, AI ethics and governance, data justice',
    objectives: 'Build equitable digital infrastructure, establish AI ethics guidelines, ensure data justice',
    target_actors: 'Tech companies, policymakers, civil society',
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString()
  },
  {
    id: 4,
    name: 'Equity and Inclusion',
    description: 'Gender, migration, race, intergenerational justice',
    objectives: 'Promote gender equality, protect migrant rights, combat racial discrimination, ensure intergenerational justice',
    target_actors: 'Human rights organizations, advocacy groups, government bodies',
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString()
  },
  {
    id: 5,
    name: 'Peace and Global Governance',
    description: 'Conflict, institutions, human rights',
    objectives: 'Prevent conflicts, strengthen international institutions, protect human rights',
    target_actors: 'International organizations, peacekeeping bodies, legal institutions',
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString()
  },
  {
    id: 6,
    name: 'Resilient Local Economies',
    description: 'Urban-rural linkages, food systems, circular economy',
    objectives: 'Strengthen urban-rural connections, develop sustainable food systems, promote circular economy practices',
    target_actors: 'Local governments, agricultural cooperatives, circular economy practitioners',
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString()
  }
];

// Routes
app.get('/api/health', (req, res) => {
  res.json({ status: 'OK', message: 'NextGen SDG Platform API is running' });
});

// Mission Hubs routes
app.get('/api/missions', (req, res) => {
  res.json(missions);
});

app.get('/api/missions/:id', (req, res) => {
  const { id } = req.params;
  const mission = missions.find(m => m.id === parseInt(id));
  if (!mission) {
    return res.status(404).json({ error: 'Mission not found' });
  }
  res.json(mission);
});

// Start server without database initialization
app.listen(PORT, '0.0.0.0', () => {
  console.log('Server running on port ' + PORT + ' (no database required)');
});