npm

@pkb/node-box

1.5.4 • Public • Published

node-box

基于 koa 封装轻量级的 node 应用,开箱即用

安装

npm i @pkb/node-box -g # 全局安装/本地安装

node-box build # 构建项目
node-box watch # 开发模式

目录

-- app 
  -- controller
  -- router
-- public # 静态资源

controller 示例

controller/home.js

'use strict';

class HomeController {
  async one({ ctx, next }) {

    ctx.body = {
      content: 'one',
    };
  }

  async two({ ctx, next }) {

    ctx.body = {
      content: 'two',
    };
  }
}

module.exports = HomeController;

router 示例

router/home.js

'use strict';

module.exports = app => {
  const { router, controller } = app;

  router.get('/one', controller.home.one);
  router.get('/two', controller.home.two);
  router.get('/');
};

Readme

Keywords

none

Package Sidebar

Install

npm i @pkb/node-box

Weekly Downloads

2

Version

1.5.4

License

none

Unpacked Size

8.63 kB

Total Files

17

Last publish

Collaborators

  • xuege2019
  • liuys
  • happyweb