Skip to content

Commit

Permalink
Merge pull request #18 from KeychainMDIP/explore
Browse files Browse the repository at this point in the history
Explore
  • Loading branch information
macterra authored Mar 15, 2024
2 parents d5b7a76 + 76fee1c commit ef4b0d4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,32 @@ app.get('/did/:did', async (req, res) => {
}
});

app.get('/explore/:did', async (req, res) => {
try {
const doc = await gatekeeper.resolveDID(req.params.did, req.query.asof);
var hthead = '<html><body>';
hthead = hthead + '<h1>MDIP Network Explorer</h1>';
hthead = hthead + '<table><tr><td><h3>' + req.params.did + '</h3></td>';
var htdoc = JSON.stringify(doc,null,5);
htdoc = htdoc.replace(/"didDocument"/g, '"<b>didDocument</b>"');
htdoc = htdoc.replace(/"didDocumentMetadata"/g, '"<b>didDocumentMetadata</b>"');
htdoc = htdoc.replace(/"manifest"/g, '"<b>manifest</b>"');
htdoc = htdoc.replace(/"issuer"/g, '"<b>issuer</b>"');
htdoc = htdoc.replace(/"signer"/g, '"<b>signer</b>"');
htdoc = htdoc.replace(/"id"/g, '"<b>id</b>"');
htdoc = htdoc.replace(/"credential"/g, '"<b>credential</b>"');
htdoc = htdoc.replace(/"vault"/g, '"<b>vault</b>"');
htdoc = htdoc.replace(/"(did:mdip:.*)"/g, '"<a href="/explore/$1">$1</a>"');
htdoc = hthead + '<tr><td><hr><pre>' + htdoc + '</pre><hr></td></tr>';
var now = new Date();
htdoc = htdoc + '</table>' + now + '</body></html>';
res.send(htdoc);
} catch (error ) {
console.error(error);
res.status(500).send(error.toString());
}
});

app.post('/did/:did', async (req, res) => {
try {
const txn = req.body;
Expand Down

0 comments on commit ef4b0d4

Please sign in to comment.