Closed technophile-04 closed 6 months ago
If these libs works well with next api, we don't even need prod server, isn't it? Every app will have separate db. Or am I wrong? I'll check it next days
I actually tried using lowdb
2months ago with next api route but vercel don't allow write operation to file when you deploy to vercel :(
Yes, nextjs server functions on Vercel doesn't give you FS access. I think you'll have to do it with any kind of vercel storage (database, blob). https://vercel.com/docs/storage
I'm happy to deploy it to one of our boxes if that makes things easier for people.
you'all tell me!
I experimented spent countless hours fighting with cors, next api (new) bugs, vercel env vars bugs and built that mega app 🤦♂️ (see only app folder, underscoreds are for old pages api).
BE: https://github.com/rin-st/multisig-backend
changes needed to do in the challenge-6. https://github.com/scaffold-eth/se-2-challenges/compare/challenge-6-multisig...ch6-update-api?expand=1
I didn't create this pr since I think app should be deployed from some more official account 🙂 . Or for now it's ok?
KV hobby plan includes 30 000 requests per month and 3 000 per day and I think it's probably enough for now. https://vercel.com/docs/storage/vercel-kv/usage-and-pricing . But if someone forget to close pool page it will send request every second. What do you think? Do we need pro plan?
Added env example to BE repo. You can use your storage vars to test it locally or pm me for my
I experimented spent countless hours fighting with cors, next api (new) bugs, vercel env vars bugs and built that mega app 🤦♂️ (see only app folder, underscoreds are for old pages api).
Thanks so much Rinat for giving it a shot !!! Just tested it out and works great !!
KV hobby plan includes 30 000 requests per month and 3 000 per day and I think it's probably enough for now. https://vercel.com/docs/storage/vercel-kv/usage-and-pricing . But if someone forget to close pool page it will send request every second. What do you think? Do we need pro plan?
Just a thought :
I see in https://github.com/rin-st/multisig-backend you also added the code for pages route api, what if we add that code in this repo too and update readme with :
(Optional Section(Recommended): Your own server and DB) : I think the steps are prettry straight forward,
yarn vercel --prod
Thanks Shiv! 🙏
I see in https://github.com/rin-st/multisig-backend you also added the code for pages route api, what if we add that code in this repo too and update readme with :
(Optional Section(Recommended): Your own server and DB) : I think the steps are prettry straight forward,
- Create and get the ENV variables from vercel KV store
- paste them into your newly deployed vercel projects environments
- Update the prod server URL and again run
yarn vercel --prod
Probably, but
So for me it not so recommended :). I think we can add it and test if it works for most of the people, but we need to be ready to answer why it won't work)
cc @Pabl0cks I think this thread is interesting to Pablo too
Awesome job @rin-st!! I've tried your deployed backend and it's working great, TYSM! 🙌
So for me it not so recommended :). I think we can add it and test if it works for most of the people, but we need to be ready to answer why it won't work)
Without testing it and considering @rin-st's points, I tend to agree with him that it's probably not a good idea to recommend. However, I can give it a try tomorrow and check how many problems I encounter myself.
If we finally decide to just use our deployed backend, we can have the self-deployed backend as a plan B in case we start encountering problems due to reaching Vercel limits.
Oh I see, totally agree with you all !! I think it's not at all worth it since it's not too straightforward and also sometimes even if you do each step correctly things might still not work, so let's drop it 🙌
So just thinking of deploying our api to prod how are we going about it ?
Merge Rinat's _pages/api into Multsig chall branch and host it on vercel from BG account ?
Or a clone/fork of Rinat's repo into new repo under Scaffold-eth organization and then connecting it to vercel ?
It will be very hard to host Next api on our custom box right, so we need to host it on vercel only right ?
Thanks @rin-st for working on this. CORS errors are painful haha. And thanks all for testing and giving your take on it.
I initially thought that we were going to have a simple nodejs server deployed in the BG boxes (like the autograder), but having it like this will work too.
Merge Rinat's _pages/api into Multsig chall branch and host it on vercel from BG account ?
I'd do this only if we suggest (as extra) to people to set their own server/db (as Shiv suggested). If not, I don't see the value in polluting the challenge branch... and I'll go with:
Or a clone/fork of Rinat's repo into new repo under Scaffold-eth organization and then connecting it to vercel ?
What do you all think?
I think we need to create separate repo since imho users don't need to deploy their db and hence don't that code. We can give them link to that repo if they want to play with db too.
Regarding express server with saving to variable (like in backend-local) I think it should work too, since it already worked for months (or it was another version of managing data?). But vercel version seems more relevant and stable, if we'll not meet limits. I believe to meet free limit we need tens of users per month
Thanks Rinat! After thinking about it a bit more. My thoughts:
Vercel / NextJS option only makes sense to me if we want to share it with people, and suggest them to use it. If not, why have a whole NextJS set up just for a simple backend thing (is it a bit overkill, no?). The only thing I like is the automatic deployment stuff (but I don't think we'd change this a lot)
NodeJS/Express server: it could be a single file, and instead of using a variable storage (a bit hacky) we could use the "json database" (Shiv mentioned some of them in the OP) which is still hacky haha but a bit better and nothing happens if the server resets.
Thoughts?
Yup I agree, I think having a simple express server file is the way to go since its simple and works pretty nicely for our needs 🙌
Vercel / NextJS option only makes sense to me if we want to share it with people, and suggest them to use it. If not, why have a whole NextJS set up just for a simple backend thing (is it a bit overkill, no?). The only thing I like is the automatic deployment stuff (but I don't think we'd change this a lot)
Yes, it's overkill for sure. I used it because we started to discuss about Next and also you mentioned Vercel storage. So I forgot about original post 😄 🤦♂️ .
NodeJS/Express server: it could be a single file, and instead of using a variable storage (a bit hacky) we could use the "json database" (Shiv mentioned some of them in the OP) which is still hacky haha but a bit better and nothing happens if the server resets.
Agree, it's better and easier. Let's implement it
Changed https://github.com/rin-st/multisig-backend so now it uses express and lowdb.
Deployed it to render, so you can test it - change POOL_SERVER_URL
in challenge 6 to https://multisig-backend.onrender.com/ (with slash at the end)
Been playing a bit with your deployed POOL_SERVER_URL
on render and it's working great. Will do more tests tomorrow 🙌
I think when render spins down the server, the old transactions disappear. When I tried to test today, after it relaunched, my Pool was empty, and only new transactions appear. My test url => https://challenge-6-multisig.vercel.app/
I think when render spins down the server, the old transactions disappear. When I tried to test today, after it relaunched, my Pool was empty, and only new transactions appear. My test url => https://challenge-6-multisig.vercel.app/
Yes, it behaves that way on render and free plans of other services. I deployed it here just for testing purposes. As I understand we'll not have that problem on bg boxes. But I don't know for sure what are that boxes and how they work
Good stuff @rin-st Thanks!
Decided to copy Rinat's work to https://github.com/scaffold-eth/se-2-challenges/tree/multisig-backend. We could do it in another repo too, but since we already have this branch model (each branch is independent, not meant to be merged to main) I thought it made sense.
Could you add a simple README to it? Just explain what it's and how to run it (even if it's simple, future Carlos will thank you :P)
As I understand we'll not have that problem on bg boxes. But I don't know for sure what are that boxes and how they work
Yep. They are EC2 instances so no issues with the file storage.
Could you add a simple README to it? Just explain what it's and how to run it (even if it's simple, future Carlos will thank you :P)
Generated simple readme using gpt and edited it a little bit 🙂 https://github.com/scaffold-eth/se-2-challenges/tree/multisig-backend
If you think we need to add live-reloading for dev mode we can add it like here https://github.com/scaffold-eth/se-2-challenges/pull/122
Amazing! I use ChatGPT a lot for that stuff too :D
Thanks @rin-st !
I spent some time this morning with Shiv making some tweaks to the code (Basically https support) and deploying it to the BG EC2 instance. Austin still needs to configure some port stuff.
I'll post it here when is live and we can close this.
This is live on: https://backend.multisig.holdings:49832/
Could you guys test? I guess we'd also need to add that URL to the challenge readme/.env.example, right?
deploying cost to sepolia is ~0.8 sep 😮 . I'll wait a little bit 😄
But tested it locally and works great! And looks like nothing to break here
Not sure regarding .env
file, since it's already in source code. And it will require additional step for creating .env
and adding that variable for every user. So it requires to add that address to readme and it will not be hidden anyway
Not sure regarding .env file, since it's already in source code. And it will require additional step for creating .env and adding that variable for every user. So it requires to add that address to readme and it will not be hidden anyway
Oh, perfect. Directly in the code works.
deploying cost to sepolia is ~0.8 sep 😮 . I'll wait a little bit 😄
Feel free to close this when you test it.
Thanks!
Feel free to close this when you test it.
It's working great to me also, will add a reference in Readme 🙌
Closing!
Description :
Currently, we are storing the backend state in a variable kind of hacky, I think it will be great if we use JSON file as DB.
This won't make much of a difference while doing the challenge locally, but we are planning to connect this repo's challenge 6
backend-local
to our box where the prod server will live and it's good to have some kind of persistent storage there.Some helper libraries :