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

[RFC] Blitz App Architecture #7

Merged
merged 14 commits into from
Apr 2, 2020
Merged

[RFC] Blitz App Architecture #7

merged 14 commits into from
Apr 2, 2020

Conversation

flybayer
Copy link
Member

Woohoo! Finally a draft for the architecture RFC! Let's make this as good as we possibly can before posting publicly!

View Rendered

@merelinguist
Copy link

What are the benefits of react-query over, say, swr?

@flybayer
Copy link
Member Author

flybayer commented Apr 1, 2020

@merelinguist good question!

Their docs do a good job of answering this. Click on the "How is this different from Zeit's SWR?" toggle that's just under the Quick Features section.

We don't have to use react-query. We can use anything that does what we need or even write our own.

@flybayer flybayer merged commit d4d10df into master Apr 2, 2020
@flybayer flybayer deleted the flybayer-patch-2 branch April 2, 2020 12:08
@rishabhpoddar
Copy link
Collaborator

Seems awesome! For middlewares, we should allow for the following:

  • Apply one middleware to all or a few APIs
  • Allow for arbitrary params (along with req and res to be passed to the middleware). If present, the extra params must be passed on a per API basis.

One use case of this is for authorisation. We can create a middleware that takes req, res and requiredRole as an input. If the user calling that API does not have that requiredRole, then the middleware throws an appropriate error. So here, we want to be able to specify, on a per API basis, what the requiredRole is, and we also want some APIs to not use this middleware.

Now even if the above example is not how authorisation will work in Blitz, there could be other use cases for this kind of behaviour. NodeJS allows for this level of control as well.

@rishabhpoddar
Copy link
Collaborator

We should define what the various default properties are in the Context object vs in the req object. For example, in the Context object, we will have an optional Session object while in the req object, we will have the request URL and headers.

If a user is creating a middleware, how should they decide is something should go in the req object, or Context?

@rishabhpoddar
Copy link
Collaborator

We should also define how the user can do database transactions. This is important since any serious app will require many transactions in them. One more important aspect of transactions is to also be able to specify the isolation level on a per transaction basis (the default one works for most cases).

@flybayer
Copy link
Member Author

flybayer commented Apr 5, 2020

@rishabhpoddar great thoughts!

But can you please post all those in the public RFC instead of here in the drafts repo? Then everyone else will see your comments and can chime in too! :)

@blitz-js blitz-js locked as resolved and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants