Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apology-middleware

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apology-middleware

middleware for custom error pages

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by83.33%
Maintainers
2
Weekly downloads
 
Created
Source

Apology Middleware

npm tests coverage dependencies

Middleware for custom error pages

Note: This project is in early development, and versioning is a little different. Read this for more details.

Why should you care?

Let's say that you are using connect to serve a static site. Occasionally, and by no fault of yours of course, some one may request a URL that you don't have. Your app will gladly return a 404 code for you, but sometimes that's not enough. Apology Middleware is for those times when you want to serve a custom HTML document for those pesky 404s.

Installation

npm install apology-middleware --save

Usage

This library can be used with connect, express, and any other server stack that accepts the same middleware format.

There are a few different ways to interact with apology. The first is to simply pass an absolute path to the html file you wish to serve. It should be noted, apology automatically sets the content type as text/html.

var http = require('http');
    connect = require('connect'),
    apology = require('apology-middleware'),
    serveStatic  = require('serve-static');

var app = connect()
            .use(apology('/path/to/4oh4.html')
            .use(serveStatic(__dirname));

var server = http.createServer(app).listen(1111)

Apology can optionally take two arguments, a root and a file. These two will automatically be joined.

apology(__dirname, 'custom.html');

If you don't specify a custom error page then apology will serve our standard error file for you (don't worry, it's quite handsome).

License & Contributing

FAQs

Package last updated on 17 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc