aotoo-koa-server
based on koa2
Last updated a year ago by webkixi .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install aotoo-koa-server 
SYNC missed versions from official npm registry.

aotoo-koa-server

web service, based on koa2, with router and plugins
easier to build koa web service aotoo-koa-server基于koa2完成,支持基础路由、镜像路由,静态资源,插件plugins机制等

demo source

  • 支持KOA中间件(base on koa)
    基于KOA2,支持 koa2 middleware

  • 支持Aotoo组件(aotoo sync component)
    使用Aotoo的组件,可以在NODE中使用,一套结构,多端使用,【aotoo】

  • 支持镜像路由(mirror route)
    按照目录命名规则,自动render及匹配相关静态资源

  • 灵活的自定义路由(custom route)
    自定义路由机制

  • 多层restful(multiple restful api)
    简单、多层restful支持,默认3层

  • API机制(sandwich api across backend)
    组件间通信简单、灵活

  • 插件机制(plugins)
    方便快捷的开发组件

  • 支持websocket
    组件都支持JSX与实例双模式

目录结构

root
  │            
  ├── dist 
  │    ├── html 
  │    │    └── demo.html
  │    ├── js 
  │    │    └── demo.js
  │    └── css 
  │         └── demo.css
  │    
  ├── server 
  │    │
  │    ├── index.js
  │    │
  │    ├── pages 
  │    │    └── demo.js
  │    │
  │    └── plugins 
  │         └──docs
  │             └──index.js
  │
  └── .babelrc

Babel依赖

// .babelrc
{
  "presets": [
    "react",
    "es2015",
    "stage-0"
  ],
  "plugins": [
    [
      "transform-runtime",
      {
        "polyfill": true,
        "regenerator": true
      }
    ]
  ]
}

前端

静态JS

/dist/js/demo.js

console.log('i am demo.js')

静态CSS

/dist/css/demo.css

body{
  font-size: 16px;
}

NODE端

初始化

cd root
yarn init
yarn add aotoo-koa-server

配置

serve/index.js

const path = require('path')
const aks = require('aotoo-koa-server')

const _mapper = {
  js: {
    demo: 'demo.js'
  },
  css: {
    demo: 'demo.css'
  }
}

const app = aks({
  root: path.join(__dirname, '../dist/html'),  
  index: 'demo',
  pages: path.join(__dirname, './pages'),
  pluginsFolder: path.join(__dirname, './plugins'),
  mapper: _mapper
})

app.statics(path.join(__dirname, '../dist/js'), {
  prefix: '/js'
})

app.statics(path.join(__dirname, '../dist/css'), {
  prefix: '/css'
})


app.listen(3000)

Control层

/server/pages/demo.js(C)
MVC的control层

function index(oridata) {
  return {
    get: async function(ctx){
      oridata.fkp = 'Aotoo-koa-server'
      return oridata;
    },

    post: async function(ctx){
      return {pdata: 'post数据'}
    }
  }
}
export { index as getData }

View层

/dist/html/index.html(V)
MVC的view层
支持ejs、handbars语法,基于art-template模板引擎

<!DOCTYPE html>
<html lang="en">
  <head>
    ...
  </head>
  <body>
    <h1>Hello <%=fkp%></h1>
  </body>
</html>

运行

node server/index.js

Current Tags

  • 2.2.17                                ...           latest (a year ago)

106 Versions

  • 2.2.17                                ...           a year ago
  • 2.2.16                                ...           a year ago
  • 2.2.15                                ...           a year ago
  • 2.2.14                                ...           a year ago
  • 2.2.13-beta1                                ...           a year ago
  • 2.2.13                                ...           a year ago
  • 2.2.12-beta2                                ...           a year ago
  • 2.2.12                                ...           a year ago
  • 2.2.11                                ...           a year ago
  • 2.2.10                                ...           a year ago
  • 2.2.9                                ...           a year ago
  • 2.2.8                                ...           2 years ago
  • 2.2.7                                ...           2 years ago
  • 2.2.6-beta9                                ...           2 years ago
  • 2.2.6-beta8                                ...           2 years ago
  • 2.2.6-beta7                                ...           2 years ago
  • 2.2.6-beta6                                ...           2 years ago
  • 2.2.6-beta5                                ...           2 years ago
  • 2.2.6-beta4                                ...           2 years ago
  • 2.2.6-beta3                                ...           2 years ago
  • 2.2.6-beta2                                ...           2 years ago
  • 2.2.6-beta1                                ...           2 years ago
  • 2.2.6                                ...           2 years ago
  • 2.2.5                                ...           2 years ago
  • 2.2.4                                ...           2 years ago
  • 2.2.3-beta4                                ...           2 years ago
  • 2.2.3-beta3                                ...           2 years ago
  • 2.2.3-beta2                                ...           2 years ago
  • 2.2.3-beta1                                ...           2 years ago
  • 2.2.3                                ...           2 years ago
  • 2.2.2                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.1.7                                ...           2 years ago
  • 2.1.6                                ...           2 years ago
  • 2.1.5                                ...           2 years ago
  • 2.1.4                                ...           2 years ago
  • 2.1.3                                ...           2 years ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.0.7                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.6                                ...           2 years ago
  • 2.0.5                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3-1                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1-1                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0-1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.7.3                                ...           2 years ago
  • 1.7.2                                ...           2 years ago
  • 1.7.1                                ...           2 years ago
  • 1.7.0                                ...           2 years ago
  • 1.6.0                                ...           2 years ago
  • 1.5.0                                ...           2 years ago
  • 1.4.2                                ...           2 years ago
  • 1.4.1                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.1                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.13                                ...           2 years ago
  • 1.1.12                                ...           2 years ago
  • 1.1.11                                ...           2 years ago
  • 1.1.10                                ...           2 years ago
  • 1.1.9                                ...           2 years ago
  • 1.1.7                                ...           2 years ago
  • 1.1.6                                ...           2 years ago
  • 1.1.5                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.18                                ...           2 years ago
  • 1.0.17                                ...           2 years ago
  • 1.0.16                                ...           2 years ago
  • 1.0.15                                ...           2 years ago
  • 1.0.14                                ...           2 years ago
  • 1.0.13-beta1                                ...           2 years ago
  • 1.0.13                                ...           2 years ago
  • 1.0.12-beta2                                ...           2 years ago
  • 1.0.12-beta1                                ...           2 years ago
  • 1.0.12                                ...           2 years ago
  • 1.0.11-beta1                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6-2                                ...           2 years ago
  • 1.0.6-1                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3-3                                ...           2 years ago
  • 1.0.3-2                                ...           2 years ago
  • 1.0.3-1                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 107
Last Day 0
Last Week 107
Last Month 1
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |