# kohapi

> A node server base koa.js

Latest version **0.0.1-bate1.0.2** (published 2021-01-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install kohapi
pnpm add kohapi
yarn add kohapi
bun add kohapi
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-bate1.0.2 |
| Published | 2021-01-29 |
| First published | 2021-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | KOHAI |
| Maintainers | gqxqd |
| Keywords | Koa, kohapi |

## Links

- npm: https://www.npmjs.com/package/kohapi
- Repository: https://gitee.com/kohai/kohapi
- Homepage: https://kohai.gitee.io/kohapi
- npm.io page: https://npm.io/package/kohapi

## Dependencies (3)

- [koa](https://npm.io/package/koa.md) ^2.13.1
- [koa-body](https://npm.io/package/koa-body.md) ^4.2.0
- [@koa/router](https://npm.io/package/@koa/router.md) ^10.0.0

## Recent versions

- 0.0.1-bate1.0.2 (latest) — 2021-01-29
- 0.0.1-bate1.0.1 — 2021-01-23
- 0.0.1-bate1.0.0 — 2021-01-15
- 0.0.1 — 2021-01-15

## README

# kohapi

> 基于 Koa 的 Node 服务端框架（完善中……）

## 项目结构
```
src
  modules
    product
      apis
        get-product.js
    user
      apis
        get-user.js
  index.js
```

### `src/index.js`

```js
const path = require('path');
const { createApp, createApis } = require('kohapi');

createApp()
    .use(createApis({ dirname: path.join(__dirname, 'modules/**/apis') }))
    .listen(3000, () => {
        console.log('Server is running at http://localhost:3000');
    });

```

### `src/modules/product/apis/get-product.js`

```js
const { defineApi } = require('kohapi');

module.exports = defineApi({
    method: 'get',
    path: '/product',
    description: 'get a product by id',
    handler: () => {
        return 'get a product by id';
    },
});
```

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