Previously we were using eachSchema and schema.options.toJSON to set various configuration options which affected how the json was rendered by mongoose's toJSON method. This was a flawed approach because data could leak between requests if two instances were setting different option simultaneously.
This pull request moves the url generation into a transform.js module, which fixes the race condition with url generation and also should make it reasonably trivial to fix https://github.com/mysociety/popit-api/issues/119.
Previously we were using
eachSchema
andschema.options.toJSON
to set various configuration options which affected how the json was rendered by mongoose'stoJSON
method. This was a flawed approach because data could leak between requests if two instances were setting different option simultaneously.This pull request moves the url generation into a
transform.js
module, which fixes the race condition with url generation and also should make it reasonably trivial to fix https://github.com/mysociety/popit-api/issues/119.Fixes https://github.com/mysociety/popit/issues/729