Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
expressify-koa
Advanced tools
Expressify Koa is a simple converter that lets you use Koa 2.x middleware in Express.
Migrate from Express to Koa gradually. Application developers can gradually swap out Express/Connect-style middleware for Koa middleware
Support both Express and Koa. Package developers can support multiple frameworks without creating new framework-agnostic abstractions. Koa is already abstracts the Node.js HTTP requests and responses, so there is no need to create a new abstraction
The conversion is possible because Koa requests and responses are abstractions over Node.js-provided HTTP Requests and Responses
Ported from Identity Desk's multi-framework support module.
$ npm install expressify-koa
const express = require('express')
const expressify = require('expressify-koa')
const app = express()
app.get('/', expressify(function (ctx, next) {
ctx.body = 'Hello World'
return next()
}))
app.listen(3000)
Expressify Koa only accepts a single Koa middleware. To attach multiple Koa middleware in series, use koa-compose
or a Koa-compatible router such as koa-router
This diagram contrasts how Koa and Expressify Koa handle middleware responses and control flow:
----------------------------------------------------------------------
| Regular Koa app | Expressify Koa |
----------------------------------------------------------------------
| | |
| middleware stack | |
| built with `use()` | |
| | |
| ↓ | |
| | |
| `callback()` combines | accepts a single middleware function |
| the stack into one function | (possibly pre-combined) |
| | |
| ↓ | ↓ |
| | |
| `respond()` converts | convert any response from Koa |
| Koa's `ctx.response` into | middleware on `ctx.body` |
| an HTTP response | into an HTTP response |
| | |
| ↓ | ↓ |
| | |
| `listen()` creates an | pass control to Express if |
| HTTP server | response still pending |
| | |
----------------------------------------------------------------------
Convert middleware
into Express middleware
To run the test suite, first install the dependencies, then run npm test
:
$ npm install
$ npm test
This project welcomes contributions from the community. Contributions are accepted using GitHub pull requests; for more information, see GitHub documentation - Creating a pull request.
For a good pull request, we ask you provide the following:
Readme.md
file as well.npm run lint
and fix any displayed issues.The lead author is Faraz Syed.
FAQs
Use Koa 2.x middleware in Express
The npm package expressify-koa receives a total of 0 weekly downloads. As such, expressify-koa popularity was classified as not popular.
We found that expressify-koa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.