Medley is a fast and modern web framework for Node.js. It fully supports both async
/await
and
callbacks and is compatible with Node 6 or greater. It's design incorporates concepts found in
Express, Koa,
hapi, and Fastify.
Most importantly, Medley aims to provide an API that is forward-compatible with future versions
that will take full advantage of Node's HTTP/2
module.
Install:
npm install @medley/medley
# or
yarn add @medley/medley
Create a web server:
const medley = require('@medley/medley')
const app = medley()
app.get('/', (req, res) => {
res.send('Hello World')
})
app.listen(3000)
- Getting Started
- The
medley()
function - The
app
Object - Routing
- The
req
Object - The
res
Object - The Request Lifecyle
- Hooks
- Extensions
- JSON Serialization
- Plugins
- An API similar to Express
- Performance on par with Fastify
- Full support for both
async
/await
and callbacks - Automatic
HEAD
,OPTIONS
, and405
responses - Facilities for safely extending the framework (extensions)
- 100% test coverage
- HTTP/2 support
HTTP/2 is the future of the web. It is faster than HTTP/1.x and comes with new, speed-boosting
features such as server push.
The Node.js http2
module has a very different API from the http
/https
modules, but it also provides a
compatibility API. Medley currently
uses the compatibility API (to support both HTTP/1.x and HTTP/2), but Medley's API is designed such
that when Medley upgrades to the full http2
API, application code built on Medley should not need
to change. Medley's goal is to insulate application code from this transition (as much as possible)
so that code written now that won't require massive rewrites in the future.
@medley/body-parser
- Essential body parsers for Medley.@medley/multipart
- Plugin for parsingmultipart/form-data
bodies.
@medley/cookie
- Plugin for parsing and setting cookies.@medley/etag
- Plugin for automatic ETag generation & conditional GET responses.@medley/self-request
- Plugin that augments an app to be able to make HTTP requests to itself for testing.@medley/serve-favicon
- Plugin for serving the default favicon.@medley/serve-static
- Plugin for serving static files.
ajv-request-validator
- Tool for validating therequest
object of popular frameworks with Ajv.
This project was forked from Fastify. The initial commit is a clone of fastify/fastify@dab20bd
. All of the credit for that work goes to the Fastify team.