kohapi
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-bate1.0.2 • Public • Published

kohapi

基于 Koa 的 Node 服务端框架(完善中……)

项目结构

src
  modules
    product
      apis
        get-product.js
    user
      apis
        get-user.js
  index.js

src/index.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

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

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

Readme

Keywords

Package Sidebar

Install

npm i kohapi

Weekly Downloads

7

Version

0.0.1-bate1.0.2

License

MIT

Unpacked Size

7.65 kB

Total Files

9

Last publish

Collaborators

  • gqxqd