diff options
author | 2021-08-13 00:45:01 +0530 | |
---|---|---|
committer | 2021-08-13 00:45:01 +0530 | |
commit | 2d27d5e66649d4f5baf127a53ee5ae524eae3a59 (patch) | |
tree | c592ea219ac8cd987fc367f57b54034c450ab2ab /src/internal-server/app/Middleware/ConvertEmptyStringsToNull.js | |
parent | Ferdi v5.6.0 (diff) | |
parent | 5.6.1-nightly.24 [skip ci] (diff) | |
download | ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.gz ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.zst ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.zip |
chore: merge from nightly branch into release branch in prep for next beta
Diffstat (limited to 'src/internal-server/app/Middleware/ConvertEmptyStringsToNull.js')
-rw-r--r-- | src/internal-server/app/Middleware/ConvertEmptyStringsToNull.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/internal-server/app/Middleware/ConvertEmptyStringsToNull.js b/src/internal-server/app/Middleware/ConvertEmptyStringsToNull.js new file mode 100644 index 000000000..87f1f6c25 --- /dev/null +++ b/src/internal-server/app/Middleware/ConvertEmptyStringsToNull.js | |||
@@ -0,0 +1,15 @@ | |||
1 | class ConvertEmptyStringsToNull { | ||
2 | async handle({ request }, next) { | ||
3 | if (Object.keys(request.body).length) { | ||
4 | request.body = Object.assign( | ||
5 | ...Object.keys(request.body).map(key => ({ | ||
6 | [key]: request.body[key] !== '' ? request.body[key] : null, | ||
7 | })), | ||
8 | ); | ||
9 | } | ||
10 | |||
11 | await next(); | ||
12 | } | ||
13 | } | ||
14 | |||
15 | module.exports = ConvertEmptyStringsToNull; | ||