Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
htoooth
7 years ago
Commit
ba9f35f06318fc2811ccd941519414aff795f104
2 parents
3913a5ca
4bee3ef7
Merge branch 'feature/qps' of
http://git.yoho.cn/fe/yohobuy-node
into feature/qps
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
27 additions
and
45 deletions
.gitignore
apps/3party/controllers/robot-check.js
apps/home/models/index-service.js
apps/home/router.js
apps/passport/models/cert-api.js
apps/product/models/shop-service.js
config/cache.js
config/common.js
doraemon/middleware/limiter/index.js
doraemon/models/header.js
doraemon/views/layout.hbs
package.json
utils/benchmark.js
.gitignore
View file @
ba9f35f
...
...
@@ -151,3 +151,4 @@ library
Procfile
.env
.package-lock
package-lock.json
...
...
apps/3party/controllers/robot-check.js
View file @
ba9f35f
...
...
@@ -19,7 +19,7 @@ const check = captchaService.geetestCheck;
const
img
=
captchaService
.
geetestGenerate
;
const
isHuman
=
(
req
,
res
)
=>
{
let
remoteIp
=
req
.
get
(
'X-Forwarded-For'
)
||
req
.
i
p
;
let
remoteIp
=
req
.
yoho
.
clientI
p
;
if
(
remoteIp
.
indexOf
(
','
)
>
0
)
{
let
arr
=
remoteIp
.
split
(
','
);
...
...
apps/home/models/index-service.js
View file @
ba9f35f
...
...
@@ -213,7 +213,7 @@ module.exports = class extends global.yoho.BaseModel {
// 推荐数据
async
recommend
(
uid
,
udid
,
channelNum
)
{
let
recommendCaceKey
=
`
$
{
cachePreKey
}
recommend
`
;
let
recommendCaceKey
=
`
$
{
cachePreKey
}
$
{
uid
}
recommend
`
;
let
recommend
=
await
cache
.
get
(
recommendCaceKey
).
catch
(()
=>
{
return
{};
});
...
...
apps/home/router.js
View file @
ba9f35f
...
...
@@ -50,22 +50,11 @@ const invoiceController = require(`${cRoot}/invoice`);
const
meGiftController
=
require
(
`
$
{
cRoot
}
/me-gift`
)
;
const
checkLogin
=
(
req
,
res
,
next
)
=>
{
if
(
req
.
user
.
uid
)
{
return
next
();
}
else
{
if
(
res
.
xhr
)
{
res
.
json
({
code
:
401
,
message
:
'未登录!'
});
}
else
{
res
.
redirect
(
'/login.html'
);
}
}
};
// 首页
router
.
get
([
'/index'
,
'/'
],
tabsMiddleware
.
getCommonHeaderNew
,
indexController
.
index
);
router
.
get
(
'/index/newsAvatar'
,
checkLogin
,
indexController
.
newsAvatar
);
router
.
get
(
'/index/async'
,
checkLogin
,
indexController
.
asyncData
);
router
.
get
(
'/index/newsAvatar'
,
indexController
.
newsAvatar
);
router
.
get
(
'/index/async'
,
indexController
.
asyncData
);
// 查看二维码
router
.
get
(
'/QRcode'
,
tabsMiddleware
.
getCommonHeader
,
personalController
.
QRcode
);
...
...
apps/passport/models/cert-api.js
View file @
ba9f35f
...
...
@@ -58,7 +58,7 @@ module.exports = class extends global.yoho.BaseModel {
uid
:
uid
};
return
this
.
get
({
data
:
param
,
param
:
{
cache
:
true
}
});
return
this
.
get
({
data
:
param
});
}
};
...
...
apps/product/models/shop-service.js
View file @
ba9f35f
...
...
@@ -75,7 +75,7 @@ function _getShopData(channel, params, shopInfo) {
searchHandler
.
getBrandShopSeo
(
channel
,
{
shopName
:
shopInfo
.
shop_name
},
params
)
// 店铺SEO
);
_
.
set
(
resData
,
'headerData.header'
,
true
);
//
_.set(resData, 'headerData.header', true);
// 店铺装修
if
(
result
.
decorator
.
code
===
200
)
{
...
...
@@ -234,7 +234,7 @@ function _getBaseShopData(channel, params, shopInfo) {
result
.
header
,
// 头部数据
searchHandler
.
getBrandShopSeo
(
channel
,
{
shopName
:
shopName
},
params
));
_
.
set
(
resData
,
'headerData.header'
,
true
);
//
_.set(resData, 'headerData.header', true);
_
.
set
(
resData
,
'brand.shopBanner'
,
{
shopId
:
shopId
,
shopName
:
shopName
,
...
...
config/cache.js
View file @
ba9f35f
...
...
@@ -65,8 +65,8 @@ const cachePage = {
'/product/search/keyword/:id'
:
7
*
DAY
,
// 帮助
'/help/'
:
7
*
DAY
,
'/help/detail'
:
7
*
DAY
,
'/help/'
:
1
*
DAY
,
'/help/detail'
:
1
*
DAY
,
};
module
.
exports
=
cachePage
;
...
...
config/common.js
View file @
ba9f35f
...
...
@@ -172,13 +172,13 @@ module.exports = {
},
REQUEST_LIMIT
:
{
// 10s 最多访问5次
10
:
5
,
10
:
8
,
// 30s 最多访问15次
30
:
15
,
30
:
20
,
// 60s 最多访问15次
60
:
2
0
,
60
:
3
0
,
// 100s 最多访问15次
600
:
100
...
...
doraemon/middleware/limiter/index.js
View file @
ba9f35f
...
...
@@ -14,6 +14,8 @@ const captchaPolicy = require('./policies/captcha');
const
IP_WHITE_LIST
=
[
'106.38.38.146'
,
'106.38.38.147'
,
'106.39.86.227'
,
'218.94.75.58'
,
'218.94.75.50'
,
'218.94.77.166'
...
...
doraemon/models/header.js
View file @
ba9f35f
...
...
@@ -158,10 +158,10 @@ const getSubNavGroup = (data, type) => {
obj
.
isHot
=
item
.
is_hot
===
'Y'
?
true
:
false
;
obj
.
isNew
=
item
.
is_new
===
'Y'
?
true
:
false
;
// if (item.sub) {
// obj.thirdNav = getThirdNav(item.sub);
// obj.imgCode = item.content_code;
// }
if
(
item
.
sub
)
{
obj
.
thirdNav
=
getThirdNav
(
item
.
sub
);
obj
.
imgCode
=
item
.
content_code
;
}
subNav
.
push
(
obj
);
});
...
...
doraemon/views/layout.hbs
View file @
ba9f35f
...
...
@@ -26,7 +26,9 @@
window._timeStart = Date.now();
{{#
ifand
isProduction
pc
.
open
.
bughd
}}
window._yohoAppName = 'yohobuy-node';
!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});var n=r(13),i=r(14);n.init(),i.init()},function(e,t){e.exports=function(e,t,r){if("undefined"==typeof t){var n=null;if(document.cookie)for(var i=document.cookie.split(";"),o=0;o<i.length;o++){var a=(i[o]||"").trim();if(a.substring(0,e.length+1)==e+"="){n=decodeURIComponent(a.substring(e.length+1));break}}return n}r=r||{},null===t&&(t="",r.expires=-1);var d="";if(r.expires&&("number"==typeof r.expires||r.expires.toUTCString)){var u;"number"==typeof r.expires?(u=new Date,u.setTime(u.getTime()+24*r.expires*60*60*1e3)):u=r.expires,d="; expires="+u.toUTCString()}var s=r.path?"; path="+r.path:"",p=r.domain?"; domain="+r.domain:"",c=r.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(t),d,s,p,c].join("")}},,function(e,t,r){var n=r(1),i=window._yohoAppName||"unknown",o={config:{reportUrl:"//badjs.yoho.cn/apm/yas.gif"},stringify:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],i=[];for(var o in n)n.hasOwnProperty(o)&&i.push(o+"::"+n[o]);t.push(i.join("$$"))}return t.join("**")},report:function(e,t){if(e){var r=new Image;r.src=this.config.reportUrl+"?s="+i+"&l="+e+"&t="+(new Date).getTime(),t&&t()}},getUdid:function(){var e=(n("yohobuy_session")||"").slice(2).split(".")[0];return e||0},getUid:function(){var e=(n("_UID")||"").split("::")[1];return e||0},getReqId:function(){return n("docreqid")||0}};e.exports=o},,,,,,,,,,function(e,t,r){var n=r(1),i=r(3),o="_errLog",a={writeError:function(e,t,r,a,d){var u=JSON.parse(n(o)||"[]");u.push({tp:"err",msg:e,sc:t,ln:r,cn:a,pt:location.href,u:i.getUid(),ud:i.getUdid(),rid:i.getReqId(),st:JSON.stringify(d&&d.stack)}),n(o,JSON.stringify(u)),u.length>=5&&this.reportError()},clearError:function(){n(o,"[]")},reportError:function(){var e=this,t=JSON.parse(n(o)||"[]"),r=i.stringify(t);i.report(r,function(){e.clearError()})},init:function(){var e=this;window.onerror=function(t,r,n,i,o){e.writeError(t,r,n,i,o)},this.reportError()}};e.exports=a},function(e,t,r){function n(e){var t=e.offsetTop;return null!==e.offsetParent&&(t+=n(e.offsetParent)),t}var i=r(3),o=window.screen.height,a=[],d=!1,u=!1,s=0,p=setInterval(function(){var e,t;if(d){if(a.length)for(e=0;e<a.length;e++){if(t=a[e],!t.complete){u=!1;break}u=!0}else u=!0;u&&(s=(new Date).getTime()-_timeStart,clearInterval(p))}else{var r=document.body&&document.body.querySelectorAll("img")||[];for(e=0;e<r.length;e++){t=r[e];var i=n(t);if(i>o){d=!0;break}i<=o&&!t.hasPushed&&(t.hasPushed=1,a.push(t))}}},0),c={reportTime:function(e){var t=i.stringify(e);i.report(t)},addEvent:function(){var e=this,t=[],r=location.href,n=i.getUid(),o=i.getUdid(),a=i.getReqId(),c=window.performance&&window.performance.timing.navigationStart||0;_timeStart=window._timeStart||0,document.addEventListener&&document.addEventListener("DOMContentLoaded",function(e){t.push({tp:"dcl",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:o,rid:a});var i=document.body&&document.body.querySelectorAll("img")||[];i.length||(d=!0)},!1),window.addEventListener&&window.addEventListener("load",function(i){t.push({tp:"ld",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:o,rid:a}),u=!0,d=!0,p&&clearInterval(p),s&&t.push({tp:"fs",t:s,pt:r,u:n,ud:o,rid:a}),t.push({tp:"pf",dcl:(window.performance&&window.performance.timing.domComplete||0)-c,ld:(window.performance&&window.performance.timing.loadEventStart||0)-c,pt:r,u:n,ud:o,rid:a}),e.reportTime(t)},!1)},init:function(){this.addEvent()}};e.exports=c}]);
!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});var n=r(13),o=r(14);n.init(),o.init()},function(e,t){e.exports=function(e,t,r){if("undefined"==typeof t){var n=null;if(document.cookie)for(var o=document.cookie.split(";"),i=0;i<o.length;i++){var a=(o[i]||"").trim();if(a.substring(0,e.length+1)==e+"="){n=decodeURIComponent(a.substring(e.length+1));break}}return n}r=r||{},null===t&&(t="",r.expires=-1);var d="";if(r.expires&&("number"==typeof r.expires||r.expires.toUTCString)){var u;"number"==typeof r.expires?(u=new Date,u.setTime(u.getTime()+24*r.expires*60*60*1e3)):u=r.expires,d="; expires="+u.toUTCString()}var s=r.path?"; path="+r.path:"",p=r.domain?"; domain="+r.domain:"",c=r.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(t),d,s,p,c].join("")}},,function(e,t,r){var n=r(1),o=window._yohoAppName||"unknown",i={config:{reportUrl:"//badjs.yoho.cn/apm/yas.gif"},stringify:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],o=[];for(var i in n)n.hasOwnProperty(i)&&o.push(i+"::"+n[i]);t.push(o.join("$$"))}return t.join("**")},report:function(e,t){if(e){var r=new Image;r.src=this.config.reportUrl+"?s="+o+"&l="+e+"&t="+(new Date).getTime(),t&&t()}},getUdid:function(){var e=(n("yohobuy_session")||"").slice(2).split(".")[0];return e||0},getUid:function(){var e=(n("_UID")||"").split("::")[1];return e||0},getReqId:function(){return n("docreqid")||0}};e.exports=i},,,,,,,,,,function(e,t,r){var n=r(1),o=r(3),i="_errLog",a={writeError:function(e,t,r,a,d){var u=JSON.parse(n(i)||"[]");u.push({tp:"err",msg:e,sc:t,ln:r,cn:a,pt:encodeURIComponent(location.href),u:o.getUid(),ud:o.getUdid(),rid:o.getReqId(),st:JSON.stringify(d&&d.stack)}),n(i,JSON.stringify(u)),u.length>=5&&this.reportError()},clearError:function(){n(i,"[]")},reportError:function(){var e=this,t=JSON.parse(n(i)||"[]"),r=o.stringify(t);o.report(r,function(){e.clearError()})},init:function(){var e=this;window.onerror=function(t,r,n,o,i){e.writeError(t,r,n,o,i)},this.reportError()}};e.exports=a},function(e,t,r){function n(e){var t=e.offsetTop;return null!==e.offsetParent&&(t+=n(e.offsetParent)),t}var o=r(3),i=window.screen.height,a=[],d=!1,u=!1,s=0,p=setInterval(function(){var e,t;if(d){if(a.length)for(e=0;e<a.length;e++){if(t=a[e],!t.complete){u=!1;break}u=!0}else u=!0;u&&(s=(new Date).getTime()-_timeStart,clearInterval(p))}else{var r=document.body&&document.body.querySelectorAll("img")||[];for(e=0;e<r.length;e++){t=r[e];var o=n(t);if(o>i){d=!0;break}o<=i&&!t.hasPushed&&(t.hasPushed=1,a.push(t))}}},0),c={reportTime:function(e){var t=o.stringify(e);o.report(t)},addEvent:function(){var e=this,t=[],r=encodeURIComponent(location.href),n=o.getUid(),i=o.getUdid(),a=o.getReqId(),c=window.performance&&window.performance.timing.navigationStart||0;_timeStart=window._timeStart||0,document.addEventListener&&document.addEventListener("DOMContentLoaded",function(e){t.push({tp:"dcl",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:i,rid:a});var o=document.body&&document.body.querySelectorAll("img")||[];o.length||(d=!0)},!1),window.addEventListener&&window.addEventListener("load",function(o){t.push({tp:"ld",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:i,rid:a}),u=!0,d=!0,p&&clearInterval(p),s&&t.push({tp:"fs",t:s,pt:r,u:n,ud:i,rid:a}),t.push({tp:"pf",dcl:(window.performance&&window.performance.timing.domComplete||0)-c,ld:(window.performance&&window.performance.timing.loadEventStart||0)-c,pt:r,u:n,ud:i,rid:a}),e.reportTime(t)},!1)},init:function(){this.addEvent()}};e.exports=c}]);
{{/
ifand
}}
</script>
...
...
package.json
View file @
ba9f35f
...
...
@@ -33,6 +33,7 @@
"cookie-parser"
:
"^1.4.3"
,
"csurf"
:
"^1.9.0"
,
"express"
:
"^4.13.1"
,
"handlebars"
:
"4.0.5"
,
"lodash"
:
"^4.13.1"
,
"md5"
:
"^2.1.0"
,
"moment"
:
"^2.14.1"
,
...
...
@@ -56,8 +57,7 @@
"uuid"
:
"^2.0.2"
,
"yoho-express-session"
:
"^2.0.0"
,
"yoho-node-lib"
:
"=0.5.16"
,
"yoho-zookeeper"
:
"^1.0.8"
,
"handlebars"
:
"4.0.5"
"yoho-zookeeper"
:
"^1.0.8"
},
"devDependencies"
:
{
"autoprefixer"
:
"^6.3.6"
,
...
...
@@ -68,9 +68,9 @@
"eslint-config-yoho"
:
"^1.0.1"
,
"eslint-loader"
:
"^1.6.3"
,
"extract-text-webpack-plugin"
:
"^2.1.0"
,
"happypack"
:
"^3.0.3"
,
"handlebars"
:
"4.0.5"
,
"handlebars-loader"
:
"^1.4.0"
,
"happypack"
:
"^3.0.3"
,
"husky"
:
"^0.11.4"
,
"jquery-ui"
:
"^1.12.1"
,
"nodemon"
:
"1.9.2"
,
...
...
@@ -85,6 +85,7 @@
"postcss-opacity"
:
"^4.0.0"
,
"postcss-position"
:
"^0.5.0"
,
"postcss-pxtorem"
:
"^4.0.0"
,
"postcss-scss"
:
"^1.0.2"
,
"postcss-short"
:
"^3.0.3"
,
"postcss-sprites"
:
"^4.2.0"
,
"postcss-use"
:
"^2.3.0"
,
...
...
@@ -94,8 +95,8 @@
"style-loader"
:
"^0.16.0"
,
"stylelint"
:
"^7.9.0"
,
"stylelint-config-yoho"
:
"^1.2.8"
,
"stylelint-webpack-plugin"
:
"^0.7.0"
,
"stylelint-formatter-table"
:
"^1.0.3"
,
"stylelint-webpack-plugin"
:
"^0.7.0"
,
"webpack"
:
"^2.3.1"
,
"webpack-dev-server"
:
"^2.4.2"
,
"yoho-eventproxy"
:
"^0.3.6"
,
...
...
utils/benchmark.js
deleted
100644 → 0
View file @
3913a5c
function
benchmark
(
fn
,
ctx
)
{
return
function
()
{
let
t
=
new
Date
();
let
result
=
fn
.
apply
(
ctx
,
arguments
).
then
(
r
=>
{
console
.
log
(
'benchmark'
,
fn
.
name
,
`
[
$
{
new
Date
()
-
t
}]
`
);
return
r
;
});
return
result
;
};
}
module
.
exports
=
benchmark
;
Please
register
or
login
to post a comment