kf-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

kf-sdk

HTTP ERROR USAGE

// FOR CASE SUCCESS
import { HTTP_CONFIG } from 'kf-sdk';
@get('/', {
  responses: {
    '200': OBJECT_EXAMPLE,
  },
})
async version(): Promise<Object> {
  return this.responseSuccess(
    HTTP_CONFIG.OK.code,
    {
      ip: this.req.ip,
      name: this.servicename
    }
  )
}

// FOR CASE ERROR
import { HTTP_CONFIG } from 'kf-sdk';
@get('/', {
  responses: {
    '200': OBJECT_EXAMPLE,
  },
})
async version(): Promise<Object> {
  return this.responseSuccess(
    HTTP_CONFIG.errorPasswordInvalid.code,
    {
      ip: this.req.ip,
      name: this.servicename
    }
  )
}

export class VersionController extends KFController {
  constructor(
    @inject(RestBindings.Http.REQUEST) private req: Request,
    @inject(RestBindings.Http.RESPONSE) protected response: Response,
    @inject('service.name') private servicename: String
  ) {
    super();
  }

  @get('/', {
    responses: {
      '200': PING_RESPONSE,
    },
  })
  async version(): Promise<Object> {
    return this.responseFailed(
      HTTP_CONFIG.OK.code,
      {
        ip: this.req.ip,
        name: this.servicename,
        version: require('../../package.json').version,
      }
    )
  }
}

Package Sidebar

Install

npm i kf-sdk

Weekly Downloads

1

Version

1.0.8

License

none

Unpacked Size

99.6 kB

Total Files

104

Last publish

Collaborators

  • hoanh.nguyen