Giter Site home page Giter Site logo

owl's Introduction

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文件夹)

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

module.exports = [
    logger, //[logger, { options }]
]

controller层

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层

const { Service } = require('@pplgin/owl')

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

owl's People

Contributors

pplgin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.