Authored by 陈峰

qiniu

/**
* 七牛上传
* @author: chenfeng <feng.chen@yoho.cn>
* @date: 29/06/2017
*/
const qiniu = require('qiniu');
const qiniuConfig = global.yoho.config.qiniu;
function getToken(req, res) {
let mac = new qiniu.auth.digest.Mac(qiniuConfig.ACCESS_KEY, qiniuConfig.SECRET_KEY);
let options = {
scope: qiniuConfig.BUCKET_NAME,
};
let putPolicy = new qiniu.rs.PutPolicy(options);
let uploadToken = putPolicy.uploadToken(mac);
res.json({
code: 200,
uptoken: uploadToken
});
}
module.exports = {
getToken
};
... ...
/**
* api
* @author: chenfeng <feng.chen@yoho.cn>
* @date: 29/06/2017
*/
const express = require('express');
const app = express();
app.use(require('./router'));
module.exports = app;
... ...
/**
* api router
* @author: chenfeng <feng.chen@yoho.cn>
* @date: 29/06/2017
*/
const express = require('express');
const router = express.Router(); // eslint-disable-line
const qiniu = require('./controllers/qiniu');
router.get('/gettoken', qiniu.getToken);
module.exports = router;
... ...
... ... @@ -78,26 +78,6 @@ module.exports = {
}
},
zookeeperServer: '127.0.0.1:2181',
alipayConfig: {
payUrl: 'https://mapi.alipay.com/gateway.do',
service: 'alipay.wap.create.direct.pay.by.user',
partner: '2088701661478015',
inputCharset: 'utf-8',
notifyUrl: domains.service + 'payment/alipay_notify',
returnUrl: '/shopping/pay/aliwapreturn',
signType: 'MD5',
paymentType: '1',
alipayKey: 'kcxawi9bb07mzh0aq2wcirsf9znusobw',
sellerMail: 'zfb@yoho.cn',
merchantUrl: 'http://m.yohobuy.com/home/orderDetail?order_code='
},
WxPayConfig: {
appId: 'wx75e5a7c0c88e45c2',
mchId: '1227694201',
key: '7e6f3307b64cc87c79c472814b88f7fb',
appSecret: 'ce21ae4a3f93852279175a167e54509b',
notifyUrl: domains.service + 'payment/weixin_notify',
},
maxQps: 1200,
geetestJs: '//static.geetest.com/static/tools/gt.js',
jsSdk: '//cdn.yoho.cn/js-sdk/1.2.2/jssdk.js',
... ... @@ -128,6 +108,11 @@ module.exports = {
password: ''
},
database: 'yoho_activity_platform',
},
qiniu: {
ACCESS_KEY: 'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU',
SECRET_KEY: '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK',
BUCKET_NAME: 'cmsimg01'
}
};
... ...
... ... @@ -3,10 +3,14 @@
* @author: Leo <qi.li@yoho.cn>
* @date: 2017/6/23
*/
const api = require('./apps/api');
const article = require('./apps/article');
const passport = require('./apps/passport');
module.exports = app => {
// api
app.use('/api', api);
// 验证
app.use('/passport', passport);
... ...
... ... @@ -55,6 +55,7 @@
"passport-sina": "^0.1.0",
"passport-strategy": "^1.0.0",
"passport-weixin": "^0.1.0",
"qiniu": "^7.0.4",
"redis": "^2.7.1",
"request": "^2.81.0",
"request-promise": "^4.2.1",
... ...
... ... @@ -55,6 +55,10 @@ acorn@^5.0.0, acorn@^5.0.1:
version "5.0.3"
resolved "http://npm.yoho.cn/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d"
address@>=0.0.1:
version "1.0.2"
resolved "http://npm.yoho.cn/address/-/address-1.0.2.tgz#480081e82b587ba319459fef512f516fe03d58af"
agent-base@2:
version "2.1.1"
resolved "http://npm.yoho.cn/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7"
... ... @@ -62,7 +66,7 @@ agent-base@2:
extend "~3.0.0"
semver "~5.0.1"
agentkeepalive@^3.1.0:
agentkeepalive@3.3.0, agentkeepalive@^3.1.0:
version "3.3.0"
resolved "http://npm.yoho.cn/agentkeepalive/-/agentkeepalive-3.3.0.tgz#6d5de5829afd3be2712201a39275fd11c651857c"
dependencies:
... ... @@ -138,6 +142,10 @@ ansistyles@~0.1.3:
version "0.1.3"
resolved "http://npm.yoho.cn/ansistyles/-/ansistyles-0.1.3.tgz#5de60415bda071bb37127854c864f41b23254539"
any-promise@^1.3.0:
version "1.3.0"
resolved "http://npm.yoho.cn/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
any-promise@~0.1.0:
version "0.1.0"
resolved "http://npm.yoho.cn/any-promise/-/any-promise-0.1.0.tgz#830b680aa7e56f33451d4b049f3bd8044498ee27"
... ... @@ -1536,7 +1544,7 @@ content-disposition@0.5.2:
version "0.5.2"
resolved "http://npm.yoho.cn/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4"
content-type@~1.0.2:
content-type@^1.0.2, content-type@~1.0.2:
version "1.0.2"
resolved "http://npm.yoho.cn/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed"
... ... @@ -1603,6 +1611,10 @@ cosmiconfig@^2.1.0, cosmiconfig@^2.1.1:
parse-json "^2.2.0"
require-from-string "^1.1.0"
crc32@0.2.2:
version "0.2.2"
resolved "http://npm.yoho.cn/crc32/-/crc32-0.2.2.tgz#7ad220d6ffdcd119f9fc127a7772cacea390a4ba"
crc@3.4.0:
version "3.4.0"
resolved "http://npm.yoho.cn/crc/-/crc-3.4.0.tgz#4258e351613a74ef1153dfcb05e820c3e9715d7f"
... ... @@ -1938,6 +1950,12 @@ deep-is@~0.1.3:
version "0.1.3"
resolved "http://npm.yoho.cn/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
default-user-agent@^1.0.0:
version "1.0.0"
resolved "http://npm.yoho.cn/default-user-agent/-/default-user-agent-1.0.0.tgz#16c46efdcaba3edc45f24f2bd4868b01b7c2adc6"
dependencies:
os-name "~1.0.3"
defaults@^1.0.3:
version "1.0.3"
resolved "http://npm.yoho.cn/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
... ... @@ -1990,7 +2008,7 @@ des.js@^1.0.0:
inherits "^2.0.1"
minimalistic-assert "^1.0.0"
destroy@~1.0.4:
destroy@^1.0.4, destroy@~1.0.4:
version "1.0.4"
resolved "http://npm.yoho.cn/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
... ... @@ -2023,6 +2041,12 @@ diffie-hellman@^5.0.0:
miller-rabin "^4.0.0"
randombytes "^2.0.0"
digest-header@^0.0.1:
version "0.0.1"
resolved "http://npm.yoho.cn/digest-header/-/digest-header-0.0.1.tgz#11ccf6deec5766ac379744d901c12cba49514be6"
dependencies:
utility "0.1.11"
dns-equal@^1.0.0:
version "1.0.0"
resolved "http://npm.yoho.cn/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"
... ... @@ -2148,7 +2172,7 @@ editorconfig@^0.13.2:
lru-cache "^3.2.0"
sigmund "^1.0.1"
ee-first@1.1.1:
ee-first@1.1.1, ee-first@~1.1.1:
version "1.1.1"
resolved "http://npm.yoho.cn/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
... ... @@ -2772,6 +2796,14 @@ form-data@~2.1.1:
combined-stream "^1.0.5"
mime-types "^2.1.12"
formstream@1.1.0:
version "1.1.0"
resolved "http://npm.yoho.cn/formstream/-/formstream-1.1.0.tgz#51f3970f26136eb0ad44304de4cebb50207b4479"
dependencies:
destroy "^1.0.4"
mime "^1.3.4"
pause-stream "~0.0.11"
forwarded@~0.1.0:
version "0.1.0"
resolved "http://npm.yoho.cn/forwarded/-/forwarded-0.1.0.tgz#19ef9874c4ae1c297bcf078fde63a09b66a84363"
... ... @@ -3335,7 +3367,7 @@ https-proxy-agent@^1.0.0:
debug "2"
extend "3"
humanize-ms@^1.2.1:
humanize-ms@^1.2.0, humanize-ms@^1.2.1:
version "1.2.1"
resolved "http://npm.yoho.cn/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed"
dependencies:
... ... @@ -3350,7 +3382,7 @@ husky@^0.13.4:
is-ci "^1.0.9"
normalize-path "^1.0.0"
iconv-lite@0.4.15, iconv-lite@~0.4.13:
iconv-lite@0.4.15, iconv-lite@^0.4.15, iconv-lite@~0.4.11, iconv-lite@~0.4.13:
version "0.4.15"
resolved "http://npm.yoho.cn/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"
... ... @@ -4404,6 +4436,10 @@ mime@1.3.4, mime@^1.3.4:
version "1.3.4"
resolved "http://npm.yoho.cn/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53"
mime@1.3.6:
version "1.3.6"
resolved "http://npm.yoho.cn/mime/-/mime-1.3.6.tgz#591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0"
mimic-fn@^1.0.0:
version "1.1.0"
resolved "http://npm.yoho.cn/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"
... ... @@ -5040,6 +5076,13 @@ os-locale@^2.0.0:
lcid "^1.0.0"
mem "^1.1.0"
os-name@~1.0.3:
version "1.0.3"
resolved "http://npm.yoho.cn/os-name/-/os-name-1.0.3.tgz#1b379f64835af7c5a7f498b357cb95215c159edf"
dependencies:
osx-release "^1.0.0"
win-release "^1.0.0"
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1:
version "1.0.2"
resolved "http://npm.yoho.cn/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
... ... @@ -5051,6 +5094,12 @@ osenv@0, osenv@^0.1.0, osenv@^0.1.4, osenv@~0.1.4:
os-homedir "^1.0.0"
os-tmpdir "^1.0.0"
osx-release@^1.0.0:
version "1.1.0"
resolved "http://npm.yoho.cn/osx-release/-/osx-release-1.1.0.tgz#f217911a28136949af1bf9308b241e2737d3cd6c"
dependencies:
minimist "^1.1.0"
p-finally@^1.0.0:
version "1.0.0"
resolved "http://npm.yoho.cn/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
... ... @@ -5270,7 +5319,7 @@ path-type@^2.0.0:
dependencies:
pify "^2.0.0"
pause-stream@0.0.11:
pause-stream@0.0.11, pause-stream@~0.0.11:
version "0.0.11"
resolved "http://npm.yoho.cn/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
dependencies:
... ... @@ -6144,7 +6193,19 @@ q@^1.1.2:
version "1.5.0"
resolved "http://npm.yoho.cn/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1"
qs@6.4.0, qs@~6.4.0:
qiniu@^7.0.4:
version "7.0.4"
resolved "http://npm.yoho.cn/qiniu/-/qiniu-7.0.4.tgz#f740af64d1794f732bbc21edd36591136d503e62"
dependencies:
agentkeepalive "3.3.0"
crc32 "0.2.2"
formstream "1.1.0"
mime "1.3.6"
tunnel-agent "0.6.0"
urlencode "1.1.0"
urllib "2.22.0"
qs@6.4.0, qs@^6.4.0, qs@~6.4.0:
version "6.4.0"
resolved "http://npm.yoho.cn/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
... ... @@ -6755,7 +6816,7 @@ semver-diff@^2.0.0:
dependencies:
semver "^5.0.3"
"semver@2 >=2.2.1 || 3.x || 4 || 5", "semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", "semver@^2.3.0 || 3.x || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@~5.3.0:
"semver@2 >=2.2.1 || 3.x || 4 || 5", "semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", "semver@^2.3.0 || 3.x || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@~5.3.0:
version "5.3.0"
resolved "http://npm.yoho.cn/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
... ... @@ -7089,7 +7150,7 @@ static-module@^1.0.0:
static-eval "~0.2.0"
through2 "~0.4.1"
"statuses@>= 1.3.1 < 2", statuses@~1.3.1:
"statuses@>= 1.3.1 < 2", statuses@^1.3.1, statuses@~1.3.1:
version "1.3.1"
resolved "http://npm.yoho.cn/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e"
... ... @@ -7562,7 +7623,7 @@ tty-browserify@0.0.0:
version "0.0.0"
resolved "http://npm.yoho.cn/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
tunnel-agent@^0.6.0:
tunnel-agent@0.6.0, tunnel-agent@^0.6.0:
version "0.6.0"
resolved "http://npm.yoho.cn/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
dependencies:
... ... @@ -7732,6 +7793,27 @@ url@^0.11.0:
punycode "1.3.2"
querystring "0.2.0"
urlencode@1.1.0:
version "1.1.0"
resolved "http://npm.yoho.cn/urlencode/-/urlencode-1.1.0.tgz#1f2ba26f013c85f0133f7a3ad6ff2730adf7cbb7"
dependencies:
iconv-lite "~0.4.11"
urllib@2.22.0:
version "2.22.0"
resolved "http://npm.yoho.cn/urllib/-/urllib-2.22.0.tgz#2965dc4ae127a6fb695b7db27d3184f17d82cb42"
dependencies:
any-promise "^1.3.0"
content-type "^1.0.2"
debug "^2.6.0"
default-user-agent "^1.0.0"
digest-header "^0.0.1"
ee-first "~1.1.1"
humanize-ms "^1.2.0"
iconv-lite "^0.4.15"
qs "^6.4.0"
statuses "^1.3.1"
user-home@^2.0.0:
version "2.0.0"
resolved "http://npm.yoho.cn/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f"
... ... @@ -7752,6 +7834,12 @@ util@0.10.3, util@^0.10.3:
dependencies:
inherits "2.0.1"
utility@0.1.11:
version "0.1.11"
resolved "http://npm.yoho.cn/utility/-/utility-0.1.11.tgz#fde60cf9b4e4751947a0cf5d104ce29367226715"
dependencies:
address ">=0.0.1"
utils-merge@1.0.0, utils-merge@1.x.x:
version "1.0.0"
resolved "http://npm.yoho.cn/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8"
... ... @@ -8029,6 +8117,12 @@ widest-line@^1.0.0:
dependencies:
string-width "^1.0.1"
win-release@^1.0.0:
version "1.1.1"
resolved "http://npm.yoho.cn/win-release/-/win-release-1.1.1.tgz#5fa55e02be7ca934edfc12665632e849b72e5209"
dependencies:
semver "^5.0.1"
window-size@0.1.0:
version "0.1.0"
resolved "http://npm.yoho.cn/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"
... ...