koahubjs / koahub-demo-promise

koahub-demo-promise

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KoaHub.js demo (Promise)

KoaHub.js

KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架。可以直接在项目里使用 ES6/7(Generator Function, Class, Async & Await)等特性,借助 Babel 编译,可稳定运行在 Node.js 环境上。

github地址:http://github.com/koahubjs/koahub

demo

下载安装

// 下载demo
git clone https://github.com/koahubjs/koahub-demo-promise.git
// 进入项目
cd koahub-demo-promise
// 安装依赖
npm install
// 启动项目
npm start

浏览器访问

http://localhost:3000

快捷方法中间件, 自定义post/file中间件

// use koa-body
koa.use(function (ctx, next) {

    if (!ctx.request.body.files) {
        ctx.post = ctx.request.body;
    } else {
        ctx.post = ctx.request.body.fields;
        ctx.file = ctx.request.body.files;
    }

    return next();
});

常见问题

1.模版引擎慢

默认模版引擎关闭了缓存,修改模版问题会立即生效。正式环境建议开启缓存,速度将提升10倍。

官网

KoaHub.js官网

About

koahub-demo-promise


Languages

Language:JavaScript 91.2%Language:HTML 8.8%