structured-fw 0.9.5 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ export declare class Application {
18
18
  readonly components: Components;
19
19
  readonly handlebars: Handlebars;
20
20
  readonly exportedRequestContextData: Array<keyof RequestContextData>;
21
+ data: LooseObject;
21
22
  constructor(config: StructuredConfig);
22
23
  init(): Promise<void>;
23
24
  private start;
@@ -18,6 +18,7 @@ export class Application {
18
18
  this.eventEmitter = new EventEmitter();
19
19
  this.handlebars = new Handlebars();
20
20
  this.exportedRequestContextData = [];
21
+ this.data = {};
21
22
  this.config = config;
22
23
  this.cookies = new Cookies();
23
24
  this.session = new Session(this);
@@ -243,14 +243,42 @@ export class Request {
243
243
  if (ctx.request.headers['content-type']) {
244
244
  ctx.bodyRaw = await this.dataRaw(ctx.request);
245
245
  if (ctx.request.headers['content-type'].indexOf('urlencoded') > -1) {
246
- ctx.body = queryStringDecode(ctx.bodyRaw.toString('utf-8'));
246
+ const bodyRaw = ctx.bodyRaw.toString('utf-8');
247
+ try {
248
+ ctx.body = queryStringDecode(bodyRaw);
249
+ }
250
+ catch (e) {
251
+ console.error(`Error parsing urlencoded request body for request to ${ctx.request.url}, (${e.message}).
252
+ Raw data:
253
+ ${bodyRaw}
254
+
255
+ `);
256
+ }
247
257
  }
248
258
  else if (ctx.request.headers['content-type'].indexOf('multipart/form-data') > -1) {
249
259
  let boundary = /^multipart\/form-data; boundary=(.+)$/.exec(ctx.request.headers['content-type']);
250
260
  if (boundary) {
251
261
  boundary = `--${boundary[1]}`;
252
- ctx.body = Request.parseBodyMultipart(ctx.bodyRaw.toString('utf-8'), boundary);
253
- ctx.files = Request.multipartBodyFiles(ctx.bodyRaw.toString('binary'), boundary);
262
+ try {
263
+ ctx.body = Request.parseBodyMultipart(ctx.bodyRaw.toString('utf-8'), boundary);
264
+ }
265
+ catch (e) {
266
+ console.error(`Error parsing multipart request body for request to ${ctx.request.url}, (${e.message}).
267
+ Raw data:
268
+ ${ctx.bodyRaw.toString('utf-8')}
269
+
270
+ `);
271
+ }
272
+ try {
273
+ ctx.files = Request.multipartBodyFiles(ctx.bodyRaw.toString('binary'), boundary);
274
+ }
275
+ catch (e) {
276
+ console.error(`Error parsing multipart request body files for request to ${ctx.request.url}, (${e.message}).
277
+ Raw data:
278
+ ${ctx.bodyRaw.toString('utf-8')}
279
+
280
+ `);
281
+ }
254
282
  }
255
283
  }
256
284
  else if (ctx.request.headers['content-type'].indexOf('application/json') > -1) {
package/index.ts CHANGED
@@ -1,30 +1,4 @@
1
1
  import { Application } from "structured-fw/Application";
2
2
  import { config } from './Config.js';
3
- import { Layout } from "./system/server/Layout.js";
4
3
 
5
- const app = new Application(config);
6
-
7
- app.registerPlugin(async (app) => {
8
-
9
- }, {
10
- poop: 123
11
- });
12
-
13
- // app.on('afterComponentsLoaded', (components) => {
14
- // components.componentNames.forEach((componentName) => {
15
- // console.log(componentName)
16
- // console.log(components.getByName(componentName));
17
- // });
18
- // })
19
-
20
- // app.on('componentCreated', (component) => {
21
- // console.log(component.document.id);
22
- // })
23
-
24
- app.on('documentCreated', (document) => {
25
- document.on('componentCreated', (component) => {
26
- document.head.add(`<script>console.log('${component.name}')</script>`);
27
- });
28
- });
29
-
30
- export const layout: Layout = new Layout(app, 'layout');
4
+ new Application(config);
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "license": "MIT",
15
15
  "type": "module",
16
16
  "main": "build/index",
17
- "version": "0.9.5",
17
+ "version": "0.9.8",
18
18
  "scripts": {
19
19
  "develop": "tsc --watch",
20
20
  "startDev": "cd build && nodemon --watch '../app/**/*' --watch '../build/**/*' -e js,html,css index.js",