• This project
    • Loading...
  • Sign in

fe / yohobuywap-node · Files

Go to a project

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Pipelines 0
  • Builds 0
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Members
  • Labels
  • Wiki
  • Forks
  • Network
  • Create a new issue
  • yohobuywap-node
  • doraemon
  • middleware
  • redis-url.js
  • 中间件
    c3fc0033
    by shijian
    2017-06-09 13:36:08 +0800  
    Browse Files
redis-url.js 565 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
'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();
        }
    };
};