npm.io
0.0.3 • Published 7 years ago

pplgin-owl

Licence
ISC
Version
0.0.3
Deps
10
Size
24 kB
Vulns
25
Weekly
0
DeprecatedThis package is deprecated

Owl

框架底层基于 Koa2 实现,兼容 Koa的所有功能, 支持ES6

Owl核心内容

  • Loader (主要将对应目录下的文件挂载到对应的对象上去 目前支持 :model、controller、service、router对象)
  • Extend (扩展原有context对象,暂不支持自定义)
  • Logger 日志集成
  • Router 集成
使用方式

环境要求: node >=9

引入owl(具体事例可以参考app文件夹)

const path = require('path')
const { OwlApplication } = require('../lib/owl.js')
const { pkg, logFilePath } = require('./config')
const app = new OwlApplication({
	pkg,
	logFilePath,
	rootPath:__dirname,
  viewRoot: path.join(__dirname, 'views'),
})
// 启动
app.bootstrap()

controller层

const { Controller } = require('../../lib/owl')
module.exports = class Home extends Controller {
	test() {
		// this.ctx.coreLogger.info('111')
		// let s = this.ctx.service.name.m.list()
		// this.test1()
		this.ctx.body = 'this is home!'
	}

	test1() {
		console.log('xxx')
	}
}

service 层

const { Service } = require('../../lib/owl')

module.exports = class NewsService extends Service {
  list(page = 1) {
    return {
      id: 1,
      contest: 'test'
    }
  }
}