koa-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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 {
  resultnull,
  messages["A user friendly message"];
  successfalse;
  errors[{ code: 123, "Something is wrong" }];
}

License

MIT, see LICENSE.

Readme

Keywords

Package Sidebar

Install

npm i koa-utils

Weekly Downloads

1

Version

0.0.4

License

MIT

Last publish

Collaborators

  • marvinhagemeister