kwhinnery/todomvc-plusplus

Add X-Shenanigans-None to all API responses

kwhinnery opened this issue · 2 comments

A storied Twilio tradition is adding the X-Shenanigans: None header to every HTTP response we send. Create an Express middleware to do this, but only for /todos routes.

I was having a git issue, so there's the middleware for that ^^

app.use('/todos', (request, response, next) => {
  response.set({
    'X-Shenanigans-None': 'true'
  });
  next();
});

My fix was done as follows in todos.js

/ Fetch all TODOs exports.all = (request, response) => { response.setHeader("X-Shenanigans", "none"); Todo.findAll({ limit: 1000, order: [ ['createdAt', 'ASC'] ] }).then((todos) => { response.send(todos); }).catch((error) => { response.status(500).send(error); });