Authored by zhangwenxue

perf: lazy instantiation uuidv4

Showing 1 changed file with 4 additions and 2 deletions
... ... @@ -145,15 +145,17 @@ app.use((req, res, next) => {
// 独立的 UDID
if (!req.cookies.udid || (req.yoho.isApp && req.query.udid)) {
let udid = uuid.v4();
let udid;
if (req.yoho.isApp && req.query.udid) {
udid = req.query.udid;
} else {
udid = uuid.v4();
}
res.cookie('udid', udid, {
domain: 'yohobuy.com',
expires: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000)
expires: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000) // 1Year
});
req.cookies.udid = udid;
}
... ...