Skip to content

strugee/node-serve-random

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

node-serve-random

Build Status Coverage Status Greenkeeper badge

Serve random files

Vaguely API-compatible with serve-static.

API

serveRandom(root, options)

Create a new middleware function to serve files from within a given root directory. With each inbound request, a random file will be selected from the given root directory. The module will not recurse into subdirectories.

The response's max-age is always set to 0.

Options

fallthrough

Set the middleware to have errors (clients using an HTTP method other than GET or HEAD, or root being empty) fall-through as just unhandled requests, otherwise forward a client error. The difference is that client errors will cause this middleware to simply next() to your next middleware when this value is true. When this value is false, these errors (even 404s), will invoke next(err).

Defaults to true.

Acknowledgments

This module heavily borrows code from serve-static - many thanks to the great people who work on that module.

License

LGPL 3.0+

Author

AJ Jordan alex@strugee.net

About

Express middleware that responds with random files

Topics

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Packages

No packages published