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

Add types for all API's to make express request and response type safe #945

Open
sudharsan-selvaraj opened this issue Dec 27, 2023 · 1 comment

Comments

@sudharsan-selvaraj
Copy link
Member

Would be very nice to add types for the new API to avoid accidentally breaking the code in the future. At least on the responses part.

Ref: https://plainenglish.io/blog/typed-express-request-and-response-with-typescript

Originally posted by @afathonih in #944 (comment)

@afathonih
Copy link
Contributor

Turned out a lot easier as we can just do it without custom typing:

async function getQueuedSessionLength(request: Request<void>, response: Response<number>) {
  response.json((await ADTDatabase.PendingSessionsModel).chain().find().count());
}

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

No branches or pull requests

2 participants