1.0.2 • Published 3 years ago

kh-server v1.0.2

Weekly downloads
7
License
MIT
Repository
-
Last release
3 years ago

kh-server

基于 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('kh-server');

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('kh-server');

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

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago