500

Generate 500 response errors.

Usage no npm install needed!

<script type="module">
  import 00 from 'https://cdn.skypack.dev/500';
</script>

README

500

Easily generate 500 HTTP responses. I found my self writing this logic over and over again, so it's extracted out in to a module.

Installation

npm install --save 500

Usage

'use strict';

var fivehundered = require('500')
  , http = require('http');

var server = http.createServer(function (req, res) {
  res.statusCode = 200;

  if (Math.random()) return fivehundered('Server failed because of reasons');
  else if (Math.random()) return fivehundered(new Error('Random error'));

  res.end('hello world');
}).listen(8080);

License

MIT