Sign In

rock-cli

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rock-cli - npm Package Compare versions

Comparing version
0.0.6
to
0.0.7
+2
-2
package.json
{
"name": "rock-cli",
"version": "0.0.6",
"version": "0.0.7",
"description" : "A scaffold based on koa2",

@@ -14,3 +14,3 @@ "keywords" : [

"bin": {
"rock": "./bin/rock.js"
"rock": "bin/rock.js"
},

@@ -17,0 +17,0 @@ "repository": {

const fs = require('fs');
const tools = require('../utils/tools.js');

@@ -16,15 +15,3 @@ let controller = {};

//判断对象是否为构造函数
if(typeof(child_model) === "function"){
let fn = new child_model();
controller[name] = fn;
} else if (typeof(child_model) === "object") {
//继承工具类
for(let key in child_model){
if(typeof(child_model[key]) === 'function'){
child_model[key] = child_model[key].bind( Object.freeze(tools) );
};
};
controller[name] = child_model;
}
controller[name] = child_model;

@@ -31,0 +18,0 @@ }

//MYSQL 对象关系映射
const model = require('../models');
const { tools_token, tools_res } = require('../utils/tools.js');
class Product {
constructor (){
this.a = 1;
}
/**
* 查询用户信息
*/
async getUserInfo ( ctx ) {
console.log(ctx)
console.log(this.a)
try {
//console.log(ctx.token({user: '123'}))
static async getUserInfo ( ctx ) {
console.log(this);
try
const data = await model.user.findAll({
'attributes' : ['id']
});
this.tools_res.success(ctx, data, 'success');
tools_res.success(ctx, data, 'success');
} catch (e){
this.tools_res.error(ctx, 500, e);
tools_res.error(ctx, 500, e);
}
}
async geProxytUserInfo ( ctx ) {
static async geProxytUserInfo ( ctx ) {
try {
const fn = new ctx.Proxy({});
const data = await fn.request();
this.tools_res.success(data, 'success');
}catch(e){
this.tools_res.error(500, e);
tools_res.success(data, 'success');
} catch (e){
tools_res.error(500, e);
}

@@ -40,3 +34,3 @@ }

*/
async addUserInfo ( ctx ) {
static async addUserInfo ( ctx ) {
try {

@@ -47,5 +41,5 @@ const data = await model.user.create({

});
this.tools_res.success(ctx, data, 'success');
tools_res.success(ctx, data, 'success');
} catch (e){
this.tools_res.error(ctx, 500, e);
tools_res.error(ctx, 500, e);
}

@@ -57,4 +51,4 @@ }

*/
async setUserInfo ( ctx ) {
let data = null, result = null;
static async setUserInfo ( ctx ) {
let result = null;
try {

@@ -69,10 +63,10 @@ const data = await model.user.findOne({

result = await data.save();
this.tools_res.success(result, 'success');
tools_res.success(ctx, result, 'success');
} catch (e){
this.tools_res.error(500, e);
tools_res.error(ctx, 500, e);
}
}
}
};

@@ -79,0 +73,0 @@

//MYSQL 对象关系映射
const model = require('../models');
const { tools_token, tools_res } = require('../utils/tools.js');

@@ -14,5 +15,5 @@ const User = {

});
this.tools_res.success(ctx, data, 'success');
tools_res.success(ctx, data, 'success');
} catch (e){
this.tools_res.error(ctx, 500, e);
tools_res.error(ctx, 500, e);
}

@@ -25,5 +26,5 @@ },

const data = await fn.request();
this.tools_res.success(data, 'success');
}catch(e){
this.tools_res.error(500, e);
tools_res.success(data, 'success');
} catch (e){
tools_res.error(500, e);
}

@@ -41,5 +42,5 @@ },

});
this.tools_res.success(ctx, data, 'success');
tools_res.success(ctx, data, 'success');
} catch (e){
this.tools_res.error(ctx, 500, e);
tools_res.error(ctx, 500, e);
}

@@ -52,3 +53,3 @@ },

async setUserInfo ( ctx ) {
let data = null, result = null;
let result = null;
try {

@@ -63,6 +64,6 @@ const data = await model.user.findOne({

result = await data.save();
this.tools_res.success(result, 'success');
tools_res.success(ctx, result, 'success');
} catch (e){
this.tools_res.error(500, e);
tools_res.error(ctx, 500, e);
}

@@ -69,0 +70,0 @@ }

@@ -8,3 +8,2 @@ const router = require('koa-router');

});
routers.get('/search', Product.getUserInfo)

@@ -11,0 +10,0 @@ .get('/proxy', Product.geProxytUserInfo)

@@ -11,3 +11,3 @@ const jwt = require('jsonwebtoken');

*/
createToken : (ctx, data, expiresIn) => {
'createToken' : (ctx, data, expiresIn) => {
/**

@@ -36,3 +36,3 @@ * 生成口令

*/
checkToken : (ctx, token) => {
'checkToken' : (ctx, token) => {
try {

@@ -53,3 +53,3 @@ let decoded = jwt.verify(token, auth.secret);

success : (ctx, result, msg ) => {
'success' : (ctx, result, msg ) => {
ctx.body = {

@@ -62,3 +62,3 @@ 'code' : 200,

error : (ctx, code, msg ) => {
'error' : (ctx, code, msg ) => {
ctx.body = {

@@ -65,0 +65,0 @@ 'code' : code,