npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aotoo/aotoo-koa-server

v3.0.9

Published

based on koa2 and surport react ssr

Readme

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