Compare commits

...

4 Commits

Author SHA1 Message Date
7e04474a66 3.0.24 2024-02-24 18:33:33 +01:00
907d51a842 fix(core): update 2024-02-24 18:33:33 +01:00
2114ff28c0 3.0.23 2024-02-21 01:16:39 +01:00
fd9431f82b fix(core): update 2024-02-21 01:16:39 +01:00
5 changed files with 24 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@api.global/typedserver",
"version": "3.0.22",
"version": "3.0.24",
"description": "easy serving of static files",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedserver',
version: '3.0.22',
version: '3.0.24',
description: 'easy serving of static files'
}

View File

@ -11,7 +11,9 @@ export class HandlerTypedRouter extends Handler {
constructor(typedrouter: plugins.typedrequest.TypedRouter) {
super('POST', async (req, res) => {
const response = await typedrouter.routeAndAddResponse(req.body);
res.json(plugins.smartjson.stringify(response));
res.type('json');
res.write(plugins.smartjson.stringify(response));
res.end();
});
}
}

View File

@ -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

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedserver',
version: '3.0.22',
version: '3.0.24',
description: 'easy serving of static files'
}