import { stringify } from '@brillout/json-serializer/stringify';

export default function serializeApiResponses(req, res, next) {
	res.json = function json(obj) { // eslint-disable-line no-param-reassign
		if (!this.get('Content-Type')) {
			this.set('Content-Type', 'application/json');
		}

		return this.send(stringify(obj));
	};

	next();
}
