akos-handcustomcode

0.0.3 • Public • Published

akos-handCustomCode

hand custom formatting return

introduce

  1. option.ResponseCode The custom code you want.
    // default
       {
         Success: 200,
         Unauthorized: 401,
         Invalid: 403,
         NotFound: 404,
         InternalError: 500,
     }
     
    
  2. Provide method
  • throwCodeError
  • setCodeError
  • setBodyResult
  • setBodyContent
  1. for example
  async userInfo() {
        const ctx = this.ctx;
        //  a method to get user from mysql
        const user = await ctx.service.user.getInfo()
        ctx.setBodyContent(200, user)
    }

you will get the result

{
    code: 200,
    result: {
        //....userInfo....
    }
}

Readme

Keywords

Package Sidebar

Install

npm i akos-handcustomcode

Weekly Downloads

1

Version

0.0.3

License

ISC

Unpacked Size

6.22 kB

Total Files

4

Last publish

Collaborators

  • blue_lin