Skip to content

Commit bda391a

Browse files
Merge pull request #51 from Tebrihk/auto_reclaim
Auto-Reclaim Worker
2 parents 6e59240 + 80724cd commit bda391a

File tree

6 files changed

+582
-7
lines changed

6 files changed

+582
-7
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Algorand Network Configuration
2+
ALGOD_TOKEN=
3+
ALGOD_SERVER=https://testnet-api.algonode.cloud
4+
ALGOD_PORT=443
5+
6+
# Owner Account (for executing reclaim transactions)
7+
OWNER_MNEMONIC=

index.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
const express = require('express');
22
const cors = require('cors');
3+
const AutoReclaimWorker = require('./services/autoReclaimWorker');
4+
35
const app = express();
46
const port = 3000;
57

68
app.use(cors());
79
app.use(express.json());
810

911
app.get('/', (req, res) => {
10-
res.json({
11-
project: 'LeaseFlow Protocol',
12+
res.json({
13+
project: 'LeaseFlow Protocol',
1214
status: 'Active',
1315
contract_id: 'CAEGD57WVTVQSYWYB23AISBW334QO7WNA5XQ56S45GH6BP3D2AVHKUG4'
1416
});
1517
});
1618

19+
app.get('/status', (req, res) => {
20+
res.json({
21+
auto_reclaim_worker: 'Active',
22+
schedule: 'Every 10 minutes',
23+
last_check: new Date().toISOString()
24+
});
25+
});
26+
1727
if (require.main === module) {
18-
app.listen(port, () => {
19-
console.log(`LeaseFlow Backend listening at http://localhost:${port}`);
28+
const autoReclaimWorker = new AutoReclaimWorker();
29+
30+
autoReclaimWorker.initialize().then(() => {
31+
autoReclaimWorker.start();
32+
app.listen(port, () => {
33+
console.log(`LeaseFlow Backend listening at http://localhost:${port}`);
34+
console.log('Auto-Reclaim Worker started');
35+
});
36+
}).catch(error => {
37+
console.error('Failed to initialize Auto-Reclaim Worker:', error);
38+
process.exit(1);
2039
});
2140
}
2241

package-lock.json

Lines changed: 173 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
"test": "jest"
99
},
1010
"dependencies": {
11+
"algosdk": "^2.0.0",
1112
"cors": "^2.8.6",
1213
"dotenv": "^17.3.1",
13-
"express": "^5.2.1"
14+
"express": "^5.2.1",
15+
"node-cron": "^3.0.3"
1416
},
1517
"devDependencies": {
1618
"jest": "^30.3.0",
1719
"supertest": "^7.2.2"
1820
}
19-
}
21+
}

0 commit comments

Comments
 (0)