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

Make bot respond to api requests without waiting for discord. #11

Merged
merged 2 commits into from
Jul 14, 2021

Conversation

JasirZaeem
Copy link
Member

@JasirZaeem JasirZaeem commented Jul 12, 2021

The current uses of the bot don't require waiting for a response from discord that the message has been sent. This PR changes the default behaviour of api routes to respond with a 202 Created right after a request to send a message to discord has started without waiting for it to complete. An additional, optional, boolean parameter includeDetails can be passed in the JSON body of the request if the caller requires to wait for the discord message to be created and receive the id of the created message back.

An additional change made in this PR is that the errorHandler middleware now logs the errors using console.error (to be replaced with winston) and it responds to the client with the error only after checking res.headersSend i.e. it won't sent a response if a route has already done so.

TODO

  • Update api doc once merged

@JasirZaeem JasirZaeem merged commit 11a9884 into garageScript:main Jul 14, 2021
@JasirZaeem JasirZaeem deleted the respnd-before-discord branch July 14, 2021 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant