Skip to content

Simple express middleware for displaying GONE (410) status code for a set of paths

License

Notifications You must be signed in to change notification settings

WORMSS/express-gone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-gone

Simple express middleware for displaying GONE (410) status code

NPM Version NPM Downloads

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install express-gone --save

Example

app.use("/somefile", require("express-gone")());
let gone = require("express-gone");
app.use("/somefile", gone());

More examples below

API

gone([options]);

options

Optional argument for changing default response.

options.status

The status code to send in the response. res.status(status); api
default is 410.

options.redirect

The redirect location to send in the response. res.redirect(status, redirect); api
default is undefined.
note: If redirect is used; type, render or message is ignored.
note: Most clients (browsers) do not play nicely with redirect when status code is not 3xx. It is recommended to use render or message instead of redirect.

options.type

The content type of the response. res.type(type); api
default is "text"

options.render

The name of the view for the response to render. res.render(render); api
default is undefined. note: If render is used, message is ignored.

options.renderLocals

The variables to pass to the render view. res.render(render, renderLocals); api
default is undefined.

options.send

The content body of the response. res.send(send); api
default is "Gone!".

More Examples

In express paths can be a single path string or express path pattern or regular expression or array with any of the previous types
For more information on paths see path-examples

defaults
// Status Code: 410, Content-Type: "text/plain"
// body: "Gone"
app.use(paths, gone());
render
// Status Code: 410, Content-Type: "text/html" (default for express is text/html)
// body: [what ever your render view looks like, with possibly the title "File Removed"]
app.use(paths, gone({ render: "error/gone", renderLocals: { title: "File Removed" } }));
message
// Status Code: 410, Content-Type: "text/plain"
// body: "File has gone, not even a ghost exists"
app.use(paths, gone({ type: "text", send: "File has gone, not even a ghost exists" }));
redirect
// Status Code: 301, Location: "/no-file"
app.use(paths, gone({ status: 301, redirect: "/no-file" }));

License

ISC

About

Simple express middleware for displaying GONE (410) status code for a set of paths

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published