egg-full-utils
Chinese 中文
Important
crypto-js@3.1.9-1 uuid@3.3.2
Install
$ npm i egg-full-utils --save
Usage
// {app_root}/config/plugin.jsexportsfullUtils = enable: true package: 'egg-full-utils';
Configuration
// {app_root}/config/config.default.jsexportsfullUtils = /** * ctx.success() => { code: 'success', data: null } */ success: 'success';
see config/config.default.js for more detail.
Example
'use strict'; module { Controller /** * get: /login?name=xxx&password=123456 * response: { code: success, data: { userId }}, status: 200 */ async { const result = thisserviceuser; ctx; } return UserController;}; module { Service async { const ctx = this; const payload = ctxrequestbody || {}; // get user from db or cache by payload.name const user = userId: '10001' password: '07e38ba001d5df0dd4488cdf0d5ab8ea' salt: 'P7yRKQymchIZ5ZpP' ; // check password if userpassword !== ctxhelper return ctx; return ctx; } return UserService;};