redis-url.js
565 Bytes
'use strict';
const tdk = require('../../utils/getTDK');
module.exports = () => {
return (req, res, next) => {
if (!req.xhr) {
tdk('url', `${req.hostname}${req.originalUrl}`, req).then(TDKObj =>{
if (TDKObj[0]) {
req.tdk = {
title: TDKObj[1],
keywords: TDKObj[2],
description: TDKObj[3]
};
}
next();
});
} else {
return next();
}
};
};