discord dashboard and discord js combo

What i normally do is, i got a protect middleware that runs on each request.

What does the middleware do?

  • it checks if JWT is present in cookie
  • if jwt is valid
  • gets user id from jwt then make request to database to get document with access token
  • then make request to discord api /@me endpoint to validate the access token is still valid or not.
So this happens on every endpoint, now, lets say someone goes to settings of a specific server, i will do following

  • protect middleware
  • make request to api to check if he has certain roles
  • make request to api to show all roles, another request to show all channels
  • some database requests to get some data
That's a lot of api calls right? Making the web slow. I thought of using discord js for its cache system (would no need to call dapi for checking roles,fetching roles and channels)


But that means running the server as well as bot in same process. What do you guys do?
Was this page helpful?