0.0.4 • Published 7 years ago

koa-utils v0.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Koa Utils

Slim Boilerplate for TypeScript based projects.

Installation

# npm
npm install --save koa-utils

# yarn
yarn add koa-utils

Usage

const Koa = require("koa");
const { handleErrors } = require("koa-utils");

// Create server with error handler
const server = new Koa()
  .use(handleErrors());

server.listen(8080, () => console.log("Server started"));

handleErrors

Generic error handler for rest apis. Creates a response with the following structure:

ErrorResponse {
  result: null,
  messages: ["A user friendly message"];
  success: false;
  errors: [{ code: 123, "Something is wrong" }];
}

License

MIT, see LICENSE.