Authored by 陈峰

commit

@@ -25,7 +25,7 @@ export const createApi = () => { @@ -25,7 +25,7 @@ export const createApi = () => {
25 url, 25 url,
26 params, 26 params,
27 method: 'get', 27 method: 'get',
28 - }), options); 28 + }, options));
29 }, 29 },
30 post(url, data, options) { 30 post(url, data, options) {
31 return request(Object.assign({ 31 return request(Object.assign({
@@ -62,10 +62,10 @@ const handlerError = (err = {}, req, res, next) => { @@ -62,10 +62,10 @@ const handlerError = (err = {}, req, res, next) => {
62 return next(err); 62 return next(err);
63 }; 63 };
64 64
65 -const getCacheKey = (urlPath, cackeKey = '') => { 65 +const getCacheKey = (urlPath, cacheKey = '') => {
66 const urlObj = url.parse(urlPath); 66 const urlObj = url.parse(urlPath);
67 67
68 - return md5(cackeKey 68 + return md5(cacheKey
69 .replace('$url', urlObj.pathname) 69 .replace('$url', urlObj.pathname)
70 .replace('$params', urlObj.query)); 70 .replace('$params', urlObj.query));
71 }; 71 };
@@ -84,7 +84,7 @@ const render = (route) => { @@ -84,7 +84,7 @@ const render = (route) => {
84 if (isDegrade) { 84 if (isDegrade) {
85 return res.send(degradeHtml); 85 return res.send(degradeHtml);
86 } 86 }
87 - const ck = route.cackeKey ? getCacheKey(req.url, route.cackeKey) : void 0; 87 + const ck = route.cacheKey ? getCacheKey(req.url, route.cacheKey) : void 0;
88 88
89 if (config.useCache && route.cache && ck) { 89 if (config.useCache && route.cache && ck) {
90 const html = await redis.getAsync(ck); 90 const html = await redis.getAsync(ck);
@@ -116,7 +116,7 @@ const devRender = (route) => { @@ -116,7 +116,7 @@ const devRender = (route) => {
116 return async(req, res, next) => { 116 return async(req, res, next) => {
117 try { 117 try {
118 res.setHeader('X-YOHO-Version', pkg.version); 118 res.setHeader('X-YOHO-Version', pkg.version);
119 - const ck = route.cackeKey ? getCacheKey(req.url, route.cackeKey) : void 0; 119 + const ck = route.cacheKey ? getCacheKey(req.url, route.cacheKey) : void 0;
120 120
121 // return require('request-promise')({ 121 // return require('request-promise')({
122 // url: 'http://m.yohobuy.com:6005/degrade.html' 122 // url: 'http://m.yohobuy.com:6005/degrade.html'