don't hardcode api and web endpoints

This commit is contained in:
Pablo Martin 2025-03-31 16:27:21 +02:00
parent 873493f697
commit 72594c34c1
4 changed files with 13 additions and 5 deletions

View file

@ -2,14 +2,20 @@ const DEFAULT_SESSION_DURATION_SECONDS = 60 * 60 * 24 * 30;
const DEFAULT_NOSTR_CHALLENGE_DURATION_SECONDS = 60 * 60 * 24 * 30;
const DEFAULT_REDIRECT_DELAY = 3 * 1000; // 3seconds times milliseconds;
const API_ROOT = '/api'
const API_PATHS = {
createProfile: '/createProfile',
home: '/home',
offer: API_ROOT + '/offer'
};
const WEB_PATHS = {
home: '/home',
createProfile: '/createProfile',
}
module.exports = {
DEFAULT_SESSION_DURATION_SECONDS,
DEFAULT_NOSTR_CHALLENGE_DURATION_SECONDS,
API_PATHS,
WEB_PATHS,
DEFAULT_REDIRECT_DELAY,
};

View file

@ -24,7 +24,7 @@ const invitesFunction = () => {
if (verifyResponse.ok) {
signUpSuccessPopup.display();
setTimeout(() => {
window.location.href = constants.API_PATHS.createProfile;
window.location.href = constants.WEB_PATHS.createProfile;
}, constants.DEFAULT_REDIRECT_DELAY);
}
},

View file

@ -38,7 +38,7 @@ const loginFunction = () => {
nostrLoginButton.disable();
successPopup.display();
setTimeout(() => {
window.location.href = constants.API_PATHS.home;
window.location.href = constants.WEB_PATHS.home;
}, constants.DEFAULT_REDIRECT_DELAY);
}
},

View file

@ -1,5 +1,7 @@
const constants = require('../../constants');
const createOffer = async (offerDetails) => {
await fetch('/api/offer', {
await fetch(constants.API_PATHS.offer, {
method: 'POST',
headers: {
'Content-Type': 'application/json',