From 907d51a842412a2038600e277fe49cf2d2950716 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 24 Feb 2024 18:33:33 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/servertools/classes.server.ts | 19 ++++++++++++++++++- ts_web/00_commitinfo_data.ts | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 94d1ece..43b19b9 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedserver', - version: '3.0.23', + version: '3.0.24', description: 'easy serving of static files' } diff --git a/ts/servertools/classes.server.ts b/ts/servertools/classes.server.ts index 156969b..aab9486 100644 --- a/ts/servertools/classes.server.ts +++ b/ts/servertools/classes.server.ts @@ -142,7 +142,24 @@ export class Server { }); // body parsing - this.expressAppInstance.use(plugins.bodyParser.json({ limit: 100000000 })); // for parsing application/json + this.expressAppInstance.use(async (req, res, next) => { + if (req.headers['content-type'] === 'application/json') { + let data = ''; + req.on('data', chunk => { + data += chunk; + }); + req.on('end', () => { + try { + req.body = plugins.smartjson.parse(data); + next(); + } catch (error) { + res.status(400).send('Invalid JSON'); + } + }); + } else { + next(); + } + }); this.expressAppInstance.use(plugins.bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded // robots diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index 94d1ece..43b19b9 100644 --- a/ts_web/00_commitinfo_data.ts +++ b/ts_web/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedserver', - version: '3.0.23', + version: '3.0.24', description: 'easy serving of static files' }