代码拉取完成,页面将自动刷新
同步操作将从 doodooke/doodoo.js 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Doodoo.js -- 中文最佳实践Node.js Web快速开发框架。支持Koa.js中间件。
//base controller, app/demo/controller/base.js
module.exports = class extends doodoo.Controller {
async _initialize() {
console.log('base _initialize');
}
async isLogin() {
console.log('base isLogin');
}
}
//index controller, app/demo/controller/index.js
const base = require('./base');
module.exports = class extends base {
async _initialize() {
await super._initialize();
}
async index() {
this.success("Hello Doodoo.js");
}
async index2() {
this.fail("Hello Doodoo.js");
}
}
环境要求:Node.js >= 7.6.0
yarn add doodooke/doodoo.js
// app/index.js启动文件
const Doodoo = require('doodoo.js');
// 初始化项目
const app = new Doodoo();
// 启动项目
app.start();
ctx上的函数或参数将自动加载到controller,例如支持 this.body = 'Hello World!'
, ctx中具体的API请参考Koa.js, controller中的扩展方法如下。
this.ctx;
this.next;
this.isGet();
this.isPost();
this.isAjax();
this.isPjax();
this.isMethod(method);
this.hook.run(name, ...args);
this.download(file);
this.view(data);
this.success(errmsg: "ok", errcode: 0, data: data);
this.error(errmsg = "error", errcode = 1);
# 应用配置
APP_ROOT=app
APP_PORT=3000
APP_HOST=127.0.0.1
# MYSQL数据库链接
MYSQL=true
MYSQL_HOST=127.0.0.1
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=doodoo
MYSQL_PORT=3306
MYSQL_CHARSET=utf8mb4
# REDIS链接
REDIS=false
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PREFIX=doodoo:
# 静态资源服务
STATIC_DIR=www
STATIC_MAXAGE=30 * 24 * 60 * 60
STATIC_DYNAMIC=true
// 控制器初始化,前置,后置,空操作
async _initialize()
async _before()
async _before_index()
async index()
async _after_index()
async _after()
// 下载demo
git clone https://github.com/doodooke/doodoo.js.git
// 安装依赖
yarn install
// 进入项目
cd doodoo.js/example
// 启动项目
node app.js
[doodoo] Version: 1.0.1
[doodoo] Website: 127.0.0.1
[doodoo] Nodejs Version: v10.5.0
[doodoo] Nodejs Platform: darwin x64
[doodoo] Server Enviroment: development
[doodoo] Server Startup Time: 212ms
[doodoo] Server Current Time: 2018-08-21 11:17:19
[doodoo] Server Running At: http://127.0.0.1:3000
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。