title: What is the best way to automatically validate requests using Typescript?
body: <p>I would like to use Typescript interfaces to easily validate backend requests. Is there a way to make it happen? Example of what I would love to do:</p>
  
  <pre><code>import { Request, Response } from 'express'
  
  interface AuthenticateParams {
      email: string
      password: string
  }
  
  type AuthenticationRequest = Request &amp; {body: AuthenticateParams}
  
  const authenticate = async (req: AuthenticationRequest, res: Response) =&gt; {
      if (typeof req.body !== AuthenticateParams) res.status(400).send('Invalid body')
  
      // DO STUFF
      let stuff
  
      res.status(200).send(stuff)
  }
  
  export default authenticate
  </code></pre>