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 🙏

© 2024 – Pkg Stats / Ryan Hefner

koa-extern

v0.1.7

Published

extend for koa

Downloads

16

Readme

koa-extend

对koa进行扩展,分离router和controller,支持async,舍弃koa-convert , 开发note

Build Status Coverage Status

1.简介

  • 拆分开koa-router的router和controller,分别用一个js文件(router.js和controller/index.js)进行管理,分开管理router和controller, 让这两部分的分工更加明确
  • 重新定义router,单独拎出来一级路由,为一级路由开辟单独的workspace。更加适合大型项目选型
  • 重点放在router和controller中,弱化view和model层,一级路由里面的整体架构这个项目不会care,给每个一级路由更大的自主权
  • ~~重构koa.use方法,删掉koa-convert包引用,为将要到来的node v8.x的lts做准备~~
  • 扩展koa-router,底层加入router Map和controller Map对中间件的注册绑定进行管理,而外部暴露出来的增删改查均和配置文件的key有关,人为无法直接 对底层的Map进行操作,只能通过key来操作与绑定中间件
  • 每个一级路由下分别有各自的router和controller配置文件,整体团队负责不同路由下面的页面开发时互不干扰
  • koa底层加入request,作为每个一级路由公用数据调用通道(已加入koa2-request-middleware)
  • 本项目剥离业务层,所以本地环境对除虫模式的支持仅限于controller,router和底层错误均用assert直接抛出
  • 项目完成后,会加入cli构建,开发过程中每个模块的代码均需要在/test目录下写测试用例(TO DO)

2.文件目录

root----koasConfig.js(config文件)
|--test/(测试用例)
| |--test/(测试文件)
| |--list/(一级路由的一级文件夹)
| | |--controller/(controller文件夹)
| | | |--index.js(总管一级路由下controller的文件)
| | | |--other.js(其他的路由文件,一个路由对应一个文件)
| | |--router.js(一级路由下面的二级~n级路由管理文件)
| |--movie/(同上)
| |--json/(mock接口文件)
| |--koasConfig.js(测试用的config文件)
|--app/
| |--routes/(封装的koa-router)
| |--controllers/(c层结构,主要是统一读取routes的function)
| |--routes/(router,主要是统一对路由进行处理)
|--deps/(依赖文件)
|--index.js(入口文件)