@webqit/webflo 0.11.34 → 0.11.36

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.
@@ -6,8 +6,9 @@ import Fs from 'fs';
6
6
  import Path from 'path';
7
7
  import QueryString from 'querystring';
8
8
  import Router from './Router.js';
9
+ import _RuntimeClient from '../RuntimeClient.js';
9
10
 
10
- export default class RuntimeClient {
11
+ export default class RuntimeClient extends _RuntimeClient {
11
12
 
12
13
  /**
13
14
  * RuntimeClient
@@ -15,10 +16,15 @@ export default class RuntimeClient {
15
16
  * @param Context cx
16
17
  */
17
18
  constructor(cx) {
18
- this.cx = cx;
19
+ super(cx);
19
20
  this.renderFileCache = {};
20
21
  }
21
22
 
23
+ // Returns router class
24
+ get Router() {
25
+ return Router;
26
+ }
27
+
22
28
  /**
23
29
  * Handles navigation events.
24
30
  *
@@ -29,23 +35,21 @@ export default class RuntimeClient {
29
35
  */
30
36
  async handle(httpEvent, remoteFetch) {
31
37
  // The app router
32
- const router = new Router(this.cx, httpEvent.url.pathname);
38
+ const router = new this.Router(this.cx, httpEvent.url.pathname);
33
39
  const handle = async () => {
34
40
  // --------
35
41
  // ROUTE FOR DATA
36
42
  // --------
37
- let httpMethodName = httpEvent.request.method.toUpperCase();
43
+ const httpMethodName = httpEvent.request.method.toUpperCase();
38
44
  let response = await router.route([httpMethodName, 'default'], httpEvent, {}, async event => {
39
45
  return router.file(event);
40
46
  }, remoteFetch);
41
47
  if (!(response instanceof httpEvent.Response)) {
42
48
  response = new httpEvent.Response(response);
43
49
  }
44
-
45
50
  // --------
46
51
  // Rendering
47
52
  // --------
48
-
49
53
  if (response.ok && response.bodyAttrs.inputType === 'object' && httpEvent.request.headers.accept.match('text/html')) {
50
54
  let rendering = await this.render(httpEvent, router, response);
51
55
  if (typeof rendering !== 'string' && !(typeof rendering === 'object' && rendering && typeof rendering.toString === 'function')) {
@@ -59,7 +63,6 @@ export default class RuntimeClient {
59
63
 
60
64
  return response;
61
65
  };
62
-
63
66
  // --------
64
67
  // PIPE THROUGH MIDDLEWARES
65
68
  // --------
@@ -12,9 +12,7 @@ import Runtime from './Runtime.js';
12
12
  export async function start(clientCallback = null) {
13
13
  const cx = this || {};
14
14
  const defaultClientCallback = _cx => new RuntimeClient(_cx);
15
- return new Runtime(Context.create(cx), ( ...args ) => {
16
- return clientCallback ? clientCallback( ...args.concat( defaultClientCallback ) ) : defaultClientCallback( ...args );
17
- });
15
+ return new Runtime(Context.create(cx), clientCallback || defaultClientCallback);
18
16
  }
19
17
 
20
18
  /**
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * imports
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * imports
package/src/webflo.js CHANGED
@@ -21,7 +21,7 @@ const cx = WebfloPI.Context.create({
21
21
  app: { title: appJson.title, version: appJson.version },
22
22
  logger: Logger,
23
23
  config: WebfloPI.config,
24
- middlewares: [ WebfloPI.deployment.origins.webhook, ],
24
+ middlewares: [ WebfloPI.deployment.origins.webhook ],
25
25
  });
26
26
 
27
27
  /**