alchemymvc 1.3.22 → 1.4.0-alpha.2
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/LICENSE +1 -1
- package/README.md +3 -3
- package/lib/app/behaviour/publishable_behaviour.js +5 -5
- package/lib/app/behaviour/revision_behaviour.js +96 -59
- package/lib/app/behaviour/sluggable_behaviour.js +14 -14
- package/lib/app/conduit/electron_conduit.js +9 -9
- package/lib/app/conduit/http_conduit.js +13 -13
- package/lib/app/conduit/loopback_conduit.js +15 -15
- package/lib/app/conduit/socket_conduit.js +43 -43
- package/lib/app/config/routes.js +26 -0
- package/lib/app/controller/00-default_app_controller.js +21 -0
- package/lib/app/controller/alchemy_info_controller.js +12 -12
- package/lib/app/datasource/mongo_datasource.js +27 -18
- package/lib/app/element/00-default_app_element.js +19 -0
- package/lib/app/element/time_ago.js +5 -5
- package/lib/app/helper/00-default_app_helper.js +11 -0
- package/lib/app/helper/alchemy_helper.js +22 -22
- package/lib/app/helper/backed_map.js +1 -1
- package/lib/app/helper/breadcrumb.js +10 -10
- package/lib/app/helper/client_collection.js +3 -3
- package/lib/app/helper/cron.js +29 -29
- package/lib/app/helper/enum_values.js +6 -6
- package/lib/app/helper/pagination_helper.js +36 -36
- package/lib/app/helper/router_helper.js +35 -35
- package/lib/app/helper/socket_helper.js +57 -57
- package/lib/app/helper/syncable.js +62 -62
- package/lib/app/helper_component/paginate_component.js +9 -9
- package/lib/app/helper_controller/component.js +1 -1
- package/lib/app/helper_controller/conduit.js +31 -31
- package/lib/app/helper_controller/controller.js +54 -39
- package/lib/app/helper_datasource/00-nosql_datasource.js +624 -70
- package/lib/app/helper_datasource/05-fallback_datasource.js +10 -10
- package/lib/app/helper_datasource/idb_datasource.js +6 -6
- package/lib/app/helper_datasource/indexed_db.js +22 -22
- package/lib/app/helper_datasource/remote_datasource.js +5 -5
- package/lib/app/helper_error/http_error.js +4 -4
- package/lib/app/helper_error/model_error.js +2 -2
- package/lib/app/helper_error/validation_error.js +12 -12
- package/lib/app/helper_field/00-objectid_field.js +7 -7
- package/lib/app/helper_field/05-string_field.js +16 -12
- package/lib/app/helper_field/06-text_field.js +2 -4
- package/lib/app/helper_field/10-number_field.js +9 -12
- package/lib/app/helper_field/11-date_field.js +15 -15
- package/lib/app/helper_field/15-local_temporal_field.js +10 -10
- package/lib/app/helper_field/20-decimal_field.js +8 -9
- package/lib/app/helper_field/belongsto_field.js +1 -1
- package/lib/app/helper_field/big_int_field.js +8 -8
- package/lib/app/helper_field/boolean_field.js +9 -11
- package/lib/app/helper_field/datetime_field.js +3 -3
- package/lib/app/helper_field/enum_field.js +13 -8
- package/lib/app/helper_field/fixed_decimal_field.js +6 -7
- package/lib/app/helper_field/geopoint_field.js +9 -10
- package/lib/app/helper_field/habtm_field.js +3 -3
- package/lib/app/helper_field/hasoneparent_field.js +1 -1
- package/lib/app/helper_field/html_field.js +2 -4
- package/lib/app/helper_field/integer_field.js +8 -11
- package/lib/app/helper_field/local_date_field.js +5 -5
- package/lib/app/helper_field/local_date_time_field.js +5 -5
- package/lib/app/helper_field/local_time_field.js +5 -5
- package/lib/app/helper_field/mixed_field.js +5 -5
- package/lib/app/helper_field/object_field.js +6 -6
- package/lib/app/helper_field/password_field.js +3 -3
- package/lib/app/helper_field/regexp_field.js +7 -9
- package/lib/app/helper_field/schema_field.js +91 -88
- package/lib/app/helper_field/settings_field.js +92 -0
- package/lib/app/helper_field/time_field.js +6 -6
- package/lib/app/helper_field/url_field.js +2 -4
- package/lib/app/helper_model/00-base_criteria.js +662 -0
- package/lib/app/helper_model/05-criteria_expressions.js +605 -0
- package/lib/app/helper_model/10-model_criteria.js +1182 -0
- package/lib/app/helper_model/data_provider.js +2 -2
- package/lib/app/helper_model/document.js +103 -92
- package/lib/app/helper_model/document_list.js +14 -14
- package/lib/app/helper_model/field_config.js +11 -11
- package/lib/app/helper_model/field_set.js +17 -17
- package/lib/app/helper_model/model.js +201 -123
- package/lib/app/helper_model/remote_data_provider.js +2 -2
- package/lib/app/helper_validator/00_validator.js +16 -16
- package/lib/app/helper_validator/not_empty_validator.js +9 -9
- package/lib/app/model/00-default_app_model.js +18 -0
- package/lib/app/model/05-system_model.js +27 -0
- package/lib/app/model/{alchemy_migration_model.js → system_migration_model.js} +4 -4
- package/lib/app/model/system_setting_model.js +154 -0
- package/lib/app/model/{alchemy_task_history_model.js → system_task_history_model.js} +7 -7
- package/lib/app/model/{alchemy_task_model.js → system_task_model.js} +11 -11
- package/lib/bootstrap.js +22 -312
- package/lib/class/accumulator.js +5 -5
- package/lib/class/behaviour.js +5 -5
- package/lib/class/component.js +3 -3
- package/lib/class/conduit.js +152 -150
- package/lib/class/controller.js +42 -42
- package/lib/class/datasource.js +74 -79
- package/lib/class/document.js +74 -95
- package/lib/class/document_list.js +5 -5
- package/lib/class/element.js +17 -17
- package/lib/class/error.js +3 -3
- package/lib/class/field.js +169 -91
- package/lib/class/field_value.js +6 -6
- package/lib/class/helper.js +3 -3
- package/lib/class/inode.js +17 -17
- package/lib/class/inode_dir.js +12 -12
- package/lib/class/inode_file.js +26 -26
- package/lib/class/inode_list.js +4 -4
- package/lib/class/migration.js +4 -4
- package/lib/class/model.js +146 -165
- package/lib/class/path_definition.js +22 -22
- package/lib/class/path_evaluator.js +5 -5
- package/lib/class/path_param_definition.js +7 -7
- package/lib/class/plugin.js +312 -0
- package/lib/class/postponement.js +29 -29
- package/lib/class/reciprocal.js +8 -8
- package/lib/class/route.js +33 -33
- package/lib/class/router.js +73 -73
- package/lib/class/schema.js +21 -21
- package/lib/class/schema_client.js +105 -82
- package/lib/class/session.js +63 -29
- package/lib/class/session_scene.js +4 -4
- package/lib/class/sitemap.js +16 -16
- package/lib/class/task.js +39 -39
- package/lib/class/task_service.js +43 -47
- package/lib/{init → core}/alchemy.js +411 -373
- package/lib/{init/functions.js → core/alchemy_functions.js} +113 -91
- package/lib/core/alchemy_load_functions.js +715 -0
- package/lib/core/base.js +50 -62
- package/lib/core/client_alchemy.js +144 -152
- package/lib/core/client_base.js +27 -50
- package/lib/core/discovery.js +16 -18
- package/lib/core/middleware.js +54 -43
- package/lib/core/{routing.js → prefix.js} +14 -16
- package/lib/core/setting.js +1684 -0
- package/lib/core/stage.js +758 -0
- package/lib/scripts/create_constants.js +119 -0
- package/lib/{init/languages.js → scripts/create_languages.js} +5 -5
- package/lib/scripts/create_settings.js +449 -0
- package/lib/scripts/create_shared_constants.js +95 -0
- package/lib/scripts/create_stages.js +55 -0
- package/lib/scripts/init_alchemy.js +51 -0
- package/lib/{init/requirements.js → scripts/preload_modules.js} +15 -2
- package/lib/scripts/setup_devwatch.js +238 -0
- package/lib/stages/00-load_core.js +342 -0
- package/lib/stages/05-load_app.js +57 -0
- package/lib/stages/10-datasource.js +61 -0
- package/lib/stages/15-tasks.js +27 -0
- package/lib/stages/20-settings.js +68 -0
- package/lib/stages/50-routes.js +218 -0
- package/lib/stages/90-server.js +347 -0
- package/package.json +5 -7
- package/lib/app/helper_model/criteria.js +0 -2294
- package/lib/app/helper_model/db_query.js +0 -1488
- package/lib/app/routes.js +0 -11
- package/lib/core/socket.js +0 -171
- package/lib/init/constants.js +0 -158
- package/lib/init/devwatch.js +0 -238
- package/lib/init/load_functions.js +0 -979
- package/lib/stages.js +0 -515
package/lib/class/conduit.js
CHANGED
|
@@ -14,7 +14,7 @@ var libstream = alchemy.use('stream'),
|
|
|
14
14
|
/**
|
|
15
15
|
* The Conduit Class
|
|
16
16
|
*
|
|
17
|
-
* @author Jelle De Loecker
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
18
|
* @since 0.2.0
|
|
19
19
|
* @version 1.2.0
|
|
20
20
|
*
|
|
@@ -37,7 +37,7 @@ var Conduit = Function.inherits('Alchemy.Base', 'Alchemy.Conduit', function Cond
|
|
|
37
37
|
this._debugConduitInitialize = this._debugObject;
|
|
38
38
|
|
|
39
39
|
// Allow use of the log in the views
|
|
40
|
-
if (alchemy.settings.debug) {
|
|
40
|
+
if (alchemy.settings.debugging.debug) {
|
|
41
41
|
this.internal('debuglog', {_placeholder_: 'debuglog'});
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -61,7 +61,7 @@ var Conduit = Function.inherits('Alchemy.Base', 'Alchemy.Conduit', function Cond
|
|
|
61
61
|
/**
|
|
62
62
|
* Deprecated property names
|
|
63
63
|
*
|
|
64
|
-
* @author Jelle De Loecker
|
|
64
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
65
65
|
* @since 1.0.0
|
|
66
66
|
* @version 1.1.0
|
|
67
67
|
*/
|
|
@@ -75,7 +75,7 @@ Conduit.setDeprecatedProperty('sceneId', 'scene_id');
|
|
|
75
75
|
/**
|
|
76
76
|
* Return the cookies
|
|
77
77
|
*
|
|
78
|
-
* @author Jelle De Loecker
|
|
78
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
79
79
|
* @since 0.2.0
|
|
80
80
|
* @version 0.2.0
|
|
81
81
|
*/
|
|
@@ -86,7 +86,7 @@ Conduit.prepareProperty(function cookies() {
|
|
|
86
86
|
/**
|
|
87
87
|
* Return the parsed useragent string
|
|
88
88
|
*
|
|
89
|
-
* @author Jelle De Loecker
|
|
89
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
90
90
|
* @since 0.2.0
|
|
91
91
|
* @version 0.5.0
|
|
92
92
|
*/
|
|
@@ -97,7 +97,7 @@ Conduit.prepareProperty(function useragent() {
|
|
|
97
97
|
/**
|
|
98
98
|
* Create a Hawkejs Renderer
|
|
99
99
|
*
|
|
100
|
-
* @author Jelle De Loecker
|
|
100
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
101
101
|
* @since 0.2.0
|
|
102
102
|
* @version 1.1.5
|
|
103
103
|
*/
|
|
@@ -117,7 +117,7 @@ Conduit.prepareProperty(function renderer() {
|
|
|
117
117
|
/**
|
|
118
118
|
* Get the SessionScene instance
|
|
119
119
|
*
|
|
120
|
-
* @author Jelle De Loecker
|
|
120
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
121
121
|
* @since 1.3.10
|
|
122
122
|
* @version 1.3.10
|
|
123
123
|
*/
|
|
@@ -128,18 +128,18 @@ Conduit.setProperty(function scene() {
|
|
|
128
128
|
/**
|
|
129
129
|
* The session cookie name to use
|
|
130
130
|
*
|
|
131
|
-
* @author Jelle De Loecker
|
|
131
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
132
132
|
* @since 1.3.18
|
|
133
133
|
* @version 1.3.18
|
|
134
134
|
*/
|
|
135
135
|
Conduit.setProperty(function session_cookie_name() {
|
|
136
|
-
return alchemy.settings.
|
|
136
|
+
return alchemy.settings.sessions.cookie_name || 'alchemy_sid';
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Enforce the scene_id
|
|
141
141
|
*
|
|
142
|
-
* @author Jelle De Loecker
|
|
142
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
143
143
|
* @since 1.1.0
|
|
144
144
|
* @version 1.3.18
|
|
145
145
|
*/
|
|
@@ -187,7 +187,7 @@ Conduit.enforceProperty(function scene_id(new_value, old_value) {
|
|
|
187
187
|
/**
|
|
188
188
|
* Enforce the active_prefix
|
|
189
189
|
*
|
|
190
|
-
* @author Jelle De Loecker
|
|
190
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
191
191
|
* @since 1.1.0
|
|
192
192
|
* @version 1.1.5
|
|
193
193
|
*/
|
|
@@ -226,7 +226,7 @@ Conduit.enforceProperty(function active_prefix(new_value, old_value) {
|
|
|
226
226
|
/**
|
|
227
227
|
* Get a session object by id
|
|
228
228
|
*
|
|
229
|
-
* @author Jelle De Loecker
|
|
229
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
230
230
|
* @since 0.2.0
|
|
231
231
|
* @version 0.2.0
|
|
232
232
|
*/
|
|
@@ -237,7 +237,7 @@ Conduit.setStatic(function getSessionById(id) {
|
|
|
237
237
|
/**
|
|
238
238
|
* See if this is a secure connection
|
|
239
239
|
*
|
|
240
|
-
* @author Jelle De Loecker
|
|
240
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
241
241
|
* @since 0.4.2
|
|
242
242
|
* @version 1.0.2
|
|
243
243
|
*/
|
|
@@ -245,7 +245,7 @@ Conduit.setProperty(function is_secure() {
|
|
|
245
245
|
|
|
246
246
|
var protocol;
|
|
247
247
|
|
|
248
|
-
if (alchemy.settings.assume_https) {
|
|
248
|
+
if (alchemy.settings.network.assume_https) {
|
|
249
249
|
return true;
|
|
250
250
|
}
|
|
251
251
|
|
|
@@ -271,11 +271,11 @@ Conduit.setProperty(function is_secure() {
|
|
|
271
271
|
/**
|
|
272
272
|
* Set the request body
|
|
273
273
|
*
|
|
274
|
-
* @author Jelle De Loecker
|
|
274
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
275
275
|
* @since 1.1.0
|
|
276
276
|
* @version 1.3.18
|
|
277
277
|
*
|
|
278
|
-
* @param {Object|
|
|
278
|
+
* @param {Object|string}
|
|
279
279
|
*/
|
|
280
280
|
Conduit.setMethod(function setRequestBody(body) {
|
|
281
281
|
|
|
@@ -294,7 +294,7 @@ Conduit.setMethod(function setRequestBody(body) {
|
|
|
294
294
|
/**
|
|
295
295
|
* Has the given route been tested yet?
|
|
296
296
|
*
|
|
297
|
-
* @author Jelle De Loecker
|
|
297
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
298
298
|
* @since 1.2.5
|
|
299
299
|
* @version 1.2.5
|
|
300
300
|
*
|
|
@@ -312,7 +312,7 @@ Conduit.setMethod(function hasRouteBeenTested(route) {
|
|
|
312
312
|
/**
|
|
313
313
|
* Mark this route as having been tested
|
|
314
314
|
*
|
|
315
|
-
* @author Jelle De Loecker
|
|
315
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
316
316
|
* @since 1.2.5
|
|
317
317
|
* @version 1.2.5
|
|
318
318
|
*
|
|
@@ -331,11 +331,11 @@ Conduit.setMethod(function markRouteAsTested(route) {
|
|
|
331
331
|
* Rewrite a certain URL parameter
|
|
332
332
|
* (Causing some kind of redirect)
|
|
333
333
|
*
|
|
334
|
-
* @author Jelle De Loecker
|
|
334
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
335
335
|
* @since 1.2.5
|
|
336
336
|
* @version 1.2.5
|
|
337
337
|
*
|
|
338
|
-
* @param {
|
|
338
|
+
* @param {string} route_param
|
|
339
339
|
* @param {*} new_value
|
|
340
340
|
*/
|
|
341
341
|
Conduit.setMethod(function rewriteRequestRouteParam(route_param, new_value) {
|
|
@@ -350,7 +350,7 @@ Conduit.setMethod(function rewriteRequestRouteParam(route_param, new_value) {
|
|
|
350
350
|
/**
|
|
351
351
|
* Set the request files
|
|
352
352
|
*
|
|
353
|
-
* @author Jelle De Loecker
|
|
353
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
354
354
|
* @since 1.1.0
|
|
355
355
|
* @version 1.1.0
|
|
356
356
|
*
|
|
@@ -368,7 +368,7 @@ Conduit.setMethod(function setRequestFiles(files) {
|
|
|
368
368
|
/**
|
|
369
369
|
* Set the request files
|
|
370
370
|
*
|
|
371
|
-
* @author Jelle De Loecker
|
|
371
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
372
372
|
* @since 1.2.0
|
|
373
373
|
* @version 1.3.0
|
|
374
374
|
*
|
|
@@ -403,7 +403,7 @@ function _setRequestFiles(conduit, files, target) {
|
|
|
403
403
|
/**
|
|
404
404
|
* Don't convert a conduit to any special json data
|
|
405
405
|
*
|
|
406
|
-
* @author Jelle De Loecker
|
|
406
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
407
407
|
* @since 0.2.0
|
|
408
408
|
* @version 0.2.0
|
|
409
409
|
*/
|
|
@@ -414,7 +414,7 @@ Conduit.setMethod(function toJSON() {
|
|
|
414
414
|
/**
|
|
415
415
|
* Set the request & response objects
|
|
416
416
|
*
|
|
417
|
-
* @author Jelle De Loecker
|
|
417
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
418
418
|
* @since 1.2.0
|
|
419
419
|
* @version 1.2.0
|
|
420
420
|
*/
|
|
@@ -445,7 +445,7 @@ Conduit.setMethod(function setReqRes(req, res) {
|
|
|
445
445
|
/**
|
|
446
446
|
* Init values
|
|
447
447
|
*
|
|
448
|
-
* @author Jelle De Loecker
|
|
448
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
449
449
|
* @since 0.3.3
|
|
450
450
|
* @version 1.3.15
|
|
451
451
|
*/
|
|
@@ -498,7 +498,7 @@ Conduit.setMethod(function initValues() {
|
|
|
498
498
|
/**
|
|
499
499
|
* Get the time since the conduit was made
|
|
500
500
|
*
|
|
501
|
-
* @author Jelle De Loecker
|
|
501
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
502
502
|
* @since 0.2.0
|
|
503
503
|
* @version 1.1.0
|
|
504
504
|
*/
|
|
@@ -509,7 +509,7 @@ Conduit.setMethod(function time() {
|
|
|
509
509
|
/**
|
|
510
510
|
* Parse the request, get information from the url
|
|
511
511
|
*
|
|
512
|
-
* @author Jelle De Loecker
|
|
512
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
513
513
|
* @since 0.2.0
|
|
514
514
|
* @version 1.3.18
|
|
515
515
|
*
|
|
@@ -552,7 +552,7 @@ Conduit.setMethod(async function parseRequest() {
|
|
|
552
552
|
/**
|
|
553
553
|
* Parse the complete request URL if it hasn't been done yet
|
|
554
554
|
*
|
|
555
|
-
* @author Jelle De Loecker
|
|
555
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
556
556
|
* @since 1.3.18
|
|
557
557
|
* @version 1.3.19
|
|
558
558
|
*/
|
|
@@ -565,7 +565,7 @@ Conduit.setMethod(function parseUrl() {
|
|
|
565
565
|
|
|
566
566
|
let protocol;
|
|
567
567
|
|
|
568
|
-
if (alchemy.settings.assume_https) {
|
|
568
|
+
if (alchemy.settings.network.assume_https) {
|
|
569
569
|
protocol = 'https://';
|
|
570
570
|
} else if (this.headers['x-forwarded-proto']) {
|
|
571
571
|
protocol = this.headers['x-forwarded-proto'];
|
|
@@ -592,7 +592,7 @@ Conduit.setMethod(function parseUrl() {
|
|
|
592
592
|
this.url.hostname = host;
|
|
593
593
|
|
|
594
594
|
// If no URL was set, use the first requests URL (without the path)
|
|
595
|
-
if (!alchemy.settings.
|
|
595
|
+
if (!alchemy.settings.network.main_url && host) {
|
|
596
596
|
alchemy.setUrl(this.url);
|
|
597
597
|
}
|
|
598
598
|
|
|
@@ -605,7 +605,7 @@ Conduit.setMethod(function parseUrl() {
|
|
|
605
605
|
/**
|
|
606
606
|
* Parse the headers for shortcuts
|
|
607
607
|
*
|
|
608
|
-
* @author Jelle De Loecker
|
|
608
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
609
609
|
* @since 0.2.0
|
|
610
610
|
* @version 1.3.17
|
|
611
611
|
*/
|
|
@@ -642,7 +642,7 @@ Conduit.setMethod(function parseShortcuts() {
|
|
|
642
642
|
/**
|
|
643
643
|
* Sort the parsed accept-language header array
|
|
644
644
|
*
|
|
645
|
-
* @author Jelle De Loecker
|
|
645
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
646
646
|
* @since 0.0.1
|
|
647
647
|
* @version 0.0.1
|
|
648
648
|
*
|
|
@@ -662,7 +662,7 @@ function qualityCmp(a, b) {
|
|
|
662
662
|
/**
|
|
663
663
|
* Parses the HTTP accept-language header
|
|
664
664
|
*
|
|
665
|
-
* @author Jelle De Loecker
|
|
665
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
666
666
|
* @since 0.0.1
|
|
667
667
|
* @version 0.2.0
|
|
668
668
|
*/
|
|
@@ -726,7 +726,7 @@ Conduit.setMethod(function parseLanguages() {
|
|
|
726
726
|
* Parses accept-encoding strings
|
|
727
727
|
*
|
|
728
728
|
* @author jshttp
|
|
729
|
-
* @author Jelle De Loecker
|
|
729
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
730
730
|
* @since 0.2.0
|
|
731
731
|
* @version 0.2.0
|
|
732
732
|
*/
|
|
@@ -759,7 +759,7 @@ function parseEncoding(s, i) {
|
|
|
759
759
|
* Parses accept-encoding strings
|
|
760
760
|
*
|
|
761
761
|
* @author jshttp
|
|
762
|
-
* @author Jelle De Loecker
|
|
762
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
763
763
|
* @since 0.2.0
|
|
764
764
|
* @version 0.2.0
|
|
765
765
|
*/
|
|
@@ -782,7 +782,7 @@ function specify(encoding, spec, index) {
|
|
|
782
782
|
/**
|
|
783
783
|
* Parses the HTTP accept-encoding header
|
|
784
784
|
*
|
|
785
|
-
* @author Jelle De Loecker
|
|
785
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
786
786
|
* @since 0.2.0
|
|
787
787
|
* @version 0.2.0
|
|
788
788
|
*/
|
|
@@ -839,7 +839,7 @@ Conduit.setMethod(function parseAcceptEncoding() {
|
|
|
839
839
|
/**
|
|
840
840
|
* See if the wanted encoding is accepted by the client
|
|
841
841
|
*
|
|
842
|
-
* @author Jelle De Loecker
|
|
842
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
843
843
|
* @since 0.2.0
|
|
844
844
|
* @version 0.2.0
|
|
845
845
|
*/
|
|
@@ -866,7 +866,7 @@ Conduit.setMethod(function accepts(encoding) {
|
|
|
866
866
|
/**
|
|
867
867
|
* Create a loopback conduit
|
|
868
868
|
*
|
|
869
|
-
* @author Jelle De Loecker
|
|
869
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
870
870
|
* @since 0.2.0
|
|
871
871
|
* @version 1.1.3
|
|
872
872
|
*
|
|
@@ -882,7 +882,7 @@ Conduit.setMethod(function loopback(args, callback) {
|
|
|
882
882
|
/**
|
|
883
883
|
* Parse the request, get information from the url
|
|
884
884
|
*
|
|
885
|
-
* @author Jelle De Loecker
|
|
885
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
886
886
|
* @since 0.2.0
|
|
887
887
|
* @version 1.1.0
|
|
888
888
|
*/
|
|
@@ -982,7 +982,7 @@ Conduit.setMethod(function parsePrefix() {
|
|
|
982
982
|
/**
|
|
983
983
|
* Get the section
|
|
984
984
|
*
|
|
985
|
-
* @author Jelle De Loecker
|
|
985
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
986
986
|
* @since 0.2.0
|
|
987
987
|
* @version 0.2.1
|
|
988
988
|
*/
|
|
@@ -1006,11 +1006,11 @@ Conduit.setMethod(function parseSection() {
|
|
|
1006
1006
|
/**
|
|
1007
1007
|
* Get a route by its name
|
|
1008
1008
|
*
|
|
1009
|
-
* @author Jelle De Loecker
|
|
1009
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1010
1010
|
* @since 0.2.0
|
|
1011
1011
|
* @version 0.2.0
|
|
1012
1012
|
*
|
|
1013
|
-
* @param {
|
|
1013
|
+
* @param {string|Object} name The name of the route
|
|
1014
1014
|
*/
|
|
1015
1015
|
Conduit.setMethod(function getRouteByName(name) {
|
|
1016
1016
|
|
|
@@ -1027,13 +1027,13 @@ Conduit.setMethod(function getRouteByName(name) {
|
|
|
1027
1027
|
/**
|
|
1028
1028
|
* Get the Route instance & named parameters
|
|
1029
1029
|
*
|
|
1030
|
-
* @author Jelle De Loecker
|
|
1030
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1031
1031
|
* @since 0.2.0
|
|
1032
1032
|
* @version 1.3.0
|
|
1033
1033
|
*
|
|
1034
1034
|
* @param {Route} after_route Only check routes after this one
|
|
1035
1035
|
*
|
|
1036
|
-
* @return {
|
|
1036
|
+
* @return {boolean} Continue processing this request or not?
|
|
1037
1037
|
*/
|
|
1038
1038
|
Conduit.setMethod(async function parseRoute(after_route) {
|
|
1039
1039
|
|
|
@@ -1109,7 +1109,7 @@ Conduit.setMethod(async function parseRoute(after_route) {
|
|
|
1109
1109
|
/**
|
|
1110
1110
|
* Run the middleware
|
|
1111
1111
|
*
|
|
1112
|
-
* @author Jelle De Loecker
|
|
1112
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1113
1113
|
* @since 0.2.0
|
|
1114
1114
|
* @version 1.1.5
|
|
1115
1115
|
*/
|
|
@@ -1224,7 +1224,7 @@ Conduit.setMethod(async function callMiddleware() {
|
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Create a new Hawkejs' ViewRender instance
|
|
1226
1226
|
*
|
|
1227
|
-
* @author Jelle De Loecker
|
|
1227
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1228
1228
|
* @since 0.2.0
|
|
1229
1229
|
* @version 1.3.17
|
|
1230
1230
|
*/
|
|
@@ -1255,7 +1255,7 @@ Conduit.setMethod(function prepareViewRender() {
|
|
|
1255
1255
|
/**
|
|
1256
1256
|
* Call the handler of this route when parsing is finished
|
|
1257
1257
|
*
|
|
1258
|
-
* @author Jelle De Loecker
|
|
1258
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1259
1259
|
* @since 0.2.0
|
|
1260
1260
|
* @version 1.3.16
|
|
1261
1261
|
*/
|
|
@@ -1265,14 +1265,14 @@ Conduit.setMethod(function callHandler() {
|
|
|
1265
1265
|
|
|
1266
1266
|
if (this.route_mismatch) {
|
|
1267
1267
|
|
|
1268
|
-
if (alchemy.settings.debug) {
|
|
1268
|
+
if (alchemy.settings.debugging.debug) {
|
|
1269
1269
|
console.log('Route method not allowed:', this);
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
1272
|
this.error(405, 'Method Not Allowed', false);
|
|
1273
1273
|
|
|
1274
1274
|
} else {
|
|
1275
|
-
if (alchemy.settings.debug && this.original_path.indexOf('.js.map') == -1) {
|
|
1275
|
+
if (alchemy.settings.debugging.debug && this.original_path.indexOf('.js.map') == -1) {
|
|
1276
1276
|
console.log('Route not found:', this);
|
|
1277
1277
|
}
|
|
1278
1278
|
|
|
@@ -1288,7 +1288,7 @@ Conduit.setMethod(function callHandler() {
|
|
|
1288
1288
|
/**
|
|
1289
1289
|
* Put this request in a queue
|
|
1290
1290
|
*
|
|
1291
|
-
* @author Jelle De Loecker
|
|
1291
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1292
1292
|
* @since 1.3.1
|
|
1293
1293
|
* @version 1.3.1
|
|
1294
1294
|
*
|
|
@@ -1312,11 +1312,11 @@ Conduit.setMethod(function postponeAndQueue(options) {
|
|
|
1312
1312
|
*
|
|
1313
1313
|
* This does not stop the current request from processing.
|
|
1314
1314
|
*
|
|
1315
|
-
* @author Jelle De Loecker
|
|
1315
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1316
1316
|
* @since 1.3.1
|
|
1317
1317
|
* @version 1.3.1
|
|
1318
1318
|
*
|
|
1319
|
-
* @param {
|
|
1319
|
+
* @param {number|Object} options Options or time to wait
|
|
1320
1320
|
*
|
|
1321
1321
|
* @return {Alchemy.Conduit.Postponement}
|
|
1322
1322
|
*/
|
|
@@ -1337,11 +1337,11 @@ Conduit.setMethod(function postponeRequest(options) {
|
|
|
1337
1337
|
*
|
|
1338
1338
|
* This does not stop the current request from processing.
|
|
1339
1339
|
*
|
|
1340
|
-
* @author Jelle De Loecker
|
|
1340
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1341
1341
|
* @since 1.1.0
|
|
1342
1342
|
* @version 1.3.1
|
|
1343
1343
|
*
|
|
1344
|
-
* @param {
|
|
1344
|
+
* @param {number|Object} options Options or time to wait
|
|
1345
1345
|
*
|
|
1346
1346
|
* @return {Alchemy.Conduit.Postponement}
|
|
1347
1347
|
*/
|
|
@@ -1361,7 +1361,7 @@ Conduit.setMethod(function postponeResponse(options) {
|
|
|
1361
1361
|
/**
|
|
1362
1362
|
* Handle the postponement
|
|
1363
1363
|
*
|
|
1364
|
-
* @author Jelle De Loecker
|
|
1364
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1365
1365
|
* @since 1.3.1
|
|
1366
1366
|
* @version 1.3.1
|
|
1367
1367
|
*
|
|
@@ -1411,11 +1411,11 @@ Conduit.setMethod(function _postpone(options) {
|
|
|
1411
1411
|
*
|
|
1412
1412
|
* @deprecated Use {@link #setResponseUrl} instead
|
|
1413
1413
|
*
|
|
1414
|
-
* @author Jelle De Loecker
|
|
1414
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1415
1415
|
* @since 1.2.5
|
|
1416
1416
|
* @version 1.3.0
|
|
1417
1417
|
*
|
|
1418
|
-
* @param {
|
|
1418
|
+
* @param {string|RURL} url
|
|
1419
1419
|
*/
|
|
1420
1420
|
Conduit.setMethod(function overrideResponseUrl(url) {
|
|
1421
1421
|
return this.setResponseUrl(url);
|
|
@@ -1424,11 +1424,11 @@ Conduit.setMethod(function overrideResponseUrl(url) {
|
|
|
1424
1424
|
/**
|
|
1425
1425
|
* Set the response url
|
|
1426
1426
|
*
|
|
1427
|
-
* @author Jelle De Loecker
|
|
1427
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1428
1428
|
* @since 1.3.0
|
|
1429
1429
|
* @version 1.3.0
|
|
1430
1430
|
*
|
|
1431
|
-
* @param {
|
|
1431
|
+
* @param {string|RURL|boolean} new_url
|
|
1432
1432
|
*/
|
|
1433
1433
|
Conduit.setMethod(function setResponseUrl(new_url) {
|
|
1434
1434
|
|
|
@@ -1454,12 +1454,12 @@ Conduit.setMethod(function setResponseUrl(new_url) {
|
|
|
1454
1454
|
/**
|
|
1455
1455
|
* Redirect to another url
|
|
1456
1456
|
*
|
|
1457
|
-
* @author Jelle De Loecker
|
|
1457
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1458
1458
|
* @since 0.2.0
|
|
1459
1459
|
* @version 1.3.17
|
|
1460
1460
|
*
|
|
1461
|
-
* @param {
|
|
1462
|
-
* @param {
|
|
1461
|
+
* @param {number} status 3xx redirection codes. 302 (temporary redirect) by default
|
|
1462
|
+
* @param {string|Object} options Options or url
|
|
1463
1463
|
*/
|
|
1464
1464
|
Conduit.setMethod(function redirect(status, options) {
|
|
1465
1465
|
|
|
@@ -1541,12 +1541,12 @@ Conduit.setMethod(function redirect(status, options) {
|
|
|
1541
1541
|
this.status = status;
|
|
1542
1542
|
|
|
1543
1543
|
// Make sure the url is an internal one if no hard refresh is requested
|
|
1544
|
-
if (!hard_refresh && alchemy.settings.
|
|
1544
|
+
if (!hard_refresh && alchemy.settings.network.main_url) {
|
|
1545
1545
|
let rurl = RURL.parse(url);
|
|
1546
1546
|
|
|
1547
1547
|
// If an explicit hostname is set, this might be an external url
|
|
1548
1548
|
if (rurl.hostname) {
|
|
1549
|
-
let base_url = RURL.parse(alchemy.settings.
|
|
1549
|
+
let base_url = RURL.parse(alchemy.settings.network.main_url);
|
|
1550
1550
|
|
|
1551
1551
|
if (base_url.hostname != rurl.hostname) {
|
|
1552
1552
|
hard_refresh = true;
|
|
@@ -1576,13 +1576,13 @@ Conduit.setMethod(function redirect(status, options) {
|
|
|
1576
1576
|
/**
|
|
1577
1577
|
* Respond with an error
|
|
1578
1578
|
*
|
|
1579
|
-
* @author Jelle De Loecker
|
|
1579
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1580
1580
|
* @since 0.2.0
|
|
1581
1581
|
* @version 1.3.21
|
|
1582
1582
|
*
|
|
1583
1583
|
* @param {Nulber} status Response statuscode
|
|
1584
1584
|
* @param {Error} message Optional error to send
|
|
1585
|
-
* @param {
|
|
1585
|
+
* @param {boolean} print_error Print the error, defaults to true
|
|
1586
1586
|
*/
|
|
1587
1587
|
Conduit.setMethod(function error(status, message, print_error) {
|
|
1588
1588
|
|
|
@@ -1683,11 +1683,11 @@ Conduit.setMethod(function error(status, message, print_error) {
|
|
|
1683
1683
|
/**
|
|
1684
1684
|
* Deny access
|
|
1685
1685
|
*
|
|
1686
|
-
* @author Jelle De Loecker
|
|
1686
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1687
1687
|
* @since 0.2.0
|
|
1688
1688
|
* @version 1.1.0
|
|
1689
1689
|
*
|
|
1690
|
-
* @param {
|
|
1690
|
+
* @param {number} status
|
|
1691
1691
|
* @param {Error} message optional error to send
|
|
1692
1692
|
*/
|
|
1693
1693
|
Conduit.setMethod(function deny(status, message) {
|
|
@@ -1710,11 +1710,11 @@ Conduit.setMethod(function deny(status, message) {
|
|
|
1710
1710
|
* The current user is not authorized and needs to log in
|
|
1711
1711
|
* (Default implementation, is overriden by the acl plugin)
|
|
1712
1712
|
*
|
|
1713
|
-
* @author Jelle De Loecker
|
|
1713
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1714
1714
|
* @since 1.0.7
|
|
1715
1715
|
* @version 1.0.7
|
|
1716
1716
|
*
|
|
1717
|
-
* @param {
|
|
1717
|
+
* @param {boolean} tried_auth Indicate that this was an auth attempt
|
|
1718
1718
|
*/
|
|
1719
1719
|
Conduit.setMethod(function notAuthorized(tried_auth) {
|
|
1720
1720
|
return this.deny();
|
|
@@ -1724,9 +1724,9 @@ Conduit.setMethod(function notAuthorized(tried_auth) {
|
|
|
1724
1724
|
* The current user is authenticated, but not allowed
|
|
1725
1725
|
* (Default implementation, is overriden by the acl plugin)
|
|
1726
1726
|
*
|
|
1727
|
-
* @author
|
|
1728
|
-
* @since
|
|
1729
|
-
* @version
|
|
1727
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1728
|
+
* @since 1.0.7
|
|
1729
|
+
* @version 1.1.0
|
|
1730
1730
|
*/
|
|
1731
1731
|
Conduit.setMethod(function forbidden() {
|
|
1732
1732
|
|
|
@@ -1739,7 +1739,7 @@ Conduit.setMethod(function forbidden() {
|
|
|
1739
1739
|
/**
|
|
1740
1740
|
* Respond with a not found error status
|
|
1741
1741
|
*
|
|
1742
|
-
* @author Jelle De Loecker
|
|
1742
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1743
1743
|
* @since 0.2.0
|
|
1744
1744
|
* @version 1.1.0
|
|
1745
1745
|
*
|
|
@@ -1769,7 +1769,7 @@ Conduit.setMethod(async function notFound(message) {
|
|
|
1769
1769
|
/**
|
|
1770
1770
|
* Respond with a "Not Modified" 304 status
|
|
1771
1771
|
*
|
|
1772
|
-
* @author Jelle De Loecker
|
|
1772
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1773
1773
|
* @since 0.2.0
|
|
1774
1774
|
* @version 0.4.0
|
|
1775
1775
|
*/
|
|
@@ -1781,11 +1781,11 @@ Conduit.setMethod(function notModified() {
|
|
|
1781
1781
|
/**
|
|
1782
1782
|
* Respond with text. Objects get JSON-dry encoded
|
|
1783
1783
|
*
|
|
1784
|
-
* @author Jelle De Loecker
|
|
1784
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1785
1785
|
* @since 0.2.0
|
|
1786
1786
|
* @version 1.3.0
|
|
1787
1787
|
*
|
|
1788
|
-
* @param {
|
|
1788
|
+
* @param {string|Object} message
|
|
1789
1789
|
*/
|
|
1790
1790
|
Conduit.setMethod(function end(message) {
|
|
1791
1791
|
|
|
@@ -1811,7 +1811,7 @@ Conduit.setMethod(function end(message) {
|
|
|
1811
1811
|
}
|
|
1812
1812
|
|
|
1813
1813
|
// Use regular JSON if DRY has been disabled in settings
|
|
1814
|
-
if (alchemy.settings.
|
|
1814
|
+
if (alchemy.settings.network.use_json_dry_response === false || this.json_dry === false) {
|
|
1815
1815
|
json_type = 'json';
|
|
1816
1816
|
json_fnc = JSON.stringify;
|
|
1817
1817
|
} else {
|
|
@@ -1833,7 +1833,7 @@ Conduit.setMethod(function end(message) {
|
|
|
1833
1833
|
cache = this.headers['cache-control'] || this.headers['pragma'];
|
|
1834
1834
|
|
|
1835
1835
|
// Only generate etags when caching is enabled locally & on the browser
|
|
1836
|
-
if (alchemy.settings.cache !== false && (cache == null || cache != 'no-cache')) {
|
|
1836
|
+
if (alchemy.settings.performance.cache !== false && (cache == null || cache != 'no-cache')) {
|
|
1837
1837
|
|
|
1838
1838
|
// Calculate the hash as etag
|
|
1839
1839
|
etag = alchemy.checksum(message);
|
|
@@ -1853,7 +1853,7 @@ Conduit.setMethod(function end(message) {
|
|
|
1853
1853
|
}
|
|
1854
1854
|
|
|
1855
1855
|
// No need to replace anything if debugging is disabled or the log is empty
|
|
1856
|
-
if (alchemy.settings.debug && this.debuglog && this.debuglog.length && message.indexOf('_placeholder_') > -1) {
|
|
1856
|
+
if (alchemy.settings.debugging.debug && this.debuglog && this.debuglog.length && message.indexOf('_placeholder_') > -1) {
|
|
1857
1857
|
temp = JSON.dry(this.debuglog);
|
|
1858
1858
|
message = message.replace(/{\s*"_placeholder_":\s*"debuglog"\s*}/g, temp);
|
|
1859
1859
|
message = message.replace(/{\s*\\"_placeholder_\\":\s*\\"debuglog\\"\s*}/g, JSON.stringify(temp).slice(1,-1));
|
|
@@ -1861,7 +1861,7 @@ Conduit.setMethod(function end(message) {
|
|
|
1861
1861
|
|
|
1862
1862
|
// Compress the output if the client accepts it,
|
|
1863
1863
|
// but only if the file is at least 150 bytes
|
|
1864
|
-
if (alchemy.settings.
|
|
1864
|
+
if (alchemy.settings.network.use_compression !== false && message.length > 150 && this.accepts('gzip')) {
|
|
1865
1865
|
|
|
1866
1866
|
// Set the decompressed content-length for use in progress bars
|
|
1867
1867
|
this.setHeader('x-decompressed-content-length', Buffer.byteLength(message));
|
|
@@ -1885,7 +1885,7 @@ Conduit.setMethod(function end(message) {
|
|
|
1885
1885
|
/**
|
|
1886
1886
|
* End with a stream
|
|
1887
1887
|
*
|
|
1888
|
-
* @author Jelle De Loecker
|
|
1888
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1889
1889
|
* @since 1.3.22
|
|
1890
1890
|
* @version 1.3.22
|
|
1891
1891
|
*/
|
|
@@ -1902,7 +1902,7 @@ Conduit.setMethod(function _endWithStream(stream) {
|
|
|
1902
1902
|
/**
|
|
1903
1903
|
* Call the actual end method
|
|
1904
1904
|
*
|
|
1905
|
-
* @author Jelle De Loecker
|
|
1905
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1906
1906
|
* @since 0.2.0
|
|
1907
1907
|
* @version 1.3.22
|
|
1908
1908
|
*/
|
|
@@ -1945,7 +1945,7 @@ Conduit.setMethod(function _end(message, encoding = 'utf-8') {
|
|
|
1945
1945
|
/**
|
|
1946
1946
|
* Flush the headers
|
|
1947
1947
|
*
|
|
1948
|
-
* @author Jelle De Loecker
|
|
1948
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1949
1949
|
* @since 1.3.22
|
|
1950
1950
|
* @version 1.3.22
|
|
1951
1951
|
*/
|
|
@@ -1985,7 +1985,7 @@ Conduit.setMethod(function flushHeaders() {
|
|
|
1985
1985
|
/**
|
|
1986
1986
|
* Send a response to the client
|
|
1987
1987
|
*
|
|
1988
|
-
* @author Jelle De Loecker
|
|
1988
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1989
1989
|
* @since 0.2.0
|
|
1990
1990
|
* @version 0.2.0
|
|
1991
1991
|
*/
|
|
@@ -1997,7 +1997,7 @@ Conduit.setMethod(function send(content) {
|
|
|
1997
1997
|
* Create the scene id (if it doesn't exist already)
|
|
1998
1998
|
* We do this using cookies, so the HTML response can be cached
|
|
1999
1999
|
*
|
|
2000
|
-
* @author Jelle De Loecker
|
|
2000
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2001
2001
|
* @since 0.2.0
|
|
2002
2002
|
* @version 1.1.0
|
|
2003
2003
|
*/
|
|
@@ -2008,7 +2008,7 @@ Conduit.setMethod(function createScene() {
|
|
|
2008
2008
|
/**
|
|
2009
2009
|
* Render a view and send it to the client
|
|
2010
2010
|
*
|
|
2011
|
-
* @author Jelle De Loecker
|
|
2011
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2012
2012
|
* @since 0.2.0
|
|
2013
2013
|
* @version 1.3.17
|
|
2014
2014
|
*/
|
|
@@ -2093,7 +2093,7 @@ Conduit.setMethod(function render(template_name, options, callback) {
|
|
|
2093
2093
|
/**
|
|
2094
2094
|
* Convert a buffer into a stream
|
|
2095
2095
|
*
|
|
2096
|
-
* @author Jelle De Loecker
|
|
2096
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2097
2097
|
* @since 1.1.0
|
|
2098
2098
|
* @version 1.1.0
|
|
2099
2099
|
*
|
|
@@ -2116,11 +2116,11 @@ function bufferToStream(buffer) {
|
|
|
2116
2116
|
/**
|
|
2117
2117
|
* Send a file to the browser
|
|
2118
2118
|
*
|
|
2119
|
-
* @author Jelle De Loecker
|
|
2119
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2120
2120
|
* @since 0.2.0
|
|
2121
2121
|
* @version 1.3.0
|
|
2122
2122
|
*
|
|
2123
|
-
* @param {
|
|
2123
|
+
* @param {string} path The path on the server to send to the browser
|
|
2124
2124
|
* @param {Object} options Options, including headers
|
|
2125
2125
|
*/
|
|
2126
2126
|
Conduit.setTypedMethod([Types.String, Types.Object.optional()], function serveFile(path, options = {}) {
|
|
@@ -2137,7 +2137,7 @@ Conduit.setTypedMethod([Types.String, Types.Object.optional()], function serveFi
|
|
|
2137
2137
|
/**
|
|
2138
2138
|
* Send a file to the browser
|
|
2139
2139
|
*
|
|
2140
|
-
* @author Jelle De Loecker
|
|
2140
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2141
2141
|
* @since 0.2.0
|
|
2142
2142
|
* @version 1.3.13
|
|
2143
2143
|
*
|
|
@@ -2152,7 +2152,7 @@ Conduit.setTypedMethod([Types.Alchemy.Inode.File, Types.Object.optional()], asyn
|
|
|
2152
2152
|
|
|
2153
2153
|
let stats = await file.getStats();
|
|
2154
2154
|
|
|
2155
|
-
if (alchemy.settings.cache && (!options.cache_time && options.cache_time !== false)) {
|
|
2155
|
+
if (alchemy.settings.performance.cache && (!options.cache_time && options.cache_time !== false)) {
|
|
2156
2156
|
options.cache_time = stats.mtime;
|
|
2157
2157
|
}
|
|
2158
2158
|
|
|
@@ -2174,7 +2174,7 @@ Conduit.setTypedMethod([Types.Alchemy.Inode.File, Types.Object.optional()], asyn
|
|
|
2174
2174
|
/**
|
|
2175
2175
|
* Send a buffer to the client
|
|
2176
2176
|
*
|
|
2177
|
-
* @author Jelle De Loecker
|
|
2177
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2178
2178
|
* @since 1.3.0
|
|
2179
2179
|
* @version 1.3.0
|
|
2180
2180
|
*
|
|
@@ -2188,7 +2188,7 @@ Conduit.setTypedMethod([Buffer, Types.Object.optional()], function serveFile(buf
|
|
|
2188
2188
|
/**
|
|
2189
2189
|
* Send a stream to the client
|
|
2190
2190
|
*
|
|
2191
|
-
* @author Jelle De Loecker
|
|
2191
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2192
2192
|
* @since 1.3.0
|
|
2193
2193
|
* @version 1.3.0
|
|
2194
2194
|
*
|
|
@@ -2204,7 +2204,7 @@ Conduit.setTypedMethod([Types.Stream, Types.Object.optional()], function serveFi
|
|
|
2204
2204
|
is_text = true;
|
|
2205
2205
|
}
|
|
2206
2206
|
|
|
2207
|
-
if (alchemy.settings.cache === false) {
|
|
2207
|
+
if (alchemy.settings.performance.cache === false) {
|
|
2208
2208
|
options.cache_time = null;
|
|
2209
2209
|
}
|
|
2210
2210
|
|
|
@@ -2212,11 +2212,11 @@ Conduit.setTypedMethod([Types.Stream, Types.Object.optional()], function serveFi
|
|
|
2212
2212
|
options.compress = is_text;
|
|
2213
2213
|
}
|
|
2214
2214
|
|
|
2215
|
-
if (options.compress && (alchemy.settings.
|
|
2215
|
+
if (options.compress && (alchemy.settings.network.use_compression === false || !this.accepts('gzip'))) {
|
|
2216
2216
|
options.compress = false;
|
|
2217
2217
|
}
|
|
2218
2218
|
|
|
2219
|
-
if (options.cache_time && !alchemy.settings.cache) {
|
|
2219
|
+
if (options.cache_time && !alchemy.settings.performance.cache) {
|
|
2220
2220
|
options.cache_time = false;
|
|
2221
2221
|
}
|
|
2222
2222
|
|
|
@@ -2230,7 +2230,7 @@ Conduit.setTypedMethod([Types.Stream, Types.Object.optional()], function serveFi
|
|
|
2230
2230
|
/**
|
|
2231
2231
|
* Send a stream to the client
|
|
2232
2232
|
*
|
|
2233
|
-
* @author Jelle De Loecker
|
|
2233
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2234
2234
|
* @since 1.3.0
|
|
2235
2235
|
* @version 1.3.14
|
|
2236
2236
|
*
|
|
@@ -2357,19 +2357,19 @@ Conduit.setMethod(function _sendStream(stream, options) {
|
|
|
2357
2357
|
/**
|
|
2358
2358
|
* Create a session
|
|
2359
2359
|
*
|
|
2360
|
-
* @author Jelle De Loecker
|
|
2360
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2361
2361
|
* @since 0.2.0
|
|
2362
|
-
* @version 1.
|
|
2362
|
+
* @version 1.4.0
|
|
2363
2363
|
*
|
|
2364
|
-
* @param {
|
|
2364
|
+
* @param {boolean} create Create a session if none exist
|
|
2365
2365
|
*
|
|
2366
2366
|
* @return {UserSession}
|
|
2367
2367
|
*/
|
|
2368
2368
|
Conduit.setMethod(function getSession(allow_create = true) {
|
|
2369
2369
|
|
|
2370
2370
|
// Only do this once per request
|
|
2371
|
-
if (this.
|
|
2372
|
-
return this.
|
|
2371
|
+
if (this.session_instance != null) {
|
|
2372
|
+
return this.session_instance;
|
|
2373
2373
|
}
|
|
2374
2374
|
|
|
2375
2375
|
let cookie_name = this.session_cookie_name,
|
|
@@ -2395,7 +2395,7 @@ Conduit.setMethod(function getSession(allow_create = true) {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
|
|
2397
2397
|
if (session) {
|
|
2398
|
-
this.
|
|
2398
|
+
this.session_instance = session;
|
|
2399
2399
|
session.request_count++;
|
|
2400
2400
|
} else {
|
|
2401
2401
|
return false;
|
|
@@ -2407,11 +2407,11 @@ Conduit.setMethod(function getSession(allow_create = true) {
|
|
|
2407
2407
|
/**
|
|
2408
2408
|
* Create a controller of the given type and attach this conduit
|
|
2409
2409
|
*
|
|
2410
|
-
* @author Jelle De Loecker
|
|
2410
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2411
2411
|
* @since 1.3.16
|
|
2412
2412
|
* @version 1.3.16
|
|
2413
2413
|
*
|
|
2414
|
-
* @param {
|
|
2414
|
+
* @param {string} controller_name
|
|
2415
2415
|
*
|
|
2416
2416
|
* @return {Controller}
|
|
2417
2417
|
*/
|
|
@@ -2435,19 +2435,21 @@ Conduit.setMethod(function getController(controller_name) {
|
|
|
2435
2435
|
/**
|
|
2436
2436
|
* Register live data bindings via websockets
|
|
2437
2437
|
*
|
|
2438
|
-
* @author Jelle De Loecker
|
|
2438
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2439
2439
|
* @since 0.2.0
|
|
2440
|
-
* @version
|
|
2440
|
+
* @version 1.4.0
|
|
2441
2441
|
*/
|
|
2442
2442
|
Conduit.setMethod(function registerBindings(arr) {
|
|
2443
2443
|
|
|
2444
|
-
|
|
2444
|
+
const websockets = alchemy.settings.network.use_websockets;
|
|
2445
2445
|
|
|
2446
2446
|
// Don't do anything is websockets aren't enabled
|
|
2447
|
-
if (!
|
|
2447
|
+
if (!websockets || websockets == 'never') {
|
|
2448
2448
|
return;
|
|
2449
2449
|
}
|
|
2450
2450
|
|
|
2451
|
+
let data_ids;
|
|
2452
|
+
|
|
2451
2453
|
if (arr) {
|
|
2452
2454
|
data_ids = arr;
|
|
2453
2455
|
} else {
|
|
@@ -2464,42 +2466,42 @@ Conduit.setMethod(function registerBindings(arr) {
|
|
|
2464
2466
|
/**
|
|
2465
2467
|
* Get a a value from the session object
|
|
2466
2468
|
*
|
|
2467
|
-
* @author Jelle De Loecker
|
|
2469
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2468
2470
|
* @since 0.2.0
|
|
2469
|
-
* @version
|
|
2471
|
+
* @version 1.4.0
|
|
2470
2472
|
*
|
|
2471
|
-
* @param {
|
|
2473
|
+
* @param {string} name
|
|
2472
2474
|
* @param {Mixed} value
|
|
2473
2475
|
*
|
|
2474
2476
|
* @return {Mixed}
|
|
2475
2477
|
*/
|
|
2476
2478
|
Conduit.setMethod(function session(name, value) {
|
|
2477
2479
|
|
|
2478
|
-
this.getSession();
|
|
2480
|
+
const session = this.getSession();
|
|
2479
2481
|
|
|
2480
2482
|
if (arguments.length === 0) {
|
|
2481
|
-
return
|
|
2483
|
+
return session;
|
|
2482
2484
|
}
|
|
2483
2485
|
|
|
2484
2486
|
if (arguments.length === 1) {
|
|
2485
|
-
return
|
|
2487
|
+
return session.get(name);
|
|
2486
2488
|
}
|
|
2487
2489
|
|
|
2488
|
-
|
|
2490
|
+
session.set(name, value);
|
|
2489
2491
|
});
|
|
2490
2492
|
|
|
2491
2493
|
/**
|
|
2492
2494
|
* Get a route URL
|
|
2493
2495
|
*
|
|
2494
|
-
* @author Jelle De Loecker
|
|
2496
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2495
2497
|
* @since 1.2.7
|
|
2496
2498
|
* @version 1.2.7
|
|
2497
2499
|
*
|
|
2498
|
-
* @param {
|
|
2500
|
+
* @param {string} name
|
|
2499
2501
|
* @param {Object} parameters
|
|
2500
2502
|
* @param {Object} options
|
|
2501
2503
|
*
|
|
2502
|
-
* @return {
|
|
2504
|
+
* @return {string}
|
|
2503
2505
|
*/
|
|
2504
2506
|
Conduit.setMethod(function routeUrl(name, parameters, options) {
|
|
2505
2507
|
return this.renderer.helpers.Router.routeUrl(name, parameters, options);
|
|
@@ -2508,11 +2510,11 @@ Conduit.setMethod(function routeUrl(name, parameters, options) {
|
|
|
2508
2510
|
/**
|
|
2509
2511
|
* Get a parameter from the route
|
|
2510
2512
|
*
|
|
2511
|
-
* @author Jelle De Loecker
|
|
2513
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2512
2514
|
* @since 0.2.0
|
|
2513
2515
|
* @version 0.2.0
|
|
2514
2516
|
*
|
|
2515
|
-
* @param {
|
|
2517
|
+
* @param {string} name
|
|
2516
2518
|
*/
|
|
2517
2519
|
Conduit.setMethod(function routeParam(name) {
|
|
2518
2520
|
return this.params[name];
|
|
@@ -2521,7 +2523,7 @@ Conduit.setMethod(function routeParam(name) {
|
|
|
2521
2523
|
/**
|
|
2522
2524
|
* Set route parameters
|
|
2523
2525
|
*
|
|
2524
|
-
* @author Jelle De Loecker
|
|
2526
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2525
2527
|
* @since 1.3.0
|
|
2526
2528
|
* @version 1.3.0
|
|
2527
2529
|
*/
|
|
@@ -2539,18 +2541,18 @@ Conduit.setMethod(function setRouteParameters(data) {
|
|
|
2539
2541
|
/**
|
|
2540
2542
|
* Get/set a cookie
|
|
2541
2543
|
*
|
|
2542
|
-
* @author Jelle De Loecker
|
|
2544
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2543
2545
|
* @since 0.2.0
|
|
2544
|
-
* @version 1.
|
|
2546
|
+
* @version 1.4.0
|
|
2545
2547
|
*
|
|
2546
|
-
* @param {
|
|
2548
|
+
* @param {string} name
|
|
2547
2549
|
* @param {Mixed} value
|
|
2548
2550
|
* @param {Object} options
|
|
2549
2551
|
*/
|
|
2550
2552
|
Conduit.setMethod(function cookie(name, value, options) {
|
|
2551
2553
|
|
|
2552
2554
|
// Return if cookies are disabled
|
|
2553
|
-
if (!alchemy.settings.cookies) {
|
|
2555
|
+
if (!alchemy.settings.frontend.cookies.enabled) {
|
|
2554
2556
|
return;
|
|
2555
2557
|
}
|
|
2556
2558
|
|
|
@@ -2580,8 +2582,8 @@ Conduit.setMethod(function cookie(name, value, options) {
|
|
|
2580
2582
|
this.new_cookies[name] = value;
|
|
2581
2583
|
|
|
2582
2584
|
// If there is no domain set, see if it is required
|
|
2583
|
-
if ((options.domain === true || options.domain == null) && alchemy.settings.
|
|
2584
|
-
let wanted_domain = alchemy.settings.
|
|
2585
|
+
if ((options.domain === true || options.domain == null) && alchemy.settings.frontend.cookies.domain && this.url) {
|
|
2586
|
+
let wanted_domain = alchemy.settings.frontend.cookies.domain,
|
|
2585
2587
|
actual_domain = this.url.hostname;
|
|
2586
2588
|
|
|
2587
2589
|
if (wanted_domain != actual_domain) {
|
|
@@ -2615,11 +2617,11 @@ Conduit.setMethod(function cookie(name, value, options) {
|
|
|
2615
2617
|
/**
|
|
2616
2618
|
* Set a response header
|
|
2617
2619
|
*
|
|
2618
|
-
* @author Jelle De Loecker
|
|
2620
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2619
2621
|
* @since 0.2.0
|
|
2620
2622
|
* @version 1.3.0
|
|
2621
2623
|
*
|
|
2622
|
-
* @param {
|
|
2624
|
+
* @param {string} name
|
|
2623
2625
|
* @param {Mixed} value
|
|
2624
2626
|
*/
|
|
2625
2627
|
Conduit.setMethod(function setHeader(name, value) {
|
|
@@ -2638,11 +2640,11 @@ Conduit.setMethod(function setHeader(name, value) {
|
|
|
2638
2640
|
/**
|
|
2639
2641
|
* Get a response header
|
|
2640
2642
|
*
|
|
2641
|
-
* @author Jelle De Loecker
|
|
2643
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2642
2644
|
* @since 1.1.0
|
|
2643
2645
|
* @version 1.1.0
|
|
2644
2646
|
*
|
|
2645
|
-
* @param {
|
|
2647
|
+
* @param {string} name
|
|
2646
2648
|
*/
|
|
2647
2649
|
Conduit.setMethod(function getHeader(name) {
|
|
2648
2650
|
|
|
@@ -2658,11 +2660,11 @@ Conduit.setMethod(function getHeader(name) {
|
|
|
2658
2660
|
/**
|
|
2659
2661
|
* Update data to this scene only
|
|
2660
2662
|
*
|
|
2661
|
-
* @author Jelle De Loecker
|
|
2663
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2662
2664
|
* @since 0.2.0
|
|
2663
2665
|
* @version 0.4.0
|
|
2664
2666
|
*
|
|
2665
|
-
* @param {
|
|
2667
|
+
* @param {string} name
|
|
2666
2668
|
* @param {Mixed} value
|
|
2667
2669
|
*/
|
|
2668
2670
|
Conduit.setMethod(function update(name, value) {
|
|
@@ -2677,7 +2679,7 @@ Conduit.setMethod(function update(name, value) {
|
|
|
2677
2679
|
/**
|
|
2678
2680
|
* Push a flash message to the client
|
|
2679
2681
|
*
|
|
2680
|
-
* @author Jelle De Loecker
|
|
2682
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2681
2683
|
* @since 0.2.0
|
|
2682
2684
|
* @version 0.2.0
|
|
2683
2685
|
*/
|
|
@@ -2706,11 +2708,11 @@ Conduit.setMethod(function flash(message, options) {
|
|
|
2706
2708
|
/**
|
|
2707
2709
|
* Set a theme to use
|
|
2708
2710
|
*
|
|
2709
|
-
* @author Jelle De Loecker
|
|
2711
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2710
2712
|
* @since 0.2.0
|
|
2711
2713
|
* @version 0.2.0
|
|
2712
2714
|
*
|
|
2713
|
-
* @param {
|
|
2715
|
+
* @param {string} name
|
|
2714
2716
|
*/
|
|
2715
2717
|
Conduit.setMethod(function setTheme(name) {
|
|
2716
2718
|
this.theme = name;
|
|
@@ -2720,13 +2722,13 @@ Conduit.setMethod(function setTheme(name) {
|
|
|
2720
2722
|
/**
|
|
2721
2723
|
* Does this user support a certain feature?
|
|
2722
2724
|
*
|
|
2723
|
-
* @author Jelle De Loecker
|
|
2725
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2724
2726
|
* @since 1.0.4
|
|
2725
2727
|
* @version 1.0.4
|
|
2726
2728
|
*
|
|
2727
|
-
* @param {
|
|
2729
|
+
* @param {string} feature
|
|
2728
2730
|
*
|
|
2729
|
-
* @return {
|
|
2731
|
+
* @return {boolean}
|
|
2730
2732
|
*/
|
|
2731
2733
|
Conduit.setMethod(function supports(feature) {
|
|
2732
2734
|
|
|
@@ -2764,15 +2766,15 @@ Conduit.setMethod(function supports(feature) {
|
|
|
2764
2766
|
* This is mainly so we can prevent Server-Side-Renders from happening
|
|
2765
2767
|
* when the system is already overloaded.
|
|
2766
2768
|
*
|
|
2767
|
-
* @author Jelle De Loecker
|
|
2769
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2768
2770
|
* @since 1.3.1
|
|
2769
2771
|
* @version 1.3.1
|
|
2770
2772
|
*
|
|
2771
|
-
* @return {
|
|
2773
|
+
* @return {boolean}
|
|
2772
2774
|
*/
|
|
2773
2775
|
Conduit.setMethod(function shouldBePostponed() {
|
|
2774
2776
|
|
|
2775
|
-
if (!alchemy.settings.postpone_requests_on_overload) {
|
|
2777
|
+
if (!alchemy.settings.performance.postpone_requests_on_overload) {
|
|
2776
2778
|
return false;
|
|
2777
2779
|
}
|
|
2778
2780
|
|
|
@@ -2827,11 +2829,11 @@ Conduit.setMethod(function shouldBePostponed() {
|
|
|
2827
2829
|
/**
|
|
2828
2830
|
* Broadcast data to every connected user
|
|
2829
2831
|
*
|
|
2830
|
-
* @author Jelle De Loecker
|
|
2832
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2831
2833
|
* @since 0.3.0
|
|
2832
2834
|
* @version 1.3.16
|
|
2833
2835
|
*
|
|
2834
|
-
* @param {
|
|
2836
|
+
* @param {string} type
|
|
2835
2837
|
* @param {Object} data
|
|
2836
2838
|
*/
|
|
2837
2839
|
Alchemy.setMethod(function broadcast(type, data) {
|
|
@@ -2845,7 +2847,7 @@ Alchemy.setMethod(function broadcast(type, data) {
|
|
|
2845
2847
|
return;
|
|
2846
2848
|
}
|
|
2847
2849
|
|
|
2848
|
-
if (alchemy.settings.debug) {
|
|
2850
|
+
if (alchemy.settings.debugging.debug) {
|
|
2849
2851
|
log.debug('Broadcasting', type, {data, scene: socket_conduit});
|
|
2850
2852
|
}
|
|
2851
2853
|
|
|
@@ -2857,9 +2859,9 @@ Alchemy.setMethod(function broadcast(type, data) {
|
|
|
2857
2859
|
/**
|
|
2858
2860
|
* Get the magic mimetype function
|
|
2859
2861
|
*
|
|
2860
|
-
* @author Jelle De Loecker
|
|
2862
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2861
2863
|
* @since 0.3.0
|
|
2862
|
-
* @version
|
|
2864
|
+
* @version 1.4.0
|
|
2863
2865
|
*/
|
|
2864
2866
|
function getMagic() {
|
|
2865
2867
|
|
|
@@ -2870,7 +2872,7 @@ function getMagic() {
|
|
|
2870
2872
|
}
|
|
2871
2873
|
|
|
2872
2874
|
// Get mmmagic module
|
|
2873
|
-
mmmagic = alchemy.use('mmmagic')
|
|
2875
|
+
mmmagic = alchemy.use('@picturae/mmmagic')
|
|
2874
2876
|
|
|
2875
2877
|
if (mmmagic) {
|
|
2876
2878
|
magic = new mmmagic.Magic(mmmagic.MAGIC_MIME_TYPE);
|