https://github.com/recidvst/node-gnu-clacks
A man is not dead while his name is still spoken. Add an 'X-Clacks-Overhead' Header to your Node/Express app.
https://github.com/recidvst/node-gnu-clacks
express headers http middleware node npm npm-package pratchett
Last synced: about 1 year ago
JSON representation
A man is not dead while his name is still spoken. Add an 'X-Clacks-Overhead' Header to your Node/Express app.
- Host: GitHub
- URL: https://github.com/recidvst/node-gnu-clacks
- Owner: Recidvst
- License: mit
- Created: 2018-08-13T21:18:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-17T22:31:01.000Z (about 2 years ago)
- Last Synced: 2025-02-12T01:04:28.823Z (about 1 year ago)
- Topics: express, headers, http, middleware, node, npm, npm-package, pratchett
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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://www.gnuterrypratchett.com](http://www.gnuterrypratchett.com 'GNU Terry Pratchett')
[]()
[]()
[]()
## Install
- Install with [npm](https://www.npmjs.com/package/node-gnu-clacks 'node-gnu-clack on NPM') or download and create your own module.
```js
npm install node-gnu-clacks --save
```
## Usage
- Import the module and tell your app to use as middleware:
```js
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
```js
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
```js
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);
```