修改代码格式;

数据库查询加 lean 判断;
其它内容微调。
This commit is contained in:
liangtongchuan
2020-08-27 20:01:35 +08:00
parent 940879016f
commit c53db8634d
17 changed files with 710 additions and 323 deletions

2
pushdocker_zyz_test.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
rsync -av --include '.babelrc' --include '.eslintrc.js' --exclude '.*' --exclude './game-server/node_modules' --exclude './game-server/node_modules' --exclude 'node_modules' --exclude 'bower_components' --exclude 'dist' --progress --inplace --no-owner --no-group --rsh='ssh -p22' . root@zyz_test:/root/zyz/

View File

@@ -8,5 +8,5 @@ export const ENCRYPT_KEY = 'fiqaxijabbantusmprc234fj';
export const AUTH_SMS_CNT_PER_DAY = 8; export const AUTH_SMS_CNT_PER_DAY = 8;
export const COUNTER = { export const COUNTER = {
UID: 'uid' UID: 'uid',
} };

View File

@@ -4,14 +4,14 @@ import { GameModel } from '../db/Game';
import { Controller } from 'egg'; import { Controller } from 'egg';
export default class GameController extends Controller { export default class GameController extends Controller {
public async getServerList() { public async getServerList() {
const { ctx } = this; const { ctx } = this;
const { serverType } = ctx.request.body; const { serverType } = ctx.request.body;
let serverList: Array<any> = await GameModel.getServerListByType(serverType); const serverList: Array<any> = await GameModel.getServerListByType(serverType);
if (serverList && serverList.length > 0) { if (serverList && serverList.length > 0) {
ctx.body = {status: STATUS_SUC.code, data: { serverList }}; ctx.body = { status: STATUS_SUC.code, data: { serverList } };
} else { } else {
ctx.body = ctx.service.utils.exceptionResult(SERVER_NOT_FOUND); ctx.body = ctx.service.utils.exceptionResult(SERVER_NOT_FOUND);
}
} }
} }
}

View File

@@ -3,13 +3,13 @@ import { prop, pre } from '@typegoose/typegoose';
/** /**
* BaseModel * BaseModel
*/ */
@pre<BaseModel>('save', function (next) { @pre<BaseModel>('save', function(next) {
if (!this.createdAt || this.isNew) { if (!this.createdAt || this.isNew) {
this.createdAt = this.updatedAt = new Date() this.createdAt = this.updatedAt = new Date();
} else { } else {
this.updatedAt = new Date() this.updatedAt = new Date();
} }
next() next();
}) })
export default class BaseModel { export default class BaseModel {
@@ -21,4 +21,4 @@ export default class BaseModel {
@prop() @prop()
updatedAt: Date updatedAt: Date
} }

View File

@@ -2,21 +2,21 @@ import BaseModel from './BaseModel';
import { index, getModelForClass, prop } from '@typegoose/typegoose'; import { index, getModelForClass, prop } from '@typegoose/typegoose';
/** /**
* 短信字段接口 * 自增 ID
*/ */
@index({ name: 1 }) @index({ name: 1 })
export default class Counter extends BaseModel { export default class Counter extends BaseModel {
@prop({ required: true }) @prop({ required: true })
name: string; name: string;
@prop({ required: true, default: 1 }) @prop({ required: true, default: 1 })
seq: number; seq: number;
public static async getNewCounter(name: string) { public static async getNewCounter(name: string, lean = true) {
const counter = await CounterModel.findOneAndUpdate({name}, {$inc: {seq: 1}}, {new: true, upsert: true}).lean(); const counter = await CounterModel.findOneAndUpdate({ name }, { $inc: { seq: 1 } }, { new: true, upsert: true }).lean(lean);
return counter?.seq; return counter?.seq;
} }
} }

View File

@@ -3,68 +3,72 @@ import BaseModel from './BaseModel';
import { index, getModelForClass, prop } from '@typegoose/typegoose'; import { index, getModelForClass, prop } from '@typegoose/typegoose';
class ServerInfo { class ServerInfo {
@prop({ required: true}) @prop({ required: true })
name: string; name: string;
@prop({ required: true}) @prop({ required: true })
host: string; host: string;
@prop({ required: false}) @prop({ required: false })
port: number; port: number;
@prop({ required: true}) @prop({ required: true })
status: number; status: number;
@prop({ required: true}) @prop({ required: true })
createTime: Date; createTime: Date;
@prop({ required: true}) @prop({ required: true })
serverType: string; serverType: string;
} }
/** /**
* 用户字段接口 * 游戏字段接口
*/ */
@index({ id: 1 }) @index({ id: 1 })
export default class Game extends BaseModel { export default class Game extends BaseModel {
@prop({ required: true}) @prop({ required: true })
id: number; id: number;
@prop({ required: true}) @prop({ required: true })
name: string; name: string;
@prop({ required: true}) @prop({ required: true })
nameEn: string; nameEn: string;
@prop({ required: true}) @prop({ required: true })
des: string; des: string;
@prop({ required: true}) @prop({ required: true })
serverList: Array<ServerInfo>; serverList: Array<ServerInfo>;
@prop({ required: true}) @prop({ required: true })
iconUrl: string; iconUrl: string;
@prop({ required: true}) @prop({ required: true })
version: string; version: string;
@prop({ required: true}) @prop({ required: true })
versionCode: number; versionCode: number;
public static async getServerListByType(serverType: string) { public static async getServerListByType(serverType: string) {
let game = await GameModel.findOne().lean(); let game = await GameModel.findOne().lean();
if (!game) { if (!game) {
const serverInfo: ServerInfo = {name: '常山少年', host: 'pinus_test.trgame.cn', port: 3014, status: 1, createTime: new Date(), serverType: 'official'}; const serverInfo: ServerInfo = { name: '常山少年', host: 'pinus_test.trgame.cn', port: 3014, status: 1, createTime: new Date(), serverType: 'official' };
const iconUrl = `https://download.tgamebox.cn/avatar/${APP_ID}/1.png`; const iconUrl = `https://download.tgamebox.cn/avatar/${APP_ID}/1.png`;
game = await GameModel.findOneAndUpdate({}, {id: 1, name: '赵云传', nameEn: 'zyz', des: '牛逼的战棋', iconUrl, version: '0.0.1', versionCode: 1, $push: {serverList: serverInfo}}, {upsert: true, new: true}).lean(); game = await GameModel.findOneAndUpdate(
} {},
let serverList: Array<ServerInfo> = game ? game.serverList : []; { id: 1, name: '赵云传', nameEn: 'zyz', des: '牛逼的战棋', iconUrl, version: '0.0.1', versionCode: 1, $push: { serverList: serverInfo } },
serverList = serverList.filter(item => { return item.serverType === serverType; }) { upsert: true, new: true },
return serverList; ).lean();
}
console.log(serverType, game);
let serverList: Array<ServerInfo> = game ? game.serverList : [];
serverList = serverList.filter(item => { return item.serverType === serverType; });
console.log(serverType, serverList);
return serverList;
} }
//#endregion
} }
export const GameModel = getModelForClass(Game); export const GameModel = getModelForClass(Game);

View File

@@ -8,55 +8,57 @@ const moment = require('moment');
@index({ tel: 1 }) @index({ tel: 1 })
export default class Sms extends BaseModel { export default class Sms extends BaseModel {
@prop({ required: true }) @prop({ required: true })
tel: string; tel: string;
@prop({ required: true }) @prop({ required: true })
telHash: string; telHash: string;
@prop({ required: true }) @prop({ required: true })
code: string; code: string;
@prop({ required: true }) @prop({ required: true })
used: boolean; used: boolean;
@prop({ required: true }) @prop({ required: true })
updateTime: Date; updateTime: Date;
@prop({ required: true }) @prop({ required: true })
countToday: number; countToday: number;
public static async findByTel(tel: string) { public static async findByTel(tel: string, lean = true) {
let sms = await smsModel.findOne({ tel }).lean(); const sms = await smsModel.findOne({ tel }).lean(lean);
return sms; return sms;
}
public static async updateByTel(tel: string, code: string, used: boolean, updateTime: Date, countToday: number, lean = true) {
await smsModel.findOneAndUpdate({ tel }, { code, used, updateTime, countToday }, { upsert: true }).lean(lean);
}
public static async validateSms(tel: string, code: string, lean = true) {
const record = await smsModel.findOneAndUpdate({ tel, code, used: false }, { used: true }).lean(lean);
return !!record;
}
public async timeLimit(interval: number) {
if (Date.now() > this.updateTime.getTime() + interval) {
return false;
} }
return true;
}
public static async updateByTel(tel: string, code: string, used: boolean, updateTime: Date, countToday: number) { public async cntLimit(cnt: number) {
await smsModel.findOneAndUpdate({tel}, {code, used, updateTime, countToday}, {upsert: true}); console.log('hasSendToday:', this.hasSendToday());
if (await this.hasSendToday() && this.countToday >= cnt) {
return true;
} }
return false;
}
public static async validateSms(tel: string, code: string) { public async hasSendToday() {
const record = await smsModel.findOneAndUpdate({tel, code, used: false}, {used: true}); console.log(moment(this.updateTime).format('YYYY-MM-DD'), moment(Date.now()).format('YYYY-MM-DD'));
return !!record; return moment(this.updateTime).format('YYYY-MM-DD') === moment(Date.now()).format('YYYY-MM-DD');
} }
public async timeLimit(interval: number) {
if (this.updateTime.getTime() > Date.now() - interval) {
return true;
}
return false;
}
public async cntLimit(cnt: number) {
if (this.hasSendToday() && this.countToday >= cnt) {
return true;
}
return false;
}
public async hasSendToday() {
return moment(this.updateTime).format("YYYY-MM-DD") === moment(Date.now()).format("YYYY-MM-DD");
}
} }
export const smsModel = getModelForClass(Sms); export const smsModel = getModelForClass(Sms);

View File

@@ -10,70 +10,65 @@ import { index, getModelForClass, prop } from '@typegoose/typegoose';
@index({ uid: 1 }) @index({ uid: 1 })
export default class User extends BaseModel { export default class User extends BaseModel {
@prop({ required: true}) @prop({ required: true })
uid: number; uid: number;
@prop({ required: true}) @prop({ required: true })
username: string; username: string;
@prop({ required: true}) @prop({ required: true })
token: string; token: string;
@prop({ required: true}) @prop({ required: true })
tel: string; tel: string;
@prop({ required: true}) @prop({ required: true })
telHash: string; telHash: string;
@prop({ required: true}) @prop({ required: true })
lastLoginTime: Date; lastLoginTime: Date;
@prop({ required: true}) @prop({ required: true })
createTime: Date; createTime: Date;
// 平台ios, android, web, pc // 平台ios, android, web, pc
@prop({ required: true}) @prop({ required: true })
platform: string; platform: string;
@prop({ required: true}) @prop({ required: true })
pkgName: string; pkgName: string;
// 服务器类型official, channel, ios, oversea // 服务器类型official, channel, ios, oversea
@prop({ required: true}) @prop({ required: true })
serverType: string; serverType: string;
public static async createUser() { public static async updateToken(tel: string, token: string, platform: string, pkgName: string, serverType: string, lean = true) {
let user = await UserModel.findOne({ tel }).lean();
}
public static async updateToken(tel: string, token: string, platform: string, pkgName: string, serverType: string) {
let user = await UserModel.findOne({tel}).lean();
const curTime: Date = new Date(); const curTime: Date = new Date();
let update = {}; let update = {};
if (!user) { if (!user) {
const uid = await CounterModel.getNewCounter(COUNTER.UID); const uid = await CounterModel.getNewCounter(COUNTER.UID);
update = Object.assign(update, {platform, pkgName, serverType, createTime: curTime, uid, username: `用户${uid}`}); update = Object.assign(update, { platform, pkgName, serverType, createTime: curTime, uid, username: `用户${uid}` });
} }
update = Object.assign(update, {token, lastLoginTime: curTime}); update = Object.assign(update, { token, lastLoginTime: curTime });
user = await UserModel.findOneAndUpdate({tel}, update, {upsert: true, new: true}).lean(); user = await UserModel.findOneAndUpdate({ tel }, update, { upsert: true, new: true }).lean(lean);
return user; return user;
} }
public static async findUserByToken(token: string) { public static async findUserByToken(token: string, lean = true) {
const user = await UserModel.findOne({token}).select('uid token').lean(); const user = await UserModel.findOne({ token }).select('uid token').lean(lean);
return user; return user;
} }
public static async findUserByTel(tel: string) { public static async findUserByTel(tel: string, lean = true) {
const user = await UserModel.findOne({tel}).select('uid tel').lean(); const user = await UserModel.findOne({ tel }).select('uid tel').lean(lean);
return user; return user;
} }
public static async findUserByUid(uid: number) { public static async findUserByUid(uid: number, lean = true) {
const user = await UserModel.findOne({uid}).select('uid tel').lean(); const user = await UserModel.findOne({ uid }).select('uid tel').lean(lean);
return user; return user;
} }
//#endregion
} }
export const UserModel = getModelForClass(User); export const UserModel = getModelForClass(User);

View File

@@ -5,14 +5,14 @@ const isJSON = require('koa-is-json');
function aesEncrypt(data, key, iv) { function aesEncrypt(data, key, iv) {
const cipher = crypto.createCipheriv('aes-192-cbc', key, iv); const cipher = crypto.createCipheriv('aes-192-cbc', key, iv);
var crypted = cipher.update(data, 'utf8', 'hex'); let crypted = cipher.update(data, 'utf8', 'hex');
crypted += cipher.final('hex'); crypted += cipher.final('hex');
return crypted; return crypted;
} }
function aesDecrypt(data, key, iv) { function aesDecrypt(data, key, iv) {
const decipher = crypto.createDecipheriv('aes-192-cbc', key, iv); const decipher = crypto.createDecipheriv('aes-192-cbc', key, iv);
var decrypted = decipher.update(data, 'hex', 'utf8'); let decrypted = decipher.update(data, 'hex', 'utf8');
decrypted += decipher.final('utf8'); decrypted += decipher.final('utf8');
return decrypted; return decrypted;
} }
@@ -20,29 +20,31 @@ function aesDecrypt(data, key, iv) {
module.exports = options => { module.exports = options => {
return async function parmsDecode(ctx: Context, next) { return async function parmsDecode(ctx: Context, next) {
if (options.threshold && ctx.length < options.threshold) return; if (options.threshold && ctx.length < options.threshold) return;
let reqBody = ctx.request.body; const reqBody = ctx.request.body;
if (!reqBody.data) return;
if (isJSON(reqBody)) { if (isJSON(reqBody)) {
let encodeStr = aesEncrypt(JSON.stringify(reqBody), ENCRYPT_KEY, ENCRYPT_IV); const encodeStr = aesEncrypt(JSON.stringify(reqBody), ENCRYPT_KEY, ENCRYPT_IV);
console.log(`encoded str: ${encodeStr}`); console.log(`encoded str: ${encodeStr}`);
} }
if (!reqBody.data) return;
let decodeStr = aesDecrypt(reqBody.data, ENCRYPT_KEY, ENCRYPT_IV); const decodeStr = aesDecrypt(reqBody.data, ENCRYPT_KEY, ENCRYPT_IV);
ctx.logger.debug('decoded str:', decodeStr);
try { try {
ctx.request.body = JSON.parse(decodeStr); ctx.request.body = JSON.parse(decodeStr);
console.log('req body', ctx.request.body);
} catch (e) { } catch (e) {
console.error('parms parse err'); console.error('parms parse err');
} }
await next(); await next();
const resBody = ctx.body;
let resBody = ctx.body;
console.log('return value:', resBody); console.log('return value:', resBody);
if (isJSON(resBody)) { if (isJSON(resBody)) {
ctx.body = {result: aesEncrypt(JSON.stringify(resBody), ENCRYPT_KEY, ENCRYPT_IV)}; ctx.body = { result: aesEncrypt(JSON.stringify(resBody), ENCRYPT_KEY, ENCRYPT_IV) };
} else { } else {
ctx.body = {result: aesEncrypt(JSON.stringify({status: 3, data: 'internal err'}), ENCRYPT_KEY, ENCRYPT_IV)}; ctx.body = { result: aesEncrypt(JSON.stringify({ status: 3, data: 'internal err' }), ENCRYPT_KEY, ENCRYPT_IV) };
} }
} };
} };

View File

@@ -1,19 +1,20 @@
import { STATUS_TOKEN_ERR, STATUS_WRONG_PARMS } from './../../../shared/statusCode'; import { STATUS_TOKEN_ERR, STATUS_WRONG_PARMS } from './../../../shared/statusCode';
import { UserModel } from './../db/User'; import { UserModel } from './../db/User';
import { Context } from 'egg';
module.exports = () => { module.exports = () => {
return async function tokenParser(ctx: Context, next) { return async function tokenParser(ctx, next) {
if (!ctx.request.body || !ctx.request.body.token) { if (!ctx.request.body || !ctx.request.body.token) {
ctx.body = ctx.service.utils.exceptionResult(STATUS_WRONG_PARMS); console.error('token not found');
return; ctx.body = ctx.service.utils.exceptionResult(STATUS_WRONG_PARMS);
} return;
const user = await UserModel.findUserByToken(ctx.request.body.token);
if (!user) {
console.log('token invalid');
ctx.body = ctx.service.utils.exceptionResult(STATUS_TOKEN_ERR);
return;
}
await next();
} }
} const user = await UserModel.findUserByToken(ctx.request.body.token);
if (!user) {
console.error('token invalid');
ctx.body = ctx.service.utils.exceptionResult(STATUS_TOKEN_ERR);
return;
}
await next();
};
};

View File

@@ -9,84 +9,95 @@ const _ = require('underscore');
*/ */
export default class Auth extends Service { export default class Auth extends Service {
public checkTelNo(telNo) { public checkTelNo(telNo) {
if (!_.isString(telNo)) { if (!_.isString(telNo)) {
return {status: 1, data: '参数类型错误'}; return { status: 1, data: '参数类型错误' };
} }
if (telNo.length !== 11) { if (telNo.length !== 11) {
return {status: 1, data: '手机号长度错误'}; return { status: 1, data: '手机号长度错误' };
} }
return {status: 0, data: '手机号合法'}; return { status: 0, data: '手机号合法' };
}
async sendSmsCodeByGuodu(tel, code) {
const ctx = this.ctx;
const url = `http://221.179.172.68:8000/QxtSms/QxtFirewall?OperID=bantu3&OperPass=c8XcTffG&DesMobile=${tel}&Content=${encodeURIComponent(`【同人游戏】验证码${code},您正在登录赵云传,若非本人操作,请勿泄露`)}&Content_Code=1`;
const result = await ctx.curl(url, {
method: 'GET',
});
return result.data;
}
testLimit(sms, interval) {
if (sms.updateTime.getTime() > Date.now() - interval) {
return true;
}
return false;
}
/**
* 用户获取手机验证码
* @param telNo - 用户手机号
*/
public async getSms(tel: string) {
const telVerify = this.checkTelNo(tel);
if (telVerify.status !== 0) {
return telVerify;
} }
async sendSmsCodeByGuodu(tel, code) { const sms = await smsModel.findByTel(tel, false);
const ctx = this.ctx; if (sms) {
let url = `http://221.179.172.68:8000/QxtSms/QxtFirewall?OperID=bantu3&OperPass=c8XcTffG&DesMobile=${tel}&Content=${encodeURIComponent(`【同人游戏】验证码${code},您正在登录赵云传,若非本人操作,请勿泄露`)}&Content_Code=1` if (await sms.timeLimit(10000)) {
const result = await ctx.curl(url, { return this.ctx.service.utils.exceptionResult(SMS_IN_60S);
method: 'GET', }
}); if (await sms.cntLimit(8)) {
return result.data; return this.ctx.service.utils.exceptionResult(SMS_CNT_LIMIT);
}
} }
/** let code = '';
* 用户获取手机验证码 if (!sms || !sms.used) {
* @param telNo - 用户手机号 code = this.ctx.service.utils.generateNum(6);
*/ } else {
code = sms.code;
public async getSms(tel: string) {
const telVerify = this.checkTelNo(tel);
if (telVerify.status !== 0) {
return telVerify;
}
let sms = await smsModel.findByTel(tel);
if (!!sms) {
if (sms.timeLimit(60000)) {
return this.ctx.service.utils.exceptionResult(SMS_IN_60S);
}
if (sms.cntLimit(8)) {
return this.ctx.service.utils.exceptionResult(SMS_CNT_LIMIT);
}
}
let code: string = '';
if (!sms || !sms.used) {
code = this.ctx.service.utils.generateNum(6);
} else {
code = sms.code;
}
await this.sendSmsCodeByGuodu(tel, code);
await smsModel.updateByTel(tel, code, false, new Date(), sms?.hasSendToday() ? sms.countToday + 1 : 1);
return this.ctx.service.utils.exceptionResult(STATUS_SUC);
} }
/** const smsResult = await this.sendSmsCodeByGuodu(tel, code);
* 用户获取到手机验证码之后发送验证登录请求 console.log(smsResult);
* @param telNo 登录手机号 await smsModel.updateByTel(tel, code, false, new Date(), sms?.hasSendToday() ? sms.countToday + 1 : 1);
* @param code 登录验证码 return this.ctx.service.utils.exceptionResult(STATUS_SUC);
*/ }
public async smsLogin(tel: string, code: string, platform: string, pkgName: string, serverType: string) {
const ctx = this.ctx;
// 参数检查
const telVerify = this.checkTelNo(tel);
if (telVerify.status !== 0) {
return telVerify;
}
if (!_.isString(code) || code.length !== 6) {
return ctx.service.utils.exceptionResult(STATUS_WRONG_PARMS);
}
// 手机验证码核验 /**
const smsValid: boolean = await smsModel.validateSms(tel, code); * 用户获取到手机验证码之后发送验证登录请求
if (!smsValid) { * @param tel 登录手机号
return ctx.service.utils.exceptionResult(SMS_INVALID); * @param code 登录验证码
} * @param platform 平台
* @param pkgName 包名
// 用户注册登录 * @param serverType 服务器类型
const token = ctx.service.utils.generateStr(256); */
const user = await UserModel.updateToken(tel, token, platform, pkgName, serverType); public async smsLogin(tel: string, code: string, platform: string, pkgName: string, serverType: string) {
return {status: STATUS_SUC, data: { token, uid: user?.uid }}; const ctx = this.ctx;
// 参数检查
const telVerify = this.checkTelNo(tel);
if (telVerify.status !== 0) {
return telVerify;
} }
if (!_.isString(code) || code.length !== 6) {
return ctx.service.utils.exceptionResult(STATUS_WRONG_PARMS);
}
// 手机验证码核验
const smsValid: boolean = await smsModel.validateSms(tel, code);
if (!smsValid) {
return ctx.service.utils.exceptionResult(SMS_INVALID);
}
// 用户注册登录
const token = ctx.service.utils.generateStr(256);
const user = await UserModel.updateToken(tel, token, platform, pkgName, serverType);
return { status: STATUS_SUC, data: { token, uid: user?.uid } };
}
} }

View File

@@ -6,81 +6,82 @@ const crypto = require('crypto');
*/ */
export default class TurboCore extends Service { export default class TurboCore extends Service {
/** /**
* 用户获取手机验证码 * 用户获取手机验证码
* @param telNo - 用户手机号 * @param telNo - 用户手机号
*/ */
public async getSms(telNo: string) { public async getSms(telNo: string) {
const ctx = this.ctx; const ctx = this.ctx;
let body = { const body = {
telNo telNo,
}; };
const result = await ctx.curl(`${TURBO_CORE_URL}/user/getSms`, { const result = await ctx.curl(`${TURBO_CORE_URL}/user/getSms`, {
method: 'POST', method: 'POST',
contentType: 'json', contentType: 'json',
headers: { headers: {
'AppId': APP_ID, AppId: APP_ID,
'sign': this.getTurboSign( body, TURBO_PARM_SECRET) sign: this.getTurboSign(body, TURBO_PARM_SECRET),
}, },
data: body, data: body,
dataType: 'json', dataType: 'json',
}); });
return result.data; return result.data;
} }
/** /**
* 用户获取到手机验证码之后发送验证登录请求 * 用户获取到手机验证码之后发送验证登录请求
* @param telNo 登录手机号 * @param telNo 登录手机号
* @param code 登录验证码 * @param code 登录验证码
*/ */
public async smsLogin(telNo: string, code: string) { public async smsLogin(telNo: string, code: string) {
const ctx = this.ctx; const ctx = this.ctx;
let body = { const body = {
telNo, code telNo, code,
}; };
const result = await ctx.curl(`${TURBO_CORE_URL}/user/getSms`, { const result = await ctx.curl(`${TURBO_CORE_URL}/user/getSms`, {
method: 'POST', method: 'POST',
contentType: 'json', contentType: 'json',
headers: { headers: {
'AppId': APP_ID, AppId: APP_ID,
'sign': this.getTurboSign( body, TURBO_PARM_SECRET) sign: this.getTurboSign(body, TURBO_PARM_SECRET),
}, },
data: body, data: body,
dataType: 'json', dataType: 'json',
}); });
return result.data; return result.data;
} }
/** /**
* 获取多宝规则下的参数签名 * 获取多宝规则下的参数签名
* @param params 参数列表 * @param params 参数列表
* @param secret 密钥 * @param secret 密钥
*/ */
private getTurboSign(params, secret) { private getTurboSign(params, secret) {
let paramsString = this.joinParamsStr(params); const paramsString = this.joinParamsStr(params);
let stringToSign = paramsString; let stringToSign = paramsString;
if (secret) {
stringToSign = `${stringToSign}&secret=${secret}`;
return crypto.createHmac('sha256', secret)
.update(stringToSign)
.digest('hex');
} else {
return null;
}
}
/** if (secret) {
* 将参数组合成字符串 stringToSign = `${stringToSign}&secret=${secret}`;
* @param params 参数列表 return crypto.createHmac('sha256', secret)
*/ .update(stringToSign)
private joinParamsStr(params) { .digest('hex');
let signString = Object.keys(params).filter(function (key) {
return params[key] !== undefined && params[key] !== '' && ['pfx', 'partner_key', 'sign', 'key'].indexOf(key) < 0;
}).sort().map(function (key) {
return key + '=' + params[key];
}).join("&");
return signString;
} }
return null;
}
/**
* 将参数组合成字符串
* @param params 参数列表
*/
private joinParamsStr(params) {
const signString = Object.keys(params).filter(function(key) {
return params[key] !== undefined && params[key] !== '' && [ 'pfx', 'partner_key', 'sign', 'key' ].indexOf(key) < 0;
}).sort()
.map(function(key) {
return key + '=' + params[key];
})
.join('&');
return signString;
}
} }

View File

@@ -4,29 +4,29 @@ const csprng = require('csprng');
* Utils Service * Utils Service
*/ */
export default class Utils extends Service { export default class Utils extends Service {
/** /**
* 生成 len 长度的随机字符串 * 生成 len 长度的随机字符串
* @param len 长度 * @param len 长度
* @param radix 基数 * @param radix 基数
*/ */
public generateStr(len: number, radix: number = 36) { public generateStr(len: number, radix = 36) {
return csprng(len, radix); return csprng(len, radix);
} }
/** /**
* 生成指定长度的随机数 * 生成指定长度的随机数
* @param len 随机数长度 * @param len 随机数长度
*/ */
public generateNum(len: number) { public generateNum(len: number) {
let code = ""; let code = '';
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
code += parseInt(`${Math.random() * 10}`); code += parseInt(`${Math.random() * 10}`);
}
return code;
} }
return code;
}
public exceptionResult(status) { public exceptionResult(status) {
const { code, simStr} = status; const { code, simStr } = status;
return {status: code, data: simStr}; return { status: code, data: simStr };
} }
} }

View File

@@ -10,15 +10,27 @@ export default (appInfo: EggAppInfo) => {
csrf: { csrf: {
enable: false, enable: false,
}, },
domainWhiteList: [ '*' ],
};
config.cors = {
origin: '*', // 匹配规则 域名+端口 *则为全匹配
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
}; };
// add your egg config in here // add your egg config in here
config.middleware = ['parmsDecode']; config.middleware = [ 'parmsDecode' ];
config.mongoose = { config.mongoose = {
url: 'mongodb://root:zyz_2020@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/admin?replicaSet=mgset-500808098', // 内网 url: 'mongodb://root:zyz_2020@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/admin?replicaSet=mgset-500808098', // 内网
options: {}, options: {},
}; };
config.alinode = {
appid: '86043',
secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a',
error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ],
packages: [ '/root/zyz/web-server/package.json' ],
};
// add your special config in here // add your special config in here
const bizConfig = { const bizConfig = {
sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,

View File

@@ -6,6 +6,14 @@ const plugin: EggPlugin = {
// enable: true, // enable: true,
// package: 'egg-view-nunjucks', // package: 'egg-view-nunjucks',
// }, // },
cors: {
enable: true,
package: 'egg-cors',
},
alinode: {
enable: true,
package: 'egg-alinode',
},
}; };
export default plugin; export default plugin;

View File

@@ -232,6 +232,14 @@
} }
} }
}, },
"@koa/cors": {
"version": "3.1.0",
"resolved": "https://registry.npm.taobao.org/@koa/cors/download/@koa/cors-3.1.0.tgz",
"integrity": "sha1-YYuwc0OM/b0+vQ5kinbjO4Tzo7I=",
"requires": {
"vary": "^1.1.2"
}
},
"@mrmlnc/readdir-enhanced": { "@mrmlnc/readdir-enhanced": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npm.taobao.org/@mrmlnc/readdir-enhanced/download/@mrmlnc/readdir-enhanced-2.2.1.tgz", "resolved": "https://registry.npm.taobao.org/@mrmlnc/readdir-enhanced/download/@mrmlnc/readdir-enhanced-2.2.1.tgz",
@@ -246,6 +254,30 @@
"resolved": "https://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz", "resolved": "https://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz",
"integrity": "sha1-K1o6s/kYzKSKjHVMCBaOPwPrphs=" "integrity": "sha1-K1o6s/kYzKSKjHVMCBaOPwPrphs="
}, },
"@typegoose/typegoose": {
"version": "7.3.4",
"resolved": "https://registry.npm.taobao.org/@typegoose/typegoose/download/@typegoose/typegoose-7.3.4.tgz",
"integrity": "sha1-HO0W0Z+cSTirrsSwNRwL+1YtQSE=",
"requires": {
"lodash": "^4.17.19",
"loglevel": "^1.6.8",
"reflect-metadata": "^0.1.13",
"semver": "^7.3.2",
"tslib": "^2.0.0"
},
"dependencies": {
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npm.taobao.org/semver/download/semver-7.3.2.tgz?cache=0&sync_timestamp=1586886301819&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-7.3.2.tgz",
"integrity": "sha1-YElisFK4HtB4aq6EOJ/7pw/9OTg="
},
"tslib": {
"version": "2.0.1",
"resolved": "https://registry.npm.taobao.org/tslib/download/tslib-2.0.1.tgz?cache=0&sync_timestamp=1596751904317&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.0.1.tgz",
"integrity": "sha1-QQ6w0RPltjVkkO7HSWA3JbAhtD4="
}
}
},
"@types/accepts": { "@types/accepts": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npm.taobao.org/@types/accepts/download/@types/accepts-1.3.5.tgz", "resolved": "https://registry.npm.taobao.org/@types/accepts/download/@types/accepts-1.3.5.tgz",
@@ -277,6 +309,15 @@
} }
} }
}, },
"@types/bson": {
"version": "4.0.2",
"resolved": "https://registry.npm.taobao.org/@types/bson/download/@types/bson-4.0.2.tgz",
"integrity": "sha1-esy4WUL8ObvbdRXU3kN8BPaYEV8=",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/color-name": { "@types/color-name": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npm.taobao.org/@types/color-name/download/@types/color-name-1.1.1.tgz?cache=0&sync_timestamp=1596837707987&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fcolor-name%2Fdownload%2F%40types%2Fcolor-name-1.1.1.tgz", "resolved": "https://registry.npm.taobao.org/@types/color-name/download/@types/color-name-1.1.1.tgz?cache=0&sync_timestamp=1596837707987&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fcolor-name%2Fdownload%2F%40types%2Fcolor-name-1.1.1.tgz",
@@ -498,6 +539,26 @@
"integrity": "sha1-NSOxJqCwSUguHDwRh3Rg92Yi/6s=", "integrity": "sha1-NSOxJqCwSUguHDwRh3Rg92Yi/6s=",
"dev": true "dev": true
}, },
"@types/mongodb": {
"version": "3.5.26",
"resolved": "https://registry.npm.taobao.org/@types/mongodb/download/@types/mongodb-3.5.26.tgz?cache=0&sync_timestamp=1598396385471&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fmongodb%2Fdownload%2F%40types%2Fmongodb-3.5.26.tgz",
"integrity": "sha1-qhAxWSW6EM3Hkx7ygMD/b1T9N/M=",
"dev": true,
"requires": {
"@types/bson": "*",
"@types/node": "*"
}
},
"@types/mongoose": {
"version": "5.7.36",
"resolved": "https://registry.npm.taobao.org/@types/mongoose/download/@types/mongoose-5.7.36.tgz",
"integrity": "sha1-La4oxjBBxq+6ioPqApafRjs/ECE=",
"dev": true,
"requires": {
"@types/mongodb": "*",
"@types/node": "*"
}
},
"@types/node": { "@types/node": {
"version": "7.10.11", "version": "7.10.11",
"resolved": "https://registry.npm.taobao.org/@types/node/download/@types/node-7.10.11.tgz?cache=0&sync_timestamp=1596839227404&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-7.10.11.tgz", "resolved": "https://registry.npm.taobao.org/@types/node/download/@types/node-7.10.11.tgz?cache=0&sync_timestamp=1596839227404&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-7.10.11.tgz",
@@ -703,6 +764,28 @@
"humanize-ms": "^1.2.1" "humanize-ms": "^1.2.1"
} }
}, },
"agentx": {
"version": "1.10.7",
"resolved": "https://registry.npm.taobao.org/agentx/download/agentx-1.10.7.tgz",
"integrity": "sha1-E4lSwmHJB4iguOhcI5CYhbtH9Ns=",
"requires": {
"debug": "^3.1.0",
"nounou": "^1.2.1",
"split2": "^2.2.0",
"through2": "^2.0.3",
"ws": "^1.1.5"
},
"dependencies": {
"debug": {
"version": "3.2.6",
"resolved": "https://registry.npm.taobao.org/debug/download/debug-3.2.6.tgz",
"integrity": "sha1-6D0X3hbYp++3cX7b5fsQE17uYps=",
"requires": {
"ms": "^2.1.1"
}
}
}
},
"ajv": { "ajv": {
"version": "6.12.4", "version": "6.12.4",
"resolved": "https://registry.npm.taobao.org/ajv/download/ajv-6.12.4.tgz?cache=0&sync_timestamp=1597480782874&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fajv%2Fdownload%2Fajv-6.12.4.tgz", "resolved": "https://registry.npm.taobao.org/ajv/download/ajv-6.12.4.tgz?cache=0&sync_timestamp=1597480782874&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fajv%2Fdownload%2Fajv-6.12.4.tgz",
@@ -2250,11 +2333,54 @@
"file-uri-to-path": "1.0.0" "file-uri-to-path": "1.0.0"
} }
}, },
"bl": {
"version": "2.2.1",
"resolved": "https://registry.npm.taobao.org/bl/download/bl-2.2.1.tgz?cache=0&sync_timestamp=1598428657095&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbl%2Fdownload%2Fbl-2.2.1.tgz",
"integrity": "sha1-jBGntzBlXF1WiYzchxIk9A/ZAdU=",
"requires": {
"readable-stream": "^2.3.5",
"safe-buffer": "^5.1.1"
},
"dependencies": {
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.7.tgz",
"integrity": "sha1-Hsoc9xGu+BTAT2IlKjamL2yyO1c=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz",
"integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=",
"requires": {
"safe-buffer": "~5.1.0"
}
}
}
},
"black-hole-stream": { "black-hole-stream": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npm.taobao.org/black-hole-stream/download/black-hole-stream-0.0.1.tgz", "resolved": "https://registry.npm.taobao.org/black-hole-stream/download/black-hole-stream-0.0.1.tgz",
"integrity": "sha1-M7ega58edFPWBBuCl0SB0hUq6kI=" "integrity": "sha1-M7ega58edFPWBBuCl0SB0hUq6kI="
}, },
"bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npm.taobao.org/bluebird/download/bluebird-3.5.1.tgz",
"integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk="
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.11.tgz",
@@ -2297,6 +2423,11 @@
"electron-to-chromium": "^1.3.47" "electron-to-chromium": "^1.3.47"
} }
}, },
"bson": {
"version": "1.1.5",
"resolved": "https://registry.npm.taobao.org/bson/download/bson-1.1.5.tgz?cache=0&sync_timestamp=1597069108497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbson%2Fdownload%2Fbson-1.1.5.tgz",
"integrity": "sha1-Kqrpj832dQwISLDLod3sPHMGCjQ="
},
"buffer": { "buffer": {
"version": "5.6.0", "version": "5.6.0",
"resolved": "https://registry.npm.taobao.org/buffer/download/buffer-5.6.0.tgz", "resolved": "https://registry.npm.taobao.org/buffer/download/buffer-5.6.0.tgz",
@@ -2668,6 +2799,16 @@
"resolved": "https://registry.npm.taobao.org/commander/download/commander-2.20.3.tgz?cache=0&sync_timestamp=1595168120323&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.20.3.tgz", "resolved": "https://registry.npm.taobao.org/commander/download/commander-2.20.3.tgz?cache=0&sync_timestamp=1595168120323&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.20.3.tgz",
"integrity": "sha1-/UhehMA+tIgcIHIrpIA16FMa6zM=" "integrity": "sha1-/UhehMA+tIgcIHIrpIA16FMa6zM="
}, },
"commandx": {
"version": "1.5.4",
"resolved": "https://registry.npm.taobao.org/commandx/download/commandx-1.5.4.tgz",
"integrity": "sha1-LgkYepPfhFQz6a55Hpkip7FtjxA=",
"requires": {
"formstream": "^1.1.0",
"tunnel-agent": "^0.6.0",
"urllib": "^2.22.0"
}
},
"comment-parser": { "comment-parser": {
"version": "0.5.5", "version": "0.5.5",
"resolved": "https://registry.npm.taobao.org/comment-parser/download/comment-parser-0.5.5.tgz?cache=0&sync_timestamp=1590816213745&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcomment-parser%2Fdownload%2Fcomment-parser-0.5.5.tgz", "resolved": "https://registry.npm.taobao.org/comment-parser/download/comment-parser-0.5.5.tgz?cache=0&sync_timestamp=1590816213745&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcomment-parser%2Fdownload%2Fcomment-parser-0.5.5.tgz",
@@ -3000,6 +3141,11 @@
"resolved": "https://registry.npm.taobao.org/delegates/download/delegates-1.0.0.tgz", "resolved": "https://registry.npm.taobao.org/delegates/download/delegates-1.0.0.tgz",
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o="
}, },
"denque": {
"version": "1.4.1",
"resolved": "https://registry.npm.taobao.org/denque/download/denque-1.4.1.tgz",
"integrity": "sha1-Z0T/dkHBSMP4ppwwflEjXB9KN88="
},
"depd": { "depd": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npm.taobao.org/depd/download/depd-1.1.2.tgz", "resolved": "https://registry.npm.taobao.org/depd/download/depd-1.1.2.tgz",
@@ -3220,6 +3366,19 @@
"ylru": "^1.2.1" "ylru": "^1.2.1"
} }
}, },
"egg-alinode": {
"version": "2.0.1",
"resolved": "https://registry.npm.taobao.org/egg-alinode/download/egg-alinode-2.0.1.tgz",
"integrity": "sha1-oM+jqRbmiqXj66uhqqtwN1hDJo8=",
"requires": {
"agentx": "^1.8.4",
"commandx": "^1.3.3",
"mkdirp": "^0.5.1",
"moment": "^2.17.1",
"mz": "^2.6.0",
"node-homedir": "^1.1.0"
}
},
"egg-bin": { "egg-bin": {
"version": "4.15.0", "version": "4.15.0",
"resolved": "https://registry.npm.taobao.org/egg-bin/download/egg-bin-4.15.0.tgz?cache=0&sync_timestamp=1593750363070&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fegg-bin%2Fdownload%2Fegg-bin-4.15.0.tgz", "resolved": "https://registry.npm.taobao.org/egg-bin/download/egg-bin-4.15.0.tgz?cache=0&sync_timestamp=1593750363070&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fegg-bin%2Fdownload%2Fegg-bin-4.15.0.tgz",
@@ -3615,6 +3774,14 @@
} }
} }
}, },
"egg-cors": {
"version": "2.2.3",
"resolved": "https://registry.npm.taobao.org/egg-cors/download/egg-cors-2.2.3.tgz",
"integrity": "sha1-ohoPay3GJ6TneKcoLBrfmapj+I8=",
"requires": {
"@koa/cors": "^3.0.0"
}
},
"egg-development": { "egg-development": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npm.taobao.org/egg-development/download/egg-development-2.5.0.tgz?cache=0&sync_timestamp=1590414534424&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fegg-development%2Fdownload%2Fegg-development-2.5.0.tgz", "resolved": "https://registry.npm.taobao.org/egg-development/download/egg-development-2.5.0.tgz?cache=0&sync_timestamp=1590414534424&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fegg-development%2Fdownload%2Fegg-development-2.5.0.tgz",
@@ -6127,6 +6294,11 @@
"object.assign": "^4.1.0" "object.assign": "^4.1.0"
} }
}, },
"kareem": {
"version": "2.3.1",
"resolved": "https://registry.npm.taobao.org/kareem/download/kareem-2.3.1.tgz",
"integrity": "sha1-3vEtnJQQF/q/sA+HOvlenJnhvoc="
},
"keygrip": { "keygrip": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npm.taobao.org/keygrip/download/keygrip-1.1.0.tgz", "resolved": "https://registry.npm.taobao.org/keygrip/download/keygrip-1.1.0.tgz",
@@ -6379,8 +6551,7 @@
"lodash": { "lodash": {
"version": "4.17.20", "version": "4.17.20",
"resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597336097104&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz", "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597336097104&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz",
"integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=", "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI="
"dev": true
}, },
"log-symbols": { "log-symbols": {
"version": "2.2.0", "version": "2.2.0",
@@ -6391,6 +6562,11 @@
"chalk": "^2.0.1" "chalk": "^2.0.1"
} }
}, },
"loglevel": {
"version": "1.7.0",
"resolved": "https://registry.npm.taobao.org/loglevel/download/loglevel-1.7.0.tgz?cache=0&sync_timestamp=1598447642950&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Floglevel%2Fdownload%2Floglevel-1.7.0.tgz",
"integrity": "sha1-coFmhVp0DVnTjbAc9G8ELKoEG7A="
},
"long": { "long": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npm.taobao.org/long/download/long-4.0.0.tgz", "resolved": "https://registry.npm.taobao.org/long/download/long-4.0.0.tgz",
@@ -6481,6 +6657,12 @@
"p-is-promise": "^2.0.0" "p-is-promise": "^2.0.0"
} }
}, },
"memory-pager": {
"version": "1.5.0",
"resolved": "https://registry.npm.taobao.org/memory-pager/download/memory-pager-1.5.0.tgz",
"integrity": "sha1-2HUWVdItOEaCdByXLyw9bfo+ZrU=",
"optional": true
},
"merge-descriptors": { "merge-descriptors": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npm.taobao.org/merge-descriptors/download/merge-descriptors-1.0.1.tgz", "resolved": "https://registry.npm.taobao.org/merge-descriptors/download/merge-descriptors-1.0.1.tgz",
@@ -6633,6 +6815,81 @@
"moment": ">= 2.9.0" "moment": ">= 2.9.0"
} }
}, },
"mongodb": {
"version": "3.6.0",
"resolved": "https://registry.npm.taobao.org/mongodb/download/mongodb-3.6.0.tgz",
"integrity": "sha1-ur1xcuxxfi7T+F4Hmz8aop3ORyQ=",
"requires": {
"bl": "^2.2.0",
"bson": "^1.1.4",
"denque": "^1.4.1",
"require_optional": "^1.0.1",
"safe-buffer": "^5.1.2",
"saslprep": "^1.0.0"
}
},
"mongoose": {
"version": "5.10.1",
"resolved": "https://registry.npm.taobao.org/mongoose/download/mongoose-5.10.1.tgz",
"integrity": "sha1-zdCD1y4ZpcT/E0Fx19Gpl2vwH+k=",
"requires": {
"bson": "^1.1.4",
"kareem": "2.3.1",
"mongodb": "3.6.0",
"mongoose-legacy-pluralize": "1.0.2",
"mpath": "0.7.0",
"mquery": "3.2.2",
"ms": "2.1.2",
"regexp-clone": "1.0.0",
"safe-buffer": "5.2.1",
"sift": "7.0.1",
"sliced": "1.0.1"
},
"dependencies": {
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz?cache=0&sync_timestamp=1589129010497&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsafe-buffer%2Fdownload%2Fsafe-buffer-5.2.1.tgz",
"integrity": "sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY="
}
}
},
"mongoose-legacy-pluralize": {
"version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/mongoose-legacy-pluralize/download/mongoose-legacy-pluralize-1.0.2.tgz",
"integrity": "sha1-O6n5H6UHtRhtOZ+0CFS/8Y+1Y+Q="
},
"mpath": {
"version": "0.7.0",
"resolved": "https://registry.npm.taobao.org/mpath/download/mpath-0.7.0.tgz",
"integrity": "sha1-IOgQLidrcXCdbgfp+NTQ9kGvv7g="
},
"mquery": {
"version": "3.2.2",
"resolved": "https://registry.npm.taobao.org/mquery/download/mquery-3.2.2.tgz",
"integrity": "sha1-4Tg6OVGFLOI+N/YZqbNQ8fs2ZOc=",
"requires": {
"bluebird": "3.5.1",
"debug": "3.1.0",
"regexp-clone": "^1.0.0",
"safe-buffer": "5.1.2",
"sliced": "1.0.1"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz",
"integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz?cache=0&sync_timestamp=1575472461218&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"ms": { "ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz?cache=0&sync_timestamp=1575472461218&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.1.2.tgz", "resolved": "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz?cache=0&sync_timestamp=1575472461218&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.1.2.tgz",
@@ -6830,6 +7087,11 @@
"integrity": "sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU=", "integrity": "sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU=",
"dev": true "dev": true
}, },
"nounou": {
"version": "1.2.1",
"resolved": "https://registry.npm.taobao.org/nounou/download/nounou-1.2.1.tgz",
"integrity": "sha1-qQR++kQF4m7H52iHW9JYD8Sl8I8="
},
"npm-run-path": { "npm-run-path": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npm.taobao.org/npm-run-path/download/npm-run-path-2.0.2.tgz?cache=0&sync_timestamp=1577052941951&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnpm-run-path%2Fdownload%2Fnpm-run-path-2.0.2.tgz", "resolved": "https://registry.npm.taobao.org/npm-run-path/download/npm-run-path-2.0.2.tgz?cache=0&sync_timestamp=1577052941951&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnpm-run-path%2Fdownload%2Fnpm-run-path-2.0.2.tgz",
@@ -8166,6 +8428,11 @@
"word-wrap": "~1.2.3" "word-wrap": "~1.2.3"
} }
}, },
"options": {
"version": "0.0.6",
"resolved": "https://registry.npm.taobao.org/options/download/options-0.0.6.tgz",
"integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8="
},
"os-homedir": { "os-homedir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/os-homedir/download/os-homedir-1.0.2.tgz", "resolved": "https://registry.npm.taobao.org/os-homedir/download/os-homedir-1.0.2.tgz",
@@ -8837,6 +9104,11 @@
} }
} }
}, },
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npm.taobao.org/reflect-metadata/download/reflect-metadata-0.1.13.tgz",
"integrity": "sha1-Z648pXyXKiqhZCsQ/jY/4y1J3Ag="
},
"regenerate": { "regenerate": {
"version": "1.4.1", "version": "1.4.1",
"resolved": "https://registry.npm.taobao.org/regenerate/download/regenerate-1.4.1.tgz", "resolved": "https://registry.npm.taobao.org/regenerate/download/regenerate-1.4.1.tgz",
@@ -8888,6 +9160,11 @@
} }
} }
}, },
"regexp-clone": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/regexp-clone/download/regexp-clone-1.0.0.tgz",
"integrity": "sha1-Ii25Z2IydwViYLmSYmNUoEzpv2M="
},
"regexp.prototype.flags": { "regexp.prototype.flags": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npm.taobao.org/regexp.prototype.flags/download/regexp.prototype.flags-1.3.0.tgz", "resolved": "https://registry.npm.taobao.org/regexp.prototype.flags/download/regexp.prototype.flags-1.3.0.tgz",
@@ -8973,6 +9250,22 @@
"resolved": "https://registry.npm.taobao.org/require-main-filename/download/require-main-filename-1.0.1.tgz", "resolved": "https://registry.npm.taobao.org/require-main-filename/download/require-main-filename-1.0.1.tgz",
"integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE="
}, },
"require_optional": {
"version": "1.0.1",
"resolved": "https://registry.npm.taobao.org/require_optional/download/require_optional-1.0.1.tgz",
"integrity": "sha1-TPNaQkf2TKPfjC7yCMxJSxyo/C4=",
"requires": {
"resolve-from": "^2.0.0",
"semver": "^5.1.0"
},
"dependencies": {
"resolve-from": {
"version": "2.0.0",
"resolved": "https://registry.npm.taobao.org/resolve-from/download/resolve-from-2.0.0.tgz",
"integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
}
}
},
"resolve": { "resolve": {
"version": "1.17.0", "version": "1.17.0",
"resolved": "https://registry.npm.taobao.org/resolve/download/resolve-1.17.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresolve%2Fdownload%2Fresolve-1.17.0.tgz", "resolved": "https://registry.npm.taobao.org/resolve/download/resolve-1.17.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresolve%2Fdownload%2Fresolve-1.17.0.tgz",
@@ -9110,6 +9403,15 @@
"resolved": "https://registry.npm.taobao.org/safer-buffer/download/safer-buffer-2.1.2.tgz", "resolved": "https://registry.npm.taobao.org/safer-buffer/download/safer-buffer-2.1.2.tgz",
"integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=" "integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo="
}, },
"saslprep": {
"version": "1.0.3",
"resolved": "https://registry.npm.taobao.org/saslprep/download/saslprep-1.0.3.tgz",
"integrity": "sha1-TAL5RrVs9UKX40e6EJPnrKxM8iY=",
"optional": true,
"requires": {
"sparse-bitfield": "^3.0.3"
}
},
"scmp": { "scmp": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npm.taobao.org/scmp/download/scmp-2.1.0.tgz", "resolved": "https://registry.npm.taobao.org/scmp/download/scmp-2.1.0.tgz",
@@ -9219,6 +9521,11 @@
"object-inspect": "^1.7.0" "object-inspect": "^1.7.0"
} }
}, },
"sift": {
"version": "7.0.1",
"resolved": "https://registry.npm.taobao.org/sift/download/sift-7.0.1.tgz?cache=0&sync_timestamp=1597975540611&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsift%2Fdownload%2Fsift-7.0.1.tgz",
"integrity": "sha1-R9YsULFZ0xbxNy+LU/nBDNIaSwg="
},
"signal-exit": { "signal-exit": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.3.tgz?cache=0&sync_timestamp=1585253373618&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsignal-exit%2Fdownload%2Fsignal-exit-3.0.3.tgz", "resolved": "https://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.3.tgz?cache=0&sync_timestamp=1585253373618&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsignal-exit%2Fdownload%2Fsignal-exit-3.0.3.tgz",
@@ -9240,6 +9547,11 @@
"is-fullwidth-code-point": "^2.0.0" "is-fullwidth-code-point": "^2.0.0"
} }
}, },
"sliced": {
"version": "1.0.1",
"resolved": "https://registry.npm.taobao.org/sliced/download/sliced-1.0.1.tgz",
"integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
},
"smart-buffer": { "smart-buffer": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npm.taobao.org/smart-buffer/download/smart-buffer-4.1.0.tgz", "resolved": "https://registry.npm.taobao.org/smart-buffer/download/smart-buffer-4.1.0.tgz",
@@ -9421,6 +9733,15 @@
"resolved": "https://registry.npm.taobao.org/source-map-url/download/source-map-url-0.4.0.tgz", "resolved": "https://registry.npm.taobao.org/source-map-url/download/source-map-url-0.4.0.tgz",
"integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=" "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM="
}, },
"sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npm.taobao.org/sparse-bitfield/download/sparse-bitfield-3.0.3.tgz",
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
"optional": true,
"requires": {
"memory-pager": "^1.0.2"
}
},
"spdx-correct": { "spdx-correct": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npm.taobao.org/spdx-correct/download/spdx-correct-3.1.1.tgz?cache=0&sync_timestamp=1590161967473&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fspdx-correct%2Fdownload%2Fspdx-correct-3.1.1.tgz", "resolved": "https://registry.npm.taobao.org/spdx-correct/download/spdx-correct-3.1.1.tgz?cache=0&sync_timestamp=1590161967473&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fspdx-correct%2Fdownload%2Fspdx-correct-3.1.1.tgz",
@@ -10060,6 +10381,14 @@
"tslib": "^1.8.1" "tslib": "^1.8.1"
} }
}, },
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npm.taobao.org/tunnel-agent/download/tunnel-agent-0.6.0.tgz",
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"type": { "type": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npm.taobao.org/type/download/type-1.2.0.tgz", "resolved": "https://registry.npm.taobao.org/type/download/type-1.2.0.tgz",
@@ -10109,6 +10438,11 @@
"random-bytes": "~1.0.0" "random-bytes": "~1.0.0"
} }
}, },
"ultron": {
"version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/ultron/download/ultron-1.0.2.tgz",
"integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po="
},
"underscore": { "underscore": {
"version": "1.10.2", "version": "1.10.2",
"resolved": "https://registry.npm.taobao.org/underscore/download/underscore-1.10.2.tgz?cache=0&sync_timestamp=1585605854253&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Funderscore%2Fdownload%2Funderscore-1.10.2.tgz", "resolved": "https://registry.npm.taobao.org/underscore/download/underscore-1.10.2.tgz?cache=0&sync_timestamp=1585605854253&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Funderscore%2Fdownload%2Funderscore-1.10.2.tgz",
@@ -10404,6 +10738,15 @@
"mkdirp": "^0.5.1" "mkdirp": "^0.5.1"
} }
}, },
"ws": {
"version": "1.1.5",
"resolved": "https://registry.npm.taobao.org/ws/download/ws-1.1.5.tgz?cache=0&sync_timestamp=1593925670988&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fws%2Fdownload%2Fws-1.1.5.tgz",
"integrity": "sha1-y9nm514J/F0skAFfIfDECHXg3VE=",
"requires": {
"options": ">=0.0.5",
"ultron": "1.0.x"
}
},
"wt": { "wt": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npm.taobao.org/wt/download/wt-1.2.0.tgz", "resolved": "https://registry.npm.taobao.org/wt/download/wt-1.2.0.tgz",

View File

@@ -22,23 +22,29 @@
"clean": "ets clean" "clean": "ets clean"
}, },
"dependencies": { "dependencies": {
"@typegoose/typegoose": "^7.3.4",
"csprng": "^0.1.2", "csprng": "^0.1.2",
"egg": "^2.6.1", "egg": "^2.6.1",
"egg-alinode": "^2.0.1",
"egg-cors": "^2.2.3",
"egg-scripts": "^2.6.0", "egg-scripts": "^2.6.0",
"mongoose": "^5.10.1",
"reflect-metadata": "^0.1.13",
"underscore": "^1.10.2" "underscore": "^1.10.2"
}, },
"devDependencies": { "devDependencies": {
"@types/mocha": "^2.2.40", "@types/mocha": "^2.2.40",
"@types/mongoose": "^5.7.36",
"@types/node": "^7.0.12", "@types/node": "^7.0.12",
"@types/supertest": "^2.0.0", "@types/supertest": "^2.0.0",
"autod": "^3.0.1", "autod": "^3.0.1",
"autod-egg": "^1.1.0", "autod-egg": "^1.1.0",
"egg-ci": "^1.8.0",
"egg-bin": "^4.11.0", "egg-bin": "^4.11.0",
"egg-ci": "^1.8.0",
"egg-mock": "^3.16.0", "egg-mock": "^3.16.0",
"tslib": "^1.9.0",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-config-egg": "^8.0.0", "eslint-config-egg": "^8.0.0",
"tslib": "^1.9.0",
"typescript": "^3.0.0" "typescript": "^3.0.0"
}, },
"engines": { "engines": {