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

quinn

v3.3.9

Published

A web framework designed for things to come.

Downloads

51

Readme

nlm-github nlm-node nlm-version

Quinn

A web framework designed for things to come.[1]

import { createServer } from 'http';
import { createApp, respond } from 'quinn';

const app = createApp(req => respond({ body: 'Hello World!' }));

createServer(app).listen(3000);

Concepts

Request handler

A potentially async function that takes a request and returns a response.

function handler(request) {
  return result;
}

Request

An http.IncomingMessage. There are no additional properties or magical extension methods.

DispatchResult

Either a VirtualResponse[2] or undefined. If it's undefined, the handler was unable to handle the given request. E.g. the handler implements routing logic and no route matched the given url.

respond

The respond function is the primary means to create VirtualResponse instances. It takes one of three possible values:

  • An existing VirtualResponse instance that will be returned unchanged. This ensures that calling respond multiple times is idempotent.
  • A response body (see below).
  • An object with any combination of numeric statusCode, headers object, and/or a body property.

The body can be one of the following:

  • A buffer or Uint8Array.
  • A string.
  • A readable stream.
  • An empty body can be expressed by passing null.
  • A function that takes a request and a response and returns one of the previous types. This variant is called a "lazy body" and can be used to delay serialization or returns bodies that depend on the incoming request as with JSONP responses.

VirtualResponse

A pass-through stream describing the response that should be returned. While it might have additional utility functions, only the following properties and methods should be relied on:

The behavior of each should match ServerResponse. All headers and the status code should be forwarded when the response is piped to a target. The statusCode by setting the property, the headers by calls to setHeader on the target, one header at a time.

A VirtualResponse can either be piped to a target stream or forwarded using response.forwardTo(req, res). Lazy bodies are only supported when using forwardTo. When using forwardTo, it will return a promise that resolves once the response has been successfully written.

Combining Quinn

With Express

import express from 'express';
import { createApp as quinn, respond } from 'quinn/express';

const app = express();
app.get('/quinn-route', quinn(req => respond({ body: 'Hello World!' })));

References

Similar Libraries

Most of these are based on JSGI. Which would make sense if node wouldn't include an http server.


[1] In other words: an experimental mess.

[2] Because buzz word.