Skip to content

A man is not dead while his name is still spoken. Add an 'X-Clacks-Overhead' Header to your Node/Express app.

License

Notifications You must be signed in to change notification settings

Recidvst/node-gnu-clacks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node/Express GNU Clacks

A man is not dead while his name is still spoken. Add an 'X-Clacks-Overhead' Header to your vanilla Node or Express app.

See http:https://www.gnuterrypratchett.com

npm npm license

Install

  • Install with npm or download and create your own module.
npm install node-gnu-clacks --save

Usage

  • Import the module and tell your app to use as middleware:
const { node: gnuHeaderNode } = require('node-gnu-clacks');
const { express: gnuHeaderExpress } = require('node-gnu-clacks');

note: you can also use const gnuHeader = require('node-gnu-clacks'); for express apps for backwards compatibility with v1.

Options

string[] ghosts = ['Terry Pratchett']

Add an array of names to be passed. This is in addition to the default, 'Terry Pratchett', which will always be added.

Example with a vanilla Node app

const http = require('http');
const { node: gnuHeaderNode } = require('node-gnu-clacks');

http
  .createServer((req, res) => {
    const addClacksHeader = gnuHeaderNode(['Moist', 'Adora', 'Reacher']);
    addClacksHeader(res);

    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('A man is not dead while his name is still spoken.\n');
  })
  .listen(3000);

Example with an Express app

const express = require('lib/express');
const { express: gnuHeaderExpress } = require('node-gnu-clacks');

const app = express();

app.use(gnuHeaderExpress());
or;
app.use(gnuHeaderExpress(['Moist', 'Adora', 'Reacher']));

app.get('/', (req, res) => {
  res.send('A man is not dead while his name is still spoken.');
});

app.listen(3000);

About

A man is not dead while his name is still spoken. Add an 'X-Clacks-Overhead' Header to your Node/Express app.

Topics

Resources

License

Stars

Watchers

Forks

Packages