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

demon-koa

v1.2.0

Published

demon-koa

Downloads

7

Readme

demon-koa | koa2 开发脚手架

集成了 koa-body / nunjucks / koa-router / koa-session 的开发脚手架。

npm

npm install nodemon --save --registry=https://registry.npm.taobao.org
npm install --save --registry=https://registry.npm.taobao.org

一、基本依赖

  • 路由:koa-router
  • cookie: koa2 默认的 cookie
  • session: koa-session
  • post 请求和文件上传: koa-body
  • 模板引擎:nunjucks,使用的依赖 koa-nunjucks-2
  • 静态资源: koa-static

二、目录结构

+ config // 配置
      |-- app.js // 应用层级配置
+ controllers // 控制器方法
+ middlewares // 中间件方法
+ models // 模型方法或数据生成
+ public 
      |-- css // stylesheet
      |-- js // scripts
      |-- vendor // 第三方依赖
      |-- upload // 文件上传路径
+ routes // 路由方法
      |-- index.js // 主路由加载
      |-- home.js // 首页路由及其他路由
+ tests // 测试方法
+ utils // 工具方法
+ views // 模板文件
      |-- base.html // 模板布局基础模板
      |-- index.html // 默认首页模板
+ app.js // 服务入口
+ nodemon.json // nodemon 配置文件

三、使用方式:

1、克隆项目

npm install demon-koa 
copy demon-koa 

2、安装依赖

yarn install

## npm install

3、开启服务

以开发模式运行 app.js, 需要全局安装 nodemon

npm install -g nodemon

yarn dev 

## npm run dev

通过 node 运行 app.js

yarn start

## npm run start

四、配置文件 config/app.js

/**
 * @description app的配置参数
 */
module.exports = {
  point:'3000', // 端口
  staticDir:'./public', // 静态资源配置目录
  viewsDir:'./views', // 模板文件目录
  viewsExt:'html', // 模板的后缀
  session:{
    key: 'koa:sess',   //cookie key (default is koa:sess)
    maxAge: 86400000,  // cookie的过期时间 maxAge in ms (default is 1 days)
    overwrite: true,  //是否可以overwrite    (默认default true)
    httpOnly: true, //cookie是否只有服务器端可以访问 httpOnly or not (default true)
    signed: true,   //签名默认true
    rolling: false,  //在每次请求时强行设置cookie,这将重置cookie过期时间(默认:false)
    renew: false,  //(boolean) renew session when session is nearly expired,
  },
  upload:{
    size:2*2014*1024, // 文件上传大小
    dir:"public/upload" // 文件上传路径
  }
};

五、文件上传

使用 koa-body 进行文件上传,基本采用默认配置,如果需要自定义文件名请参照:

六、效果

demo.jpg

License

MIT