-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathdeploy.js
More file actions
41 lines (35 loc) Β· 1.55 KB
/
deploy.js
File metadata and controls
41 lines (35 loc) Β· 1.55 KB
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
// Deployment script for Vesting Vault Backend
const { exec } = require('child_process');
const express = require('express');
const cors = require('cors');
console.log('π Starting deployment process...');
// Install dependencies
exec('npm install', (error, stdout, stderr) => {
if (error) {
console.error(`β npm install failed: ${error}`);
return;
}
console.log('β
Dependencies installed');
// Start the Express server directly in this script for simplicity in deployment context
const app = express();
const port = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
// Placeholder for the new portfolio aggregation endpoint
app.get('/api/user/:address/portfolio', (req, res) => {
const { address } = req.params;
// Mock data for demonstration - replace with actual vault data
const mockVaults = [
{ type: 'advisor', locked: 80, claimable: 15 },
{ type: 'investor', locked: 20, claimable: 5 }
];
const total_locked = mockVaults.reduce((sum, vault) => sum + vault.locked, 0);
const total_claimable = mockVaults.reduce((sum, vault) => sum + vault.claimable, 0);
res.json({ total_locked, total_claimable, vaults: mockVaults, address });
});
app.listen(port, () => {
console.log(`π Vesting Vault API running on port ${port}`);
console.log('π Portfolio endpoint: http://localhost:3000/api/user/:address/portfolio');
console.log('π§ͺ Test with: node test-endpoint.js');
});
});