Spaces:
Sleeping
Sleeping
import { Injectable, NestMiddleware } from '@nestjs/common'; | |
import { Request, Response, NextFunction } from 'express'; | |
() | |
export class DeviceInfoMiddleware implements NestMiddleware { | |
use(req: Request, res: Response, next: NextFunction) { | |
const deviceInfo = { | |
ip: req.ip, | |
userAgent: req.headers['user-agent'], | |
}; | |
req['device-info'] = deviceInfo; | |
next(); | |
} | |
} | |