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

plover-web-util

v1.1.0

Published

【插件】集成常用web中间件,提供通用web功能。

Downloads

7

Readme

plover-web-util

NPM version build status Test coverage

【插件】集成常用web中间件,提供通用web功能。

Usage

const app = plover({
  web: {
    keys: ['17e6b6bc6129097383dcad4fa1602233'],
    favicon: '',
    rtime: true
  }
});

Options

| Name | Type | Description | |------|------|-------------| | keys | String/Array | 设置cookie keys,详见 koa-keys | | favicon | String | favicon图标的路径,详见 koa-favicon | | rtime | Boolean | Response Header添加字段X-Response-Time显示响应时间,详见 koa-response-time | | conditional | Boolean | 缓冲条件请求处理,详见 koa-conditional-get | | etag | Boolean | 支持ETag响应标签,详见 koa-etag | | bodyParser | Boolean | 解析request.body(默认开启),详见 koa-bodyparser | | cookieSession | Object | 一个简单的基于cookiesession功能,详见 koa-session | | csrf | Object | CSRFtokens, 详见 koa-csrf |

Others

query

query增强,若使用querystring传递多个相同值,最后一个值将覆盖前面的值。

假设访问地址为http://www.alibaba.com?name=james&name=tomy,在controller中获取的name值为tomy

// controller
console.log(this.query.name);  // tomy

params

params增强,params包括querystringrequest.body的值,如果存在相同值,后者将覆盖前者的值:

Query String Parameters

name: jame
age: 24

Form Data

name: tomy
address: hangzhou

controller中可以通过this.params很方便的获取querystringrequest.body的值:

// controller
console.log(this.params.name);  // tomy
console.log(this.params.age);  // 24
console.log(this.params.address);  // hangzhou

assertMethod

添加了assertMethod方法,方便验证Http Method:

//
this.ctx.assertMethod('GET');

output charset

可以通过querystring传递_output_charset参数指定响应输出编码格式。

security headers

设置安全http相关头,移除了X-Powered-By

| Name | Value | |------|-------| | X-XSS-Protection | 1; mode=block | | X-Content-Type-Options | nosniff | | X-Download-Options | noopen | | X-Frame-Options | SAMEORIGN |