Open lancejpollard opened 6 hours ago
Hi @lancejpollard ! Yes, you can have. multiple aj
instances per app. We set it up like this so that we can have base rules that apply everywhere we use that instance, but then use withRule
to apply per route rules. You don't have to use the same aj
instance, but we do it because then we only need to instantiate the client once.
This has some performance benefits because we instantiate the bundled WebAssembly module when the client is created. There is also no shared local cache across instances so if a user gets blocked from one rule from one instance, there wouldn't be anything in the cache in another instance.
Does that help?
How does it know how to store permanently the rate limiting stuff? Can I have multiple
const aj = arcjet({...})
per project, like in theory one perroute.ts
?That way, I can say "for this route, rate limit like this, for that route, rate limit this other way", etc..
Will that just work?
All of the sample apps only have 1
aj
per app, so I'm not sure.