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

connect-static-file

v2.0.0

Published

connect and express middleware to serve a single static file

Downloads

15,243

Readme

connect-static-file

Build Status

Connect/express middleware to serve a single static file

Usage

var express = require('express');
var staticFile = require('connect-static-file');

var app = express();
var path = 'path/to/file.txt';
var options = {};
app.use('/foo.txt', staticFile(path, options));

Options

etag

Enable or disable etag generation, defaults to true.

extensions

If a given file doesn't exist, try appending one of the given extensions, in the given order. By default, this is disabled (set to false). An example value that will serve extension-less HTML files: ['html', 'htm']. This is skipped if the requested file already has an extension.

lastModified

Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.

maxAge

Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.

headers

Any additional headers you would like to set on the response. This is a plain old javascript object: headers: {'X-Foo': 'bar'}

encoded

If set, assume the static file has been encoded using the specified encoding. For example encoded: 'gzip'. This value must be a valid Content-Encoding token. If the browser does not support this encoding (the encoding is not specified in the Accept-Encoding request header), this middleware will pass on the request to the next middleware. The Content-Encoding header will be set so that the browser will uncompress the file on the fly.

This is useful if you are compressing your static files beforehand:

app.use('/bundle.js', staticFile('generated/bundle.js.gz', {encoded: 'gzip'}));
// If the file is missing, or if the browser does not support gzip, use this one instead:
app.use('/bundle.js', staticFile('generated/bundle.js'));

Other modules

If you would like to server an entire directory of possible gziped files, take a look at connect-gzip-static or ecstatic. If you would like dynamic gzip compression, try compression