alchemymvc 1.2.5 → 1.2.7
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 +0 -0
- package/README.md +0 -0
- package/lib/app/assets/scripts/.gitkeep +0 -0
- package/lib/app/assets/stylesheets/alchemy-info.less +0 -0
- package/lib/app/behaviour/publishable_behaviour.js +0 -0
- package/lib/app/behaviour/revision_behaviour.js +0 -0
- package/lib/app/behaviour/sluggable_behaviour.js +0 -0
- package/lib/app/component/.gitkeep +0 -0
- package/lib/app/conduit/electron_conduit.js +0 -0
- package/lib/app/conduit/http_conduit.js +173 -173
- package/lib/app/conduit/loopback_conduit.js +2 -3
- package/lib/app/conduit/socket_conduit.js +620 -620
- package/lib/app/controller/alchemy_info_controller.js +0 -0
- package/lib/app/datasource/mongo_datasource.js +0 -0
- package/lib/app/element/time_ago.js +2 -4
- package/lib/app/helper/alchemy_helper.js +22 -11
- package/lib/app/helper/client_collection.js +0 -0
- package/lib/app/helper/pagination_helper.js +0 -0
- package/lib/app/helper/router_helper.js +20 -7
- package/lib/app/helper/socket_helper.js +613 -613
- package/lib/app/helper_component/paginate_component.js +0 -0
- package/lib/app/helper_controller/component.js +0 -0
- package/lib/app/helper_controller/conduit.js +0 -0
- package/lib/app/helper_controller/controller.js +0 -0
- package/lib/app/helper_datasource/00-nosql_datasource.js +0 -0
- package/lib/app/helper_datasource/05-fallback_datasource.js +0 -0
- package/lib/app/helper_datasource/idb_datasource.js +0 -0
- package/lib/app/helper_datasource/indexed_db.js +0 -0
- package/lib/app/helper_field/00-objectid_field.js +0 -0
- package/lib/app/helper_field/06-text_field.js +0 -0
- package/lib/app/helper_field/10-number_field.js +0 -0
- package/lib/app/helper_field/boolean_field.js +0 -0
- package/lib/app/helper_field/date_field.js +0 -0
- package/lib/app/helper_field/datetime_field.js +0 -0
- package/lib/app/helper_field/enum_field.js +0 -0
- package/lib/app/helper_field/geopoint_field.js +0 -0
- package/lib/app/helper_field/habtm_field.js +0 -0
- package/lib/app/helper_field/hasoneparent_field.js +0 -0
- package/lib/app/helper_field/html_field.js +0 -0
- package/lib/app/helper_field/integer_field.js +0 -0
- package/lib/app/helper_field/object_field.js +0 -0
- package/lib/app/helper_field/regexp_field.js +0 -0
- package/lib/app/helper_field/schema_field.js +23 -2
- package/lib/app/helper_field/time_field.js +0 -0
- package/lib/app/helper_field/url_field.js +0 -0
- package/lib/app/helper_model/criteria.js +21 -3
- package/lib/app/helper_model/db_query.js +0 -0
- package/lib/app/helper_model/document_list.js +0 -0
- package/lib/app/helper_model/field_config.js +2 -2
- package/lib/app/helper_model/model.js +72 -5
- package/lib/app/model/alchemy_task_model.js +0 -0
- package/lib/app/routes.js +0 -0
- package/lib/app/view/alchemy/info.ejs +0 -0
- package/lib/app/view/error/unknown.ejs +0 -0
- package/lib/app/view/paginate/navlist.ejs +0 -0
- package/lib/bootstrap.js +0 -0
- package/lib/class/behaviour.js +0 -0
- package/lib/class/component.js +0 -0
- package/lib/class/conduit.js +2572 -2552
- package/lib/class/controller.js +4 -1
- package/lib/class/document.js +18 -4
- package/lib/class/document_list.js +0 -0
- package/lib/class/helper.js +0 -0
- package/lib/class/inode.js +0 -0
- package/lib/class/inode_dir.js +0 -0
- package/lib/class/inode_file.js +136 -112
- package/lib/class/inode_list.js +0 -0
- package/lib/class/model.js +1740 -1769
- package/lib/class/path_definition.js +0 -0
- package/lib/class/route.js +0 -0
- package/lib/class/router.js +6 -3
- package/lib/class/session.js +0 -0
- package/lib/class/task.js +0 -0
- package/lib/core/base.js +41 -18
- package/lib/core/client_alchemy.js +48 -2
- package/lib/core/discovery.js +0 -0
- package/lib/core/middleware.js +6 -4
- package/lib/core/routing.js +0 -0
- package/lib/core/socket.js +159 -159
- package/lib/init/alchemy.js +1848 -1823
- package/lib/init/constants.js +0 -0
- package/lib/init/functions.js +8 -4
- package/lib/init/load_functions.js +0 -0
- package/lib/init/requirements.js +101 -101
- package/lib/stages.js +10 -2
- package/package.json +74 -74
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Http Conduit Class
|
|
3
|
-
*
|
|
4
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
5
|
-
* @since 0.2.0
|
|
6
|
-
* @version 1.1.3
|
|
7
|
-
*
|
|
8
|
-
* @param {IncomingMessage} req
|
|
9
|
-
* @param {ServerResponse} res
|
|
10
|
-
* @param {Router} router
|
|
11
|
-
*/
|
|
12
|
-
var HttpConduit = Function.inherits('Alchemy.Conduit.Conduit', function Http(req, res, router) {
|
|
13
|
-
|
|
14
|
-
// Initialize basic conduit values
|
|
15
|
-
Http.super.call(this);
|
|
16
|
-
|
|
17
|
-
this.initHttp(req, res, router);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Has the client aborted the request?
|
|
22
|
-
*
|
|
23
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
24
|
-
* @since 1.1.0
|
|
25
|
-
* @version 1.1.0
|
|
26
|
-
*
|
|
27
|
-
* @type {Boolean}
|
|
28
|
-
*/
|
|
29
|
-
HttpConduit.setProperty(function aborted() {
|
|
30
|
-
|
|
31
|
-
if (this.request && this.request.aborted != null) {
|
|
32
|
-
return this.request.aborted;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return false;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Return the IP address
|
|
40
|
-
*
|
|
41
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
42
|
-
* @since 0.2.0
|
|
43
|
-
* @version 1.1.0
|
|
44
|
-
*/
|
|
45
|
-
HttpConduit.setProperty(function ip() {
|
|
46
|
-
|
|
47
|
-
var req = this.request;
|
|
48
|
-
|
|
49
|
-
if (!req) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let forwarded_for = req.headers['x-forwarded-for'] || req.headers['x-real-ip'];
|
|
54
|
-
|
|
55
|
-
if (forwarded_for) {
|
|
56
|
-
|
|
57
|
-
// Forwarded for can contain multiple ip addresses,
|
|
58
|
-
// return the first one
|
|
59
|
-
if (forwarded_for.indexOf(',') > -1) {
|
|
60
|
-
forwarded_for = forwarded_for.before(',');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return forwarded_for;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let remote_address;
|
|
67
|
-
|
|
68
|
-
if (req.connection) {
|
|
69
|
-
remote_address = req.connection.remoteAddress;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!remote_address && req.socket) {
|
|
73
|
-
remote_address = req.socket.remoteAddress;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!remote_address && req.connection && req.connection.socket) {
|
|
77
|
-
remote_address = req.connection.socket.remoteAddress;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return remote_address;
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Get a simple fingerprint of the client
|
|
85
|
-
* based on ip, accept-language & user-agent
|
|
86
|
-
*
|
|
87
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
88
|
-
* @since 1.1.0
|
|
89
|
-
* @version 1.1.0
|
|
90
|
-
*
|
|
91
|
-
* @type {String}
|
|
92
|
-
*/
|
|
93
|
-
HttpConduit.enforceProperty(function fingerprint() {
|
|
94
|
-
|
|
95
|
-
let result,
|
|
96
|
-
language = this.headers['accept-language'] || 'all',
|
|
97
|
-
ua = this.headers['user-agent'] || 'unknown',
|
|
98
|
-
ip = this.ip || '';
|
|
99
|
-
|
|
100
|
-
result = Object.checksum(ip + '_' + language + '_' + ua);
|
|
101
|
-
|
|
102
|
-
return result;
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Init
|
|
107
|
-
*
|
|
108
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
109
|
-
* @since 0.3.3
|
|
110
|
-
* @version 1.2.0
|
|
111
|
-
*
|
|
112
|
-
* @param {IncomingMessage} req
|
|
113
|
-
* @param {ServerResponse} res
|
|
114
|
-
* @param {Router} router
|
|
115
|
-
*/
|
|
116
|
-
HttpConduit.setMethod(async function initHttp(req, res, router) {
|
|
117
|
-
|
|
118
|
-
this.setReqRes(req, res);
|
|
119
|
-
|
|
120
|
-
if (router) {
|
|
121
|
-
this.router = router;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// The HTTP status
|
|
125
|
-
this.status = 200;
|
|
126
|
-
|
|
127
|
-
this.debugMark('Parse request');
|
|
128
|
-
|
|
129
|
-
// Parse the request, get the correct routes and such
|
|
130
|
-
await this.parseRequest();
|
|
131
|
-
|
|
132
|
-
if (this.halt_request) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (alchemy.settings.debug || alchemy.settings.environment != 'live') {
|
|
137
|
-
this.setHeader('X-Robots-Tag', 'none');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
this.debugMark(false);
|
|
141
|
-
|
|
142
|
-
// Call the middleware, which will call the handler afterwards
|
|
143
|
-
this.callMiddleware();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Get the original url path
|
|
148
|
-
*
|
|
149
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
150
|
-
* @since 1.1.0
|
|
151
|
-
* @version 1.1.0
|
|
152
|
-
*
|
|
153
|
-
* @type {String}
|
|
154
|
-
*/
|
|
155
|
-
HttpConduit.setProperty(function original_path() {
|
|
156
|
-
return this.original_url.path;
|
|
157
|
-
}, function setPath(value) {
|
|
158
|
-
return this.original_url.path = value;
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Get the original url pathname
|
|
163
|
-
*
|
|
164
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
165
|
-
* @since 1.1.0
|
|
166
|
-
* @version 1.1.0
|
|
167
|
-
*
|
|
168
|
-
* @type {String}
|
|
169
|
-
*/
|
|
170
|
-
HttpConduit.setProperty(function original_pathname() {
|
|
171
|
-
return this.original_url.pathname;
|
|
172
|
-
}, function setPathname(value) {
|
|
173
|
-
return this.original_url.pathname = value;
|
|
1
|
+
/**
|
|
2
|
+
* The Http Conduit Class
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 1.1.3
|
|
7
|
+
*
|
|
8
|
+
* @param {IncomingMessage} req
|
|
9
|
+
* @param {ServerResponse} res
|
|
10
|
+
* @param {Router} router
|
|
11
|
+
*/
|
|
12
|
+
var HttpConduit = Function.inherits('Alchemy.Conduit.Conduit', function Http(req, res, router) {
|
|
13
|
+
|
|
14
|
+
// Initialize basic conduit values
|
|
15
|
+
Http.super.call(this);
|
|
16
|
+
|
|
17
|
+
this.initHttp(req, res, router);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Has the client aborted the request?
|
|
22
|
+
*
|
|
23
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
24
|
+
* @since 1.1.0
|
|
25
|
+
* @version 1.1.0
|
|
26
|
+
*
|
|
27
|
+
* @type {Boolean}
|
|
28
|
+
*/
|
|
29
|
+
HttpConduit.setProperty(function aborted() {
|
|
30
|
+
|
|
31
|
+
if (this.request && this.request.aborted != null) {
|
|
32
|
+
return this.request.aborted;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return false;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Return the IP address
|
|
40
|
+
*
|
|
41
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
42
|
+
* @since 0.2.0
|
|
43
|
+
* @version 1.1.0
|
|
44
|
+
*/
|
|
45
|
+
HttpConduit.setProperty(function ip() {
|
|
46
|
+
|
|
47
|
+
var req = this.request;
|
|
48
|
+
|
|
49
|
+
if (!req) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let forwarded_for = req.headers['x-forwarded-for'] || req.headers['x-real-ip'];
|
|
54
|
+
|
|
55
|
+
if (forwarded_for) {
|
|
56
|
+
|
|
57
|
+
// Forwarded for can contain multiple ip addresses,
|
|
58
|
+
// return the first one
|
|
59
|
+
if (forwarded_for.indexOf(',') > -1) {
|
|
60
|
+
forwarded_for = forwarded_for.before(',');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return forwarded_for;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let remote_address;
|
|
67
|
+
|
|
68
|
+
if (req.connection) {
|
|
69
|
+
remote_address = req.connection.remoteAddress;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!remote_address && req.socket) {
|
|
73
|
+
remote_address = req.socket.remoteAddress;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!remote_address && req.connection && req.connection.socket) {
|
|
77
|
+
remote_address = req.connection.socket.remoteAddress;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return remote_address;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get a simple fingerprint of the client
|
|
85
|
+
* based on ip, accept-language & user-agent
|
|
86
|
+
*
|
|
87
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
88
|
+
* @since 1.1.0
|
|
89
|
+
* @version 1.1.0
|
|
90
|
+
*
|
|
91
|
+
* @type {String}
|
|
92
|
+
*/
|
|
93
|
+
HttpConduit.enforceProperty(function fingerprint() {
|
|
94
|
+
|
|
95
|
+
let result,
|
|
96
|
+
language = this.headers['accept-language'] || 'all',
|
|
97
|
+
ua = this.headers['user-agent'] || 'unknown',
|
|
98
|
+
ip = this.ip || '';
|
|
99
|
+
|
|
100
|
+
result = Object.checksum(ip + '_' + language + '_' + ua);
|
|
101
|
+
|
|
102
|
+
return result;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Init
|
|
107
|
+
*
|
|
108
|
+
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
109
|
+
* @since 0.3.3
|
|
110
|
+
* @version 1.2.0
|
|
111
|
+
*
|
|
112
|
+
* @param {IncomingMessage} req
|
|
113
|
+
* @param {ServerResponse} res
|
|
114
|
+
* @param {Router} router
|
|
115
|
+
*/
|
|
116
|
+
HttpConduit.setMethod(async function initHttp(req, res, router) {
|
|
117
|
+
|
|
118
|
+
this.setReqRes(req, res);
|
|
119
|
+
|
|
120
|
+
if (router) {
|
|
121
|
+
this.router = router;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// The HTTP status
|
|
125
|
+
this.status = 200;
|
|
126
|
+
|
|
127
|
+
this.debugMark('Parse request');
|
|
128
|
+
|
|
129
|
+
// Parse the request, get the correct routes and such
|
|
130
|
+
await this.parseRequest();
|
|
131
|
+
|
|
132
|
+
if (this.halt_request) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (alchemy.settings.debug || alchemy.settings.environment != 'live') {
|
|
137
|
+
this.setHeader('X-Robots-Tag', 'none');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.debugMark(false);
|
|
141
|
+
|
|
142
|
+
// Call the middleware, which will call the handler afterwards
|
|
143
|
+
this.callMiddleware();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Get the original url path
|
|
148
|
+
*
|
|
149
|
+
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
150
|
+
* @since 1.1.0
|
|
151
|
+
* @version 1.1.0
|
|
152
|
+
*
|
|
153
|
+
* @type {String}
|
|
154
|
+
*/
|
|
155
|
+
HttpConduit.setProperty(function original_path() {
|
|
156
|
+
return this.original_url.path;
|
|
157
|
+
}, function setPath(value) {
|
|
158
|
+
return this.original_url.path = value;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get the original url pathname
|
|
163
|
+
*
|
|
164
|
+
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
165
|
+
* @since 1.1.0
|
|
166
|
+
* @version 1.1.0
|
|
167
|
+
*
|
|
168
|
+
* @type {String}
|
|
169
|
+
*/
|
|
170
|
+
HttpConduit.setProperty(function original_pathname() {
|
|
171
|
+
return this.original_url.pathname;
|
|
172
|
+
}, function setPathname(value) {
|
|
173
|
+
return this.original_url.pathname = value;
|
|
174
174
|
});
|
|
@@ -78,7 +78,7 @@ LoopConduit.setMethod(function copyParentProperties(conduit) {
|
|
|
78
78
|
*
|
|
79
79
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
80
80
|
* @since 1.1.3
|
|
81
|
-
* @version 1.
|
|
81
|
+
* @version 1.2.7
|
|
82
82
|
*
|
|
83
83
|
* @param {Object} options
|
|
84
84
|
* @param {Function} callback
|
|
@@ -136,8 +136,7 @@ LoopConduit.setMethod(function setOptions(options, callback) {
|
|
|
136
136
|
|
|
137
137
|
// @WARNING: It's best to just generate the URL
|
|
138
138
|
// and let it parse all the information that way
|
|
139
|
-
options.href =
|
|
140
|
-
// @TODO: alchemy.routeUrl will ignore the `keep_get_parameters` option
|
|
139
|
+
options.href = this.routeUrl(options.name, options.params, {extra_get_parameters: false});
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
if (!this.method) {
|