rekoa

2019-06-13 admin

rekoa是什么

什么是rekoa,a simple web framework based on koa.

rekoa使用教程帮助文档

rekoa

a simple web framework based on koa.

features

  • autoload middlewares, contexts and controllers
  • auto hot reload without the need to restart the server

example

// index.js
require('babel/register'); // use babel to transform es7 async/await
var app = require('rekoa');

app({
  isDevelopment: true,
  base: __dirname,
  path: {
    middleware: path.join(__dirname, 'middleware'),
    controller: path.join(__dirname, 'controller')
  }
}).start();

// middleware/teapot
module.exports = async function (next) {
  this.name = "jack";
  await next;
};

// controller/greet.js

module.exports = [
  {
    url: '/greet',
    controller: async function () {
      this.body = "hello, i am " + this.name;
    }
  }
];

visit http://localhost:8080/ you will get hello, i am jack and change middleware or controller file and save, you will get a new result without server restart.

A more featured example is under example folder.

license

MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-67222.html

文章标题:rekoa

回到顶部