AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
324 stars 101 forks source link

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

Open sudharsan-selvaraj opened 9 months ago

sudharsan-selvaraj commented 9 months ago

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 https://github.com/AppiumTestDistribution/appium-device-farm/issues/944#issuecomment-1869943589

afathonih commented 8 months ago

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());
}