Skip to content

Instantly share code, notes, and snippets.

@jamesbiederbeck
Created March 3, 2020 19:15
Show Gist options
  • Save jamesbiederbeck/1b9e18869f749ab5faab5759c54e9364 to your computer and use it in GitHub Desktop.
Save jamesbiederbeck/1b9e18869f749ab5faab5759c54e9364 to your computer and use it in GitHub Desktop.
#! /usr/bin/env node
const express = require('express')
const app = express()
const port = 3000
const response_text = 'Hello World!\nAlso more text here for testing\nAlso different text for lookbehind\n'
app.all("*", function (req, resp, next) {
console.log("Got request!");
next();
});
app.get('/', (req, res) => res.send(response_text))
app.get('/timeout/:time', function(req, res) {
timeout = req.param("time");
console.log(`Per request, waiting ${timeout}`)
setTimeout(function(){
console.log("No more lollygagging");
res.send(response_text);
}, timeout)
;
});
app.get('/empty/', function(req, res) {
console.log(`Per request, ending connection prematurely`);
res.end()
});
app.listen(port, () => console.log(`Listening on port ${port}!`))
@Romanmir
Copy link

Romanmir commented Mar 3, 2020

Put this right before the last line:

app.get('*', function(req, res) {
res.send("This isn't the test you are looking for. You can go about your business, Move along.");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment