A library for responding to requests within the Koa framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Devin W. Leaman ad02ad2242 feat: added lint steps to scripts 2 months ago
sample feat: updated sample 1 year ago
src feat: arguably the dumbest way to test this... 1 year ago
tests feat: final addition to tests for now 1 year ago
.drone.yml refactor(.drone.yml): trying something different... 2 months ago
.gitignore chore: updated gitignore 2 months ago
.nvmrc chore: added .npmrc/.nvmrc 1 year ago
.nycrc.json feat: fixed up code coverage reports 1 year ago
.prettierignore feat: initial commit 1 year ago
.prettierrc feat: initial commit 1 year ago
README.md refactor(README): updated badges 2 months ago
package-lock.json 1.3.2 5 months ago
package.json feat: added lint steps to scripts 2 months ago
publish.sh feat: added a publish script 1 year ago
tsconfig.json feat: disabled removeComments 5 months ago

README.md

Drone (self-hosted) with branch Codecov Codacy Badge

NPM Standard-Js

@4lch4/koa-oto

This library is a responder library for handling responses within the Koa framework.

The Name

The name "Koa-Ōtō" is a combination of Koa (duh), and the Japanese Romaji version of 応答 (Ōtō) which means "Respond".

NOTE: According to Google Translate at least 😅

Example Usage

It isn't much, but this is the most basic way to use the library within your API:

import { ClientErrors, Successful } from '@4lch4/koa-oto'
import Router from '@koa/router'
import Koa from 'koa'

const app = new Koa()
const router = new Router()

router.get('/', async ctx => Successful.ok(ctx, 'Hello World'))
router.get('/error', ctx => ClientErrors.badRequest(ctx, 'Bad Request'))

app.use(router.routes())
app.use(router.allowedMethods())

app.listen(3000, () => {
  console.log('Server is running on port 3000')
})

Testing and Coverage

I went a really weird route for testing this library, but in the end I've achieved a solid coverage percentage in CodeCov. The following images are an icicle and grid representation of the current test coverage:

Code-Coverage-Icicle

Code-Coverage-Tree

Icicle: The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.

Grid: Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.