Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/piing-as/koa-caseof

Koa Middleware for handling branching routes based on property in Context
https://github.com/piing-as/koa-caseof

koa koa2 middleware nodejs router server

Last synced: 10 days ago
JSON representation

Koa Middleware for handling branching routes based on property in Context

Awesome Lists containing this project

README

        

# koa-caseof

Koa Middleware for handling branching routes based on Context

### Install
```bash
npm i @piing/koa-caseof
```

### Usage
```typescript

import KoaRouter from "koa-router"
import caseof from "@piing/koa-caseof"

const router = new KoaRouter();

router.get("/items/",
authenticate,
caseof( "user.type", {
Admin: itemController.getAll,
User: itemController.getAllBelongingToUser
}))

```