# Applying Middleware

now we can apply the our middleware to `deviceRouter`

{% code title="deviceRouter.js" %}
```javascript
import express from 'express';
import Validator from 'xpress-req-validator';

import config from './config';

const validator = new Validator(config);
const deviceRouter = express.Router();
deviceRouter.use(validator.init());

deviceRouter.post('/device', ()=> {});
```
{% endcode %}
