Skip to content

Commit

Permalink
#2692 look up nostrNpub in mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
K committed May 29, 2024
1 parent 008f5bf commit f135bdd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions modules/core/server/routes/core.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,31 @@ module.exports = function (app) {

app.route('/.well-known/nostr.json').get(function(req, res) {
// NIP05 work in progress, https://github.com/Trustroots/trustroots/issues/2692
res.json({
"names": {
"nostroots": "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e"
const mongoose = require('mongoose');
const User = mongoose.model('User');

const name = req.query.name;

User.findOne({ username: name }, function(err, user) {
if (err) {
res.status(500).send({ error: 'Internal server error' });
} else if (!user) {
res.status(404).send({ error: 'User not found' });
} else {
const nostrNpub = user.nostrNpub || 'User does not have a Nostr public key';
// const npubs = {
// "nostroots": "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e",
// "thefriendlyhost": "84d17317d46629037291f93df470c28082a874305e41c9465970659e9254edab"
// };
res.json({
"names": {
[name]: nostrNpub // TODO convert npub to hex
}
});

}
});

});

// Define application route
Expand Down

0 comments on commit f135bdd

Please sign in to comment.