Nuclearly Potent Moonshine

    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....
        }
    }
    

    Install

    npm i akos-handcustomcode

    DownloadsWeekly Downloads

    0

    Version

    0.0.3

    License

    ISC

    Unpacked Size

    6.22 kB

    Total Files

    4

    Last publish

    Collaborators

    • blue_lin