-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
43 lines (35 loc) · 1.05 KB
/
server.js
File metadata and controls
43 lines (35 loc) · 1.05 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
42
require('dotenv').config();
const express = require('express');
const app = express();
const port = process.env.PORT || 6969;
const { addressWatcher } = require('./lib.js')
const fetch = require('node-fetch');
app.use(express.json());
app.post('/api/v2/watch-address', async (req, res) => {
const data = req.body;
const address = data.address;
const webhook = data.webhook;
const metadata = data.metadata ?? process.env.METADATA ?? "";
const amount = data.amount ?? 1;
const confirmations = data.confirmations ?? process.env.CONFIRMATIONS ?? 1;
const network = data.network ?? "testnet";
if (!address || !webhook || !metadata) {
return res.status(500).json({})
}
addressWatcher({
address,
network,
confirmations,
metadata,
amount,
webhook
}).then(async (response) => {
// console.log('Response received:', response);
}).catch((error) => {
console.error('Error:', error);;
});
return res.json({})
});
app.listen(port, () => {
console.log(`Mutinyhook app listening at http://localhost:${port}`);
});