moved into src
This commit is contained in:
parent
ca2b2f2e8d
commit
d8a72e5978
6 changed files with 4 additions and 3 deletions
61
src/views/index.ejs
Normal file
61
src/views/index.ejs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Hello World</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Hello World! We're live</h1>
|
||||
<p>Now this is some production grade stuff, baby!</p>
|
||||
<p>Your session's UUID: <%= uuid %>
|
||||
</p>
|
||||
<p id="pubkey-p" style="display:none">And your pubkey is: <span id="pubkey-span"></span></p>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
window.onload = function () {
|
||||
setTimeout(function () {
|
||||
console.log("This code runs 2 seconds after the window has loaded.");
|
||||
const npub = window.nostr.getPublicKey();
|
||||
let pubkeyP = document.querySelector("#pubkey-p");
|
||||
let pubkeySpan = document.querySelector("#pubkey-span");
|
||||
|
||||
npub.then(async function (npub) {
|
||||
console.log(npub);
|
||||
pubkeyP.style.display = "block";
|
||||
pubkeySpan.innerText = npub;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/session-npubbed', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"npub": npub
|
||||
})
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.log('SessionNpubbed record created successfully:', data);
|
||||
} else {
|
||||
const error = await response.json();
|
||||
console.error('Failed to create sessionNpubbed record:', error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('An error occurred:', error);
|
||||
}
|
||||
}
|
||||
|
||||
)
|
||||
}, 2000);
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue