New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

power-express

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

power-express

Strengthening Express, so it's more developer-friendly.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

##Express的增强插件 Express的api,以及架构,个人认为比koa更加合理。但是Koa中支持使用Generator来处理异步回调,确实非常的有必要。 所以Power Express插件,就是为了在Express中引入Generator,使得异步编程和异常的处理更加的友好。 Installation

Install the plugin with npm:

$ npm install power-express --save-dev

Basic Usage

跟express一样的用法,只是后面的函数,可以使用Generator

app.get('/', function*(req, res) {
	var result = yield readFile(__dirname + '/test.js')
	return res.send(String(result))
})

为统一处理异常,添加一个addErrorHandle方法,如下使用

app.addErrorHandle(function(err, req, res) {
	res.json({
		code: 500,
		data: err.toString()
	})
})

目前支持:

  • get
  • post
  • delete
  • put
  • use
  • all
  • param

Keywords

FAQs

Package last updated on 27 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc