# @backlib/koa

> Minimalist KOA utilities for backend web services

Latest version **0.6.0** (published 2026-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @backlib/koa
pnpm add @backlib/koa
yarn add @backlib/koa
bun add @backlib/koa
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2026-01-07 |
| First published | 2020-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.10 |
| Dependencies | 5 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jeremy.chone@gmail.com |
| Maintainers | jeremychone |

## Links

- npm: https://www.npmjs.com/package/@backlib/koa
- Repository: https://github.com/britesnow/node-backlib-koa
- Homepage: https://github.com/britesnow/node-backlib-koa#readme
- Issues: https://github.com/britesnow/node-backlib-koa/issues
- npm.io page: https://npm.io/package/@backlib/koa

## Dependencies (5)

- [koa](https://npm.io/package/koa.md) ^3.1.1
- [@types/koa](https://npm.io/package/@types/koa.md) ^3.0.1
- [@koa/router](https://npm.io/package/@koa/router.md) ^15.2.0
- [koa-compose](https://npm.io/package/koa-compose.md) ^4.1.0
- [@types/koa__router](https://npm.io/package/@types/koa__router.md) ^12.0.5

## Recent versions

- 0.6.0 (latest) — 2026-01-07
- 0.5.1-SNAPSHOT.2 (SNAPSHOT) — 2022-03-12
- 0.5.2 — 2022-03-13
- 0.5.1-SNAPSHOT.1 — 2022-03-11
- 0.5.0 — 2022-01-23
- 0.5.0-SNAPSHOT.1 — 2022-01-23
- 0.4.0 — 2022-01-20
- 0.4.0-SNAPSHOT.2 — 2022-01-20
- 0.4.0-SNAPSHOT.1 — 2022-01-20
- 0.3.6 — 2021-07-25
- 0.3.6-SNAPSHOT.1 — 2021-07-25
- 0.3.5 — 2021-03-20
- 0.3.4 — 2021-02-27
- 0.3.3 — 2021-02-15
- 0.3.2 — 2021-01-11
- … 5 more at https://npm.io/package/@backlib/koa/versions

## README

BaseKoa class with typescript decorators for routing based on [koa](https://www.npmjs.com/package/koa) and [@koa/router](https://www.npmjs.com/package/@koa/router)


```ts
import Koa, { DefaultContext, DefaultState } from 'koa';
import { BaseRouter, routeGet } from '@backlib/koa';

//// EXAMPLE - BaseRouter for class/decorator style API
class Hello3 extends BaseRouter<DefaultState, DefaultContext>{
	#count = 0;

	@routeGet('hello3')
	async hello(ctx: DefaultContext) {
		this.#count++;
		ctx.body = {
			message: `Hello3 from server ${this.#count}`
		}
	}
}

async function main() {

	const app = new Koa();

	const hello3 = new Hello3('/api/');
	app.use(hello3.middleware());   
    
	app.listen(8080);    
}

// Now http://localhost:8080/api/hello3 will return {message: "Hello3 from server ..."}
```


- **Typed** Build with typescript for typescript.
- **Modern** Node.js 14 and above, compiled with native class fields and null coalescing native support. 
- **Minimalist** Not a framework, just some libs that can be assembled into an application infrastructure code.
- **PromiseAsync/Await centric** Use Promise/async/await patterns for all async calls. 
- **Web Async** Web request utilities based on [koajs](https://koajs.com/) over express as it is a modern rewrite of more or less the same API with backed in support for Promise/async/await (simplify many of the usecases)

---
_Source: https://npm.io/package/@backlib/koa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
