diff --git a/src/routes/api/v1/index.ts b/src/routes/api/v1/index.ts index f0640f9..7ed4b04 100644 --- a/src/routes/api/v1/index.ts +++ b/src/routes/api/v1/index.ts @@ -9,10 +9,19 @@ import storageLocationRoute from './storageLocations.js'; import search_routes from './search/index.js'; - // Router base is '/api/v1' const Router = express.Router({ strict: false }); +// All empty strings are null values. +Router.use('*', function (req, res, next) { + for (let key in req.body) { + if (req.body[key] === '') { + req.body[key] = null; + } + } + next(); +}); + Router.route('/items').get(itemRoute.get).post(itemRoute.post).patch(itemRoute.patch).delete(itemRoute.del); Router.route('/categories').get(categoryRoute.get).post(categoryRoute.post).patch(categoryRoute.patch).delete(categoryRoute.del); // TODO: Migrate routes to lowercase.