alchemymvc 1.1.7 → 1.2.0
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/lib/app/behaviour/sluggable_behaviour.js +2 -4
- package/lib/app/conduit/http_conduit.js +173 -192
- package/lib/app/conduit/loopback_conduit.js +0 -0
- package/lib/app/conduit/socket_conduit.js +620 -620
- package/lib/app/datasource/mongo_datasource.js +75 -10
- package/lib/app/element/time_ago.js +0 -0
- package/lib/app/helper/socket_helper.js +613 -613
- package/lib/app/helper_datasource/00-nosql_datasource.js +73 -19
- package/lib/app/helper_datasource/remote_datasource.js +0 -0
- package/lib/app/helper_field/05-string_field.js +0 -0
- package/lib/app/helper_field/schema_field.js +7 -2
- package/lib/app/helper_model/criteria.js +76 -18
- package/lib/app/helper_model/field_config.js +24 -5
- package/lib/app/helper_model/model.js +65 -7
- package/lib/app/model/alchemy_migration_model.js +33 -0
- package/lib/bootstrap.js +9 -0
- package/lib/class/conduit.js +2474 -2412
- package/lib/class/datasource.js +8 -8
- package/lib/class/field.js +7 -1
- package/lib/class/inode.js +62 -0
- package/lib/class/inode_dir.js +115 -0
- package/lib/class/inode_file.js +112 -111
- package/lib/class/migration.js +138 -0
- package/lib/class/model.js +1765 -1772
- package/lib/class/reciprocal.js +8 -2
- package/lib/class/router.js +0 -0
- package/lib/class/schema.js +14 -12
- package/lib/core/base.js +37 -10
- package/lib/core/client_base.js +1 -9
- package/lib/core/middleware.js +4 -8
- package/lib/core/socket.js +159 -159
- package/lib/init/alchemy.js +1779 -1779
- package/lib/init/devwatch.js +1 -1
- package/lib/init/functions.js +2 -56
- package/lib/init/load_functions.js +8 -2
- package/lib/init/requirements.js +101 -96
- package/lib/stages.js +12 -0
- package/package.json +74 -76
- package/CHANGELOG.md +0 -445
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var slug = alchemy.use('mollusc');
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* The Sluggable Behaviour class
|
|
5
3
|
*
|
|
@@ -293,7 +291,7 @@ Sluggable.setMethod(function createSlug(record, new_value, callback) {
|
|
|
293
291
|
*
|
|
294
292
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
295
293
|
* @since 0.1.0
|
|
296
|
-
* @version 1.1.
|
|
294
|
+
* @version 1.1.8
|
|
297
295
|
*
|
|
298
296
|
* @param {String} title
|
|
299
297
|
* @param {String} path
|
|
@@ -336,7 +334,7 @@ Sluggable.setMethod(function generateSlug(title, key, record, callback) {
|
|
|
336
334
|
return callback();
|
|
337
335
|
}
|
|
338
336
|
|
|
339
|
-
baseSlug = slug(
|
|
337
|
+
baseSlug = title.slug(that.replacement || '-').toLowerCase();
|
|
340
338
|
current = baseSlug;
|
|
341
339
|
model = Model.get(this.model.name);
|
|
342
340
|
count = 1;
|
|
@@ -1,193 +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.
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* @
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
HttpConduit.setProperty(function original_path() {
|
|
175
|
-
return this.original_url.path;
|
|
176
|
-
}, function setPath(value) {
|
|
177
|
-
return this.original_url.path = value;
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Get the original url pathname
|
|
182
|
-
*
|
|
183
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
184
|
-
* @since 1.1.0
|
|
185
|
-
* @version 1.1.0
|
|
186
|
-
*
|
|
187
|
-
* @type {String}
|
|
188
|
-
*/
|
|
189
|
-
HttpConduit.setProperty(function original_pathname() {
|
|
190
|
-
return this.original_url.pathname;
|
|
191
|
-
}, function setPathname(value) {
|
|
192
|
-
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;
|
|
193
174
|
});
|
|
File without changes
|