jsgui3-server 0.0.81 → 0.0.82

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.
package/module.js CHANGED
@@ -4,11 +4,13 @@
4
4
  //var sockjs = require('sockjs'), jsgui = require('jsgui3-html'),
5
5
  const jsgui = require('jsgui3-html')
6
6
  const Server_Page_Context = require('./page-context');
7
+ jsgui.Server_Page_Context = Server_Page_Context;
7
8
 
8
9
  // Login = require('../resource/login'),
9
10
  //var Server = {};
10
11
 
11
12
  const Resource_Publisher = require('./publishing/resource-publisher');
13
+ jsgui.Resource_Publisher = Resource_Publisher;
12
14
  jsgui.Server = require('./server');
13
15
  jsgui.fs2 = require('./fs2');
14
16
  //jsgui.Resource = Resource;
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "type": "git",
41
41
  "url": "https://github.com/metabench/jsgui3-server.git"
42
42
  },
43
- "version": "0.0.81"
43
+ "version": "0.0.82"
44
44
  }
@@ -120,7 +120,7 @@ class Function_Publisher {
120
120
  const fn_res = fn(obj_input);
121
121
  const tfr = tf(fn_res);
122
122
 
123
- console.log('tfr', tfr);
123
+ //console.log('tfr', tfr);
124
124
 
125
125
  if (tfr === 'p') {
126
126
  // promise
@@ -37,6 +37,12 @@ var Collection = jsgui.Collection;
37
37
  // Ideally want it like image keys, then options for max size and also quality.
38
38
  //
39
39
 
40
+ // Data_HTTP_Resource ?
41
+
42
+ // Handled with request+response.
43
+ // What about data that needs to be in page load?
44
+
45
+ // Maybe assume resources always deal with data?
40
46
 
41
47
  class Data_Resource extends Resource {
42
48
 
@@ -27,6 +27,7 @@ const test_lang_mini_project = () => {
27
27
  // Worth working with a lower level part of jsgui, such as lang-mini.
28
28
  // lang-mini itself has an external reference.
29
29
  // stream the file in.
30
+ throw 'STOP';
30
31
  const lm_path = '../../../../../tools/lang-mini/lang-mini.js'
31
32
 
32
33
  //const file_path = '../JS_File.js';
@@ -19,6 +19,17 @@ var exec = require('child_process').exec;
19
19
  // Perhaps this will have HTTP endpoints as well?
20
20
  // Maybe we can access it through url/resources/
21
21
 
22
+
23
+ // jsgui-html could include a prototype / placeholder Templated HTML => HTML transformer.
24
+ // Or the class that is the superclass of the class that then gets the rsx or whatever module loaded into it.
25
+ // Maybe it's a Publisher anyway?
26
+ // Publisher seems a lot like Transformer.
27
+
28
+
29
+
30
+
31
+
32
+
22
33
  // Perhaps a resource publisher, or a few of them could be useful.
23
34
  // HTTP_Resource_Publisher?
24
35
  // Generally publishes a resource over HTTP.
@@ -2,6 +2,9 @@
2
2
  * Created by James on 29/07/2014.
3
3
  */
4
4
 
5
+ // Represents (and is?) a website itself, and its representation available through the Resource system.
6
+
7
+
5
8
  // Want to get the core resources working and tested.
6
9
  // Want to run a clock website / service to start with.
7
10
  // The server could have a clock, while clients could connect to it and share the information.
@@ -73,6 +76,17 @@ const Observable_Publisher = require("../publishing/observable-publisher");
73
76
  const Function_Publisher = require("../publishing/function-publisher");
74
77
  //const Data_Resource = require("./data-resource");
75
78
 
79
+ // Proxy_Server_Resource possibly.
80
+ // Note that the client should be able to access a Proxy_Server_Resource if needed.
81
+ // Could just send request onwards and do same for response.
82
+ // Buffering rate-limiting proxies too though?
83
+
84
+
85
+ // May help with FirstPoint_Server.
86
+
87
+
88
+
89
+
76
90
  class Website_Resource extends Resource {
77
91
  constructor(spec = {}) {
78
92
  super(spec);
@@ -118,9 +132,9 @@ class Website_Resource extends Resource {
118
132
  }
119
133
  };
120
134
 
121
- if (web_database_resource) {
122
- spec_web_admin.web_database = web_database_resource;
123
- }
135
+ //if (web_database_resource) {
136
+ // spec_web_admin.web_database = web_database_resource;
137
+ //}
124
138
 
125
139
  var img_resource = new Site_Images({
126
140
  //'meta': {
@@ -149,9 +163,7 @@ class Website_Resource extends Resource {
149
163
  pool: resource_pool
150
164
  //}
151
165
  });
152
-
153
166
  resource_pool.push(static_html_resource);
154
-
155
167
  // Perhaps set it up with the specific files (automatically)?
156
168
  // Probably with the index.html
157
169
  }
@@ -184,7 +196,9 @@ class Website_Resource extends Resource {
184
196
  router.set_route("js/*", js_resource, js_resource.process);
185
197
  // As well as this, it could get the JavaScript resource to serve the JavaScript from the app's js directory.
186
198
  js_resource.serve_directory("js");
199
+ router.set_route("i/*", img_resource, img_resource.process);
187
200
  router.set_route("img/*", img_resource, img_resource.process);
201
+ router.set_route("imgs/*", img_resource, img_resource.process);
188
202
  router.set_route("images/*", img_resource, img_resource.process);
189
203
  this.map_resource_publishers = this.map_resource_publishers || {};
190
204
  router.set_route("resources/:resource_name/*", this, (req, res) => {
@@ -336,9 +350,7 @@ class Website_Resource extends Resource {
336
350
  if (rp.type === 'function') {
337
351
  if (rp.schema) def.schema = rp.schema;
338
352
  }
339
-
340
- })
341
-
353
+ });
342
354
  return res;
343
355
  }
344
356
 
@@ -38,6 +38,15 @@ var serve_html_file_from_disk = function(filePath, response) {
38
38
 
39
39
  // Transformation Resource could / should appear in jsgui3-client. Makes sense on the client too.
40
40
 
41
+ // Separate loading of transformation resource, data resource, and template (resource)
42
+ // The transformation resource can itself load / be provided with the data resource and template resource.
43
+
44
+ // jsx processing may be the best way (by far)?
45
+
46
+ // or jsui templates?
47
+ // jsx may seem / be easiest at this stage for long term expansion and integration.
48
+
49
+
41
50
 
42
51
  class Site_Static_HTML extends Resource {
43
52
 
@@ -83,48 +92,33 @@ class Site_Static_HTML extends Resource {
83
92
  }
84
93
  'process'(req, res) {
85
94
  //console.log('Site_Static_HTML processing');
86
-
87
-
88
-
89
-
90
95
  var remoteAddress = req.connection.remoteAddress;
91
-
92
96
  var custom_paths = this.custom_paths;
93
-
94
97
  var rurl = req.url;
95
-
96
98
  var pool = this.pool;
97
99
  // should have a bunch of resources from the pool.
98
-
99
100
  //var pool_resources = pool.resources();
100
101
  //console.log('pool_resources ' + stringify(pool_resources));
101
102
 
102
-
103
103
  var url_parts = url.parse(req.url, true);
104
104
  //console.log('url_parts ' + stringify(url_parts));
105
105
  var splitPath = url_parts.path.substr(1).split('/');
106
106
  //console.log('resource site css splitPath ' + stringify(splitPath));
107
107
 
108
-
109
108
  if (rurl.substr(0, 1) == '/') rurl = rurl.substr(1);
110
109
  rurl = rurl.replace(/\./g, '☺');
111
110
  //console.log('rurl ' + rurl);
112
111
 
113
112
  if (rurl == '') rurl = '/';
114
-
115
113
  var custom_response_entry = custom_paths.get(rurl);
116
-
117
114
  //console.log('Static HTML Resource process url', req.url);
118
115
 
119
116
 
120
-
121
-
122
117
  //console.log('custom_response_entry ' + stringify(custom_response_entry));
123
118
 
124
119
  if (custom_response_entry) {
125
120
  var tcr = tof(custom_response_entry);
126
121
  //console.log('tcr ' + tcr);
127
-
128
122
  if (tcr == 'data_value') {
129
123
  var val = custom_response_entry.value();
130
124
  //console.log('val ' + val);
@@ -195,7 +189,6 @@ class Site_Static_HTML extends Resource {
195
189
  if (splitPath.length == 3) {
196
190
 
197
191
  }
198
-
199
192
  }
200
193
  }
201
194
  }
package/server.js CHANGED
@@ -11,6 +11,10 @@ Website_Resource = require('./resources/website-resource'),
11
11
  Info = require('./resources/local-server-info-resource'),
12
12
  Server_Page_Context = require('./page-context'), {Evented_Class, each, tof} = jsgui;
13
13
 
14
+ // Operating JSGUI_Server as a proxy server or with improved proxy capabilities may help.
15
+
16
+ // The router is the same as on the client.
17
+
14
18
  class JSGUI_Server extends Evented_Class {
15
19
  constructor(spec = {website: true}, __type_name) {
16
20
  // Default operations mode...
@@ -47,6 +51,8 @@ class JSGUI_Server extends Evented_Class {
47
51
  });
48
52
  }
49
53
 
54
+ // Multiple websites - perhaps proxying to them.
55
+
50
56
  if (is_website) {
51
57
  const app = this.app = new Website_Resource({
52
58
  name: 'Website'
@@ -62,6 +68,10 @@ class JSGUI_Server extends Evented_Class {
62
68
  return this.resource_pool.resource_names;
63
69
  }
64
70
 
71
+ // could have those pairs. Possible websocket ports? websockets uses same ports: 80, 443.
72
+ // http_port, https_port
73
+
74
+
65
75
  'start'(port, callback, fnProcessRequest) {
66
76
  //throw 'stop';
67
77
  // The resource_pool is not just a Data_Value. need to fix some get or create new field value code.
@@ -105,7 +115,8 @@ class JSGUI_Server extends Evented_Class {
105
115
  //console.log('server_routing_res', server_routing_res);
106
116
  });
107
117
  https_server.timeout = 10800000;
108
- https_server.listen(443, ipv4_address);
118
+ //https_server.listen(443, ipv4_address);
119
+ https_server.listen(port, ipv4_address);
109
120
  num_to_start--;
110
121
  if (num_to_start === 0) {
111
122
  callback(null, true);