-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
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. |
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) %>;
Some new features for the playground: