Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create invoice #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

majdamasoud
Copy link

Some new features for the playground:

  • Create custom invoices
  • Have custom invoices show up when you click pay an invoice, and by clicking on them you can pay them
  • Console now no longer clears when refreshed, theres a button that can do that if you want
  • newest responses goes at the top of console

Screen Shot 2021-12-27 at 4 23 36 PM

Screen Shot 2021-12-27 at 4 23 50 PM

@bumi
Copy link
Contributor

bumi commented Jan 7, 2022

Thanks for the PR!

as we plan to provide this as a hosted version for people to test on https://website.regtest.getalby.com/ I somehow think the persistence is a bit confusing.
People will then see the console output and invoices from others.
why did you want to persist those and not only just show them on the site? or maybe within the browser using local storage?

@bumi
Copy link
Contributor

bumi commented Feb 6, 2022

hej, wanted to follow up on this. let me know if I can be of any help.

amount: req.body.amount,
data: invoice.data
}
newInvoice = newInvoiceObj;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not use global variables.
If I understand your code correct, then here a global variable is defined with an invoice object. Then the user is redirected to / on / a template is rendered that uses that global variable and then that global variable is set to null again.

But think about what happens if two or more users use the app at the same time. Then that one global variable is shared among all users and they overwrite each other.

I think generally no global variables should be used. HTTP is stateless and when build web apps we need to respect that.

}

let newInvoice = '<%- JSON.stringify(newInvoice) %>';
newInvoice = JSON.parse(newInvoice);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something like this should be good enough:
let newInvoice = <%- JSON.stringify(newInvoice) %>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants