-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (64 loc) · 2.32 KB
/
app.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
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
const express = require('express');
const dotenv = require('dotenv').config();
const axios = require('axios');
const app = express();
const PORT = 5000;
app.get('/users/:alias', async (req, res)=>{
res.status(200);
axios.defaults.headers.get['Content-Type'] = 'application/json';
var query= {
"filter": {
"filterColumn": "alias",
"filterValue": req.params.alias
}
};
console.log(encodeURI(JSON.stringify(query)));
const response = await axios.get(`https://app.dynamicauth.com/api/v0/environments/74bd1bf3-bdd5-43ba-8ea3-e744ebfaaaf2/users?filter=${encodeURIComponent(JSON.stringify(query.filter))}`, {
headers: {
Authorization: `Bearer ${process.env.DYNAMIC_API_KEY}`
}
});
//create some dummy data to insert into the metadata field
response.data.users[0].metadata = {
"userId": "c25123ec-62aa-4534-8153-8a68382c3df2",
"alias": "inde",
"bio": "This is a sample bio.",
"profileImage": "https://api.dicebear.com/8.x/notionists/svg?seed="+req.params.alias,
"project": [{
"name": "Sample Project",
"description": "This is a sample project description.",
"pages": "100",
"type": "PDF",
"tags": ["sample", "dummy", "data"],
"creationDate": "2023-05-15T10:30:00Z",
"author": [
{"AuthorName": "John Doe"},
{"AuthorName": "Jane Smith"}
],
"release": [
{
"chain": "Ethereum",
"chainid": "1",
"format": "ERC721",
"contractaddress": "0x1234567890123456789012345678901234567890",
"tokenid": 123
},
{
"chain": "Ethereum",
"chainid": "1",
"format": "ERC1155",
"contractaddress": "0x0987654321098765432109876543210987654321",
"tokenid": 456
}
]
}]
};
res.send(JSON.stringify(response.data.users[0].metadata));
});
app.listen(PORT, (error) =>{
if(!error)
console.log("Server is Successfully Running and App is listening on port "+ PORT);
else
console.log("Error occurred, server can't start", error);
}
);