Work

@4lch4/koa-oto

Node
TypeScript
Libraries
Koa.js

A wrapper for handling responses in Koa.js.

Repo

An AI generated image of "a rack of futuristic looking servers in a data center."

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

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')
})