Skip to content

Commit

Permalink
feat: address/label lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
charmful0x authored Oct 24, 2022
1 parent 314660c commit 5c5e16c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ app.get("/stats", async (req, res) => {
res.send(jsonRes);
});

app.get("/profile/:label_addr", async (req, res) => {
res.setHeader("Content-Type", "application/json");

const encodedState = await getAnsState();
const decodedState = JSON.parse(base64url.decode(encodedState));
const label_addr = req.params.label_addr;

const profile =
label_addr.length === 43
? decodedState?.res?.find((label) => label.user === label_addr)
: decodedState?.res?.find((label) => label.currentLabel === label_addr);

res.send(profile);
});

app.listen(port, async () => {
await polling();
console.log(`listening at PORT: ${port}`);
Expand Down

0 comments on commit 5c5e16c

Please sign in to comment.