# TypeScript + Express middleware types

**URL:** <https://community.auth0.com/t/typescript-express-middleware-types/58194>\
**Category:** Get Help\
**Created:** [February 20, 2021, 4:43am UTC](https://community.auth0.com/t/typescript-express-middleware-types/58194 "2021-02-20T04:43:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjamnkovacs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/benjamnkovacs/32/25832_2.png) [@benjamnkovacs](https://community.auth0.com/u/benjamnkovacs)\
**Post date:** [February 20, 2021, 4:43am UTC](https://community.auth0.com/t/typescript-express-middleware-types/58194/1 "2021-02-20T04:43:24Z")

</div>

- **Which SDK this is regarding:** express-openid-connect
- **SDK Version:** 2.2.1
- **Platform Version:** Node 14.15.5

**Context:**  
I am building an express app, I plan to separate it conceptually into two components

1. Landing page
2. Admin

Admin requires auth, while the landing page doesn’t. I am using the express Router to configure my routes. So I construct two new routers which can accept middleware just as the express app itself can. For the admin section I am able to gate it’s routes using the `requiresAuth` middleware exposed by you fine folk!!

**Problem**  
When I try and access `req.ocid.user` TypeScript doesn’t recognize the field `oidc`

My express app is setup as follows (cut down to only include relevant code):

```
import express from 'express';
import { auth } from 'express-openid-connect';

import { funnelRouter, adminRouter } from './routes';

const app = express();

app.use(auth(AUTH_CONFIG));
app.use('/', funnelRouter);
app.use('/admin', adminRouter);

export const start = () => {
  app.listen(PORT, () => {
    console.log(`Listening on localhost:${PORT}`);
  });
};

```

AUTH\_CONFIG

```
export const AUTH_CONFIG = {
  authRequired: false,
  auth0Logout: true,
  secret: process.env.AUTH_0_SECRET,
  baseURL: 'http://localhost:3000',
  clientID: my-id,
  issuerBaseURL: 'my-url',
};

```

Admin router

```
import express from 'express';
import { requiresAuth } from 'express-openid-connect';

const router = express.Router();

router.use(requiresAuth());

router.get('/', (req, res) => {
  res.send(JSON.stringify(req.oidc.user));
});

export default router;

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 22, 2021, 9:04pm UTC](https://community.auth0.com/t/typescript-express-middleware-types/58194/3 "2021-02-22T21:04:22Z")

</div>

> [@benjamnkovacs](#):
>
> req.ocid.user

Hi @benjamnkovacs ,

Just want to make sure this isn’t a mistype, as you have `ocid` and it should be `oidc`

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 27, 2021, 9:08pm UTC](https://community.auth0.com/t/typescript-express-middleware-types/58194/4 "2021-04-27T21:08:37Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
