csblogs/api-server

View on GitHub
src/errors/body-parser-json-syntax-error.js

Summary

Maintainability
A
0 mins
Test Coverage
export default function (error, req, res, next) {
  if (error instanceof SyntaxError) {
    res.status(400).json({ error: 'Invalid JSON in request' });
  } else {
    next();
  }
}