首页 > 解决方案 > 编写导出函数的更好方法是什么?

问题描述

问题是veracode安全扫描它在代码中创建缺陷所以在编译后它被转换为JS并且因为“使用严格”检查它不喜欢导出为全局变量我相信有没有办法更好地编写这个函数避免安全扫描问题?

main.ts

    import * as Store from "../common/store";
    export function authenticate(req: Request, res: Response) {
    const app = Store.getInstance('sp');
    app.Profile.authenticate(req.body, function(result) {
        res.send(result);
    });
}

main.js 编译后

function authenticate(req, res) {
    const app = Store.getInstance('sp');
    app.Profile.authenticate(req.body, function (result) {
        res.send(result);
    });
}
exports.authenticate = authenticate;

标签: javascriptnode.jstypescriptsecurityveracode

解决方案


推荐阅读