Extend Express Request object using Typescript

Create a file custom.d.ts and make sure to include it in your tsconfig.json's files-section if any. The contents can look as follows:

declare namespace Express {
   export interface Request {
      tenant?: string

This will allow you to, at any point in your code, use something like this:

router.use((req, res, next) => {
    req.tenant = 'tenant-X'

router.get('/whichTenant', (req, res) => {
    res.status(200).send('This is your tenant: '+req.tenant)