📜  嵌套装饰器获取请求 ip - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:49.581000             🧑  作者: Mango

代码示例1
import { createParamDecorator } from '@nestjs/common';

import * as requestIp from 'request-ip';

export const IpAddress = createParamDecorator((data, req) => {
    if (req.clientIp)
        return req.clientIp;
    return requestIp.getClientIp(req); // In case we forgot to include requestIp.mw() in main.ts
});