0.0.2 • Published 7 years ago

middleware_framework_checkargs v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

验证参数

使用方法

const cArgs = require('./index');

// 从每个msg实例获取(此处是模拟)
let args = {
    'headers': {
        'identification-decode': 'String' // 注意identification解密后字段名改变了,这里需要写成identification-decode
    },
    'get': null,
    'post': {
        'url': 'String',
        'most': {
            'date': 'String',
            'context': 'Object',
            'user_id': 'Number'
        },
        'other': 'Array',
        'isx': 'Boolean'
    }
};

// 解密后req(此处是模拟)
let req = {
    'query' : {},
    'headers': {
        'identification-decode': 'asdfghjkl' // 注意identification解密后字段名改变了
    },
    'body': {
        'url': 'sad',
        'most': {
            'date': 'abc',
            'context': {},
            'user_id': 1
        },
        'other': [],
        'isx': true
    }
}


cArgs.checkArgs(args, req, function(e, msg){
    console.log(e)
    console.log(msg)
})