Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pplgin/owl
基于koa2封装的node framework
https://github.com/pplgin/owl
koa2 koa2-router node-framework web-application
Last synced: about 1 month ago
JSON representation
基于koa2封装的node framework
- Host: GitHub
- URL: https://github.com/pplgin/owl
- Owner: pplgin
- License: mit
- Created: 2018-12-20T08:18:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-24T04:03:29.000Z (over 5 years ago)
- Last Synced: 2024-09-30T21:05:35.484Z (about 2 months ago)
- Topics: koa2, koa2-router, node-framework, web-application
- Language: JavaScript
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Owl
>框架底层基于 Koa2 实现,兼容 Koa的所有功能, 支持ES6
## Owl核心内容
- Loader (主要将对应目录下的文件挂载到对应的对象上去 目前支持 :`model、controller、service、router对象`)
- Extend (扩展原有context对象,暂不支持自定义)
- Logger 日志集成
- Router 集成## 使用方式
环境依赖: node >=9
```
npm install @pplgin/owl
```## Example
代码目录结构
```
├── app.js
├── config.js
├── controller
├── middleware
├── model
├── router
├── service
└── views
```引入owl(具体事例可以参考app文件夹)
```javascript
const path = require('path')
const { OwlApplication } = require('@pplgin/owl')
const { pkg, logConfig } = require('./config')
const app = new OwlApplication({
pkg,
rootPath:__dirname,
viewRoot: path.join(__dirname, 'views'),
logConfig
})
// 启动
app.bootstrap()
```middleware
```javascript
module.exports = [
logger, //[logger, { options }]
]
```controller层
```javascript
const { Controller } = require('@pplgin/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层
```javascript
const { Service } = require('@pplgin/owl')module.exports = class NewsService extends Service {
list(page = 1) {
return {
id: 1,
contest: 'test'
}
}
}
```