alchemymvc 1.3.4 → 1.3.6
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 +5 -62
- package/lib/app/assets/stylesheets/alchemy-info.less +23 -5
- package/lib/app/controller/alchemy_info_controller.js +2 -2
- package/lib/app/datasource/mongo_datasource.js +21 -1
- package/lib/app/helper/backed_map.js +2 -249
- package/lib/app/helper/enum_values.js +32 -10
- package/lib/app/helper/router_helper.js +13 -12
- package/lib/app/helper/socket_helper.js +16 -8
- package/lib/app/helper_field/big_int_field.js +116 -0
- package/lib/app/view/alchemy/info.hwk +19 -3
- package/lib/class/conduit.js +18 -24
- package/lib/class/field.js +10 -7
- package/lib/class/path_param_definition.js +16 -3
- package/lib/class/sitemap.js +12 -5
- package/lib/core/socket.js +29 -18
- package/lib/stages.js +10 -9
- package/package.json +8 -7
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2013-
|
|
1
|
+
Copyright (c) 2013-2023 Jelle De Loecker <jelle@elevenways.be>
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<img src="https://protoblast.
|
|
2
|
+
<img src="https://protoblast.elevenways.be/media/static/alchemy-small.png" width=30 alt="Alchemy logo"/>
|
|
3
3
|
<b>Alchemy</b>
|
|
4
4
|
</h1>
|
|
5
5
|
<div align="center">
|
|
@@ -8,24 +8,14 @@
|
|
|
8
8
|
<img src="https://travis-ci.org/11ways/alchemy.svg?branch=master" alt="Mac/Linux Build Status" />
|
|
9
9
|
</a>
|
|
10
10
|
|
|
11
|
-
<!-- CI - AppVeyor -->
|
|
12
|
-
<a href="https://ci.appveyor.com/project/skerit/alchemy">
|
|
13
|
-
<img src="https://img.shields.io/appveyor/ci/skerit/alchemy/master.svg?label=Windows" alt="Windows Build status" />
|
|
14
|
-
</a>
|
|
15
|
-
|
|
16
11
|
<!-- Coverage - Codecov -->
|
|
17
12
|
<a href="https://codecov.io/gh/11ways/alchemy">
|
|
18
13
|
<img src="https://img.shields.io/codecov/c/github/11ways/alchemy/master.svg" alt="Codecov Coverage report" />
|
|
19
14
|
</a>
|
|
20
15
|
|
|
21
16
|
<!-- DM - Snyk -->
|
|
22
|
-
<a href="https://snyk.io/test/github/
|
|
23
|
-
<img src="https://snyk.io/test/github/
|
|
24
|
-
</a>
|
|
25
|
-
|
|
26
|
-
<!-- DM - David -->
|
|
27
|
-
<a href="https://david-dm.org/skerit/alchemy">
|
|
28
|
-
<img src="https://david-dm.org/skerit/alchemy/status.svg" alt="Dependency Status" />
|
|
17
|
+
<a href="https://snyk.io/test/github/11ways/alchemy?targetFile=package.json">
|
|
18
|
+
<img src="https://snyk.io/test/github/11ways/alchemy/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" />
|
|
29
19
|
</a>
|
|
30
20
|
</div>
|
|
31
21
|
|
|
@@ -69,55 +59,8 @@ Just installing the npm package can be done like this:
|
|
|
69
59
|
|
|
70
60
|
# Quick start guide
|
|
71
61
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
You can find extensive documentation on the library here: [https://protoblast.develry.be](https://protoblast.develry.be)
|
|
75
|
-
|
|
76
|
-
## File structure
|
|
77
|
-
|
|
78
|
-
All of your project code should go into an `app` directory.
|
|
79
|
-
That directory can contain many subdirectories. Most of those files are auto-required on boot.
|
|
80
|
-
|
|
81
|
-
The directories (and some of their basic files) are:
|
|
82
|
-
|
|
83
|
-
* **assets**:
|
|
84
|
-
* **images**: Static images
|
|
85
|
-
* **scripts**: Client-side only javascript files. Accessible through `/scripts/` url.
|
|
86
|
-
* **stylesheets**: SCSS and LESS stylesheet files. Accessible through `/stylesheets/` url.
|
|
87
|
-
* **config**:
|
|
88
|
-
* **bootstrap.js**: Place where all plugins should be loaded
|
|
89
|
-
* **default.js**: Default configuration
|
|
90
|
-
* **local.js**: Configuration file that overrides all others. Is required for the `environment` definition. Should not be checked into git.
|
|
91
|
-
* **prefixes.js**: Place to define which prefixes (locales/languages) are used on the site
|
|
92
|
-
* **routes.js**: Routes should be defined here
|
|
93
|
-
* **controller**:
|
|
94
|
-
* **app_controller.js**: Basic controller instance your other controllers should inherit from
|
|
95
|
-
* **element**:
|
|
96
|
-
* **app_element.js**: Basic custom element your other custom elements should inherit from.
|
|
97
|
-
* **helper**:
|
|
98
|
-
* **app_helper.js**: Basic helper your other helpers should inherit from.
|
|
99
|
-
* **lib**:
|
|
100
|
-
* Put classes here that are only needed on the server.
|
|
101
|
-
* **model**:
|
|
102
|
-
* **app_model.js**: Basic model your other models should inherit from.
|
|
103
|
-
* **public**:
|
|
104
|
-
* Files put in here will be publicly available under the `/public/` url.
|
|
105
|
-
* **root**:
|
|
106
|
-
* Files put in here will be publicly available under the root url (So `/`)
|
|
107
|
-
* **view**:
|
|
108
|
-
* Template files go in here, preferably with a `.hwk` extension, though regular `.ejs` files also work.
|
|
109
|
-
|
|
110
|
-
## Code convention
|
|
111
|
-
|
|
112
|
-
### Naming:
|
|
113
|
-
|
|
114
|
-
* Class names are written using upper camel case: **MyClassName**
|
|
115
|
-
* Method names are written using lower camel case: **myMethodName**
|
|
116
|
-
* Property names and variables are written using snake case: **my_property_name**
|
|
117
|
-
|
|
118
|
-
### Whitespaces
|
|
119
|
-
|
|
120
|
-
* Tabs are used for indentations, spaces are used for positioning.
|
|
62
|
+
You can find all the documentation on [https://alchemy.elevenways.be](https://alchemy.elevenways.be)
|
|
63
|
+
|
|
121
64
|
|
|
122
65
|
## Base class
|
|
123
66
|
|
|
@@ -25,6 +25,8 @@ body {
|
|
|
25
25
|
.row {
|
|
26
26
|
display: flex;
|
|
27
27
|
margin-bottom: 2rem;
|
|
28
|
+
flex-flow: wrap;
|
|
29
|
+
gap: 2rem;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
.col {
|
|
@@ -32,10 +34,6 @@ body {
|
|
|
32
34
|
background: #E8F3F8;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
.col:not(:last-child) {
|
|
36
|
-
margin-right: 2rem;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
37
|
.header-image {
|
|
40
38
|
box-shadow: #000 1px 1px 3px;
|
|
41
39
|
background: #0B486B;
|
|
@@ -56,6 +54,17 @@ body {
|
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
|
|
57
|
+
tr:nth-child(even) {
|
|
58
|
+
td {
|
|
59
|
+
background-color: rgba(100, 100, 100, 0.1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
td {
|
|
64
|
+
vertical-align: top;
|
|
65
|
+
padding: 1rem 0.2rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
59
68
|
.package-description {
|
|
60
69
|
max-width: 350px;
|
|
61
70
|
}
|
|
@@ -72,6 +81,10 @@ body {
|
|
|
72
81
|
margin-top: 0;
|
|
73
82
|
}
|
|
74
83
|
}
|
|
84
|
+
|
|
85
|
+
@media screen and (max-width: 1500px) {
|
|
86
|
+
padding: 2rem 1rem;
|
|
87
|
+
}
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
.engine {
|
|
@@ -129,13 +142,18 @@ li.failed::before {
|
|
|
129
142
|
}
|
|
130
143
|
|
|
131
144
|
.settings {
|
|
132
|
-
max-width: 50%;
|
|
133
145
|
|
|
134
146
|
th {
|
|
135
147
|
text-align: left;
|
|
136
148
|
border-bottom: 1px solid black;
|
|
137
149
|
}
|
|
138
150
|
|
|
151
|
+
table {
|
|
152
|
+
width: 100%;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.table-wrap {
|
|
139
157
|
table {
|
|
140
158
|
width: 100%;
|
|
141
159
|
}
|
|
@@ -17,7 +17,7 @@ var Info = Function.inherits('Alchemy.Controller.App', function AlchemyInfo(cond
|
|
|
17
17
|
*
|
|
18
18
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
19
19
|
* @since 0.2.0
|
|
20
|
-
* @version
|
|
20
|
+
* @version 1.3.5
|
|
21
21
|
*/
|
|
22
22
|
Info.setMethod(function setInfoVariables() {
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ Info.setMethod(function setInfoVariables() {
|
|
|
30
30
|
Object.each(Datasource.get(), function eachDatasource(datasource, key) {
|
|
31
31
|
data_sources[key] = {
|
|
32
32
|
type: datasource.constructor.name,
|
|
33
|
-
error: datasource.
|
|
33
|
+
error: datasource.connection_error
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -369,7 +369,7 @@ Mongo.setMethod(function _read(model, criteria, callback) {
|
|
|
369
369
|
*
|
|
370
370
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
371
371
|
* @since 0.2.0
|
|
372
|
-
* @version 1.
|
|
372
|
+
* @version 1.3.6
|
|
373
373
|
*/
|
|
374
374
|
Mongo.setMethod(function _create(model, data, options, callback) {
|
|
375
375
|
|
|
@@ -394,6 +394,26 @@ Mongo.setMethod(function _create(model, data, options, callback) {
|
|
|
394
394
|
return callback(err, result);
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
let write_errors = result.message?.documents?.[0]?.writeErrors;
|
|
398
|
+
|
|
399
|
+
if (write_errors) {
|
|
400
|
+
let violations = new Classes.Alchemy.Error.Validation.Violations();
|
|
401
|
+
|
|
402
|
+
if (write_errors.length) {
|
|
403
|
+
let entry;
|
|
404
|
+
|
|
405
|
+
for (entry of write_errors) {
|
|
406
|
+
let violation = new Classes.Alchemy.Error.Validation.Violation();
|
|
407
|
+
violation.message = entry.errmsg || entry.message || entry.code;
|
|
408
|
+
violations.add(violation);
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
violations.add(new Error('Unknown database error'));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return callback(violations);
|
|
415
|
+
}
|
|
416
|
+
|
|
397
417
|
callback(null, Object.assign({}, data));
|
|
398
418
|
});
|
|
399
419
|
});
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
const OBJECT = Symbol('Object'),
|
|
2
|
-
BACKING = Symbol('Backing'),
|
|
3
|
-
MAP = Symbol('Map');
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* The Backed map class
|
|
7
3
|
*
|
|
@@ -9,249 +5,6 @@ const OBJECT = Symbol('Object'),
|
|
|
9
5
|
*
|
|
10
6
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
11
7
|
* @since 1.2.1
|
|
12
|
-
* @version 1.
|
|
8
|
+
* @version 1.3.5
|
|
13
9
|
*/
|
|
14
|
-
const Backed = Function.inherits('
|
|
15
|
-
this.local = new Map();
|
|
16
|
-
this.type = null;
|
|
17
|
-
this.backing = backing;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Undry the given value
|
|
22
|
-
*
|
|
23
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
24
|
-
* @since 1.2.1
|
|
25
|
-
* @version 1.2.1
|
|
26
|
-
*
|
|
27
|
-
* @param {Object} value
|
|
28
|
-
*
|
|
29
|
-
* @return {EnumValues}
|
|
30
|
-
*/
|
|
31
|
-
Backed.setStatic(function unDry(value, custom_method, whenDone) {
|
|
32
|
-
let result = new this(value.backing);
|
|
33
|
-
return result;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get the size
|
|
38
|
-
*
|
|
39
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
40
|
-
* @since 1.2.1
|
|
41
|
-
* @version 1.2.1
|
|
42
|
-
*/
|
|
43
|
-
Backed.setProperty(function size() {
|
|
44
|
-
return this.keys().length;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Set the backing value
|
|
49
|
-
*
|
|
50
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
51
|
-
* @since 1.2.1
|
|
52
|
-
* @version 1.2.1
|
|
53
|
-
*/
|
|
54
|
-
Backed.enforceProperty(function backing(new_value, old_value) {
|
|
55
|
-
|
|
56
|
-
this.backing = null;
|
|
57
|
-
this.type = null;
|
|
58
|
-
|
|
59
|
-
if (!new_value) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (new_value instanceof Backed) {
|
|
64
|
-
this.type = BACKING;
|
|
65
|
-
} else if (new_value instanceof Map) {
|
|
66
|
-
this.type = MAP;
|
|
67
|
-
} else if (typeof new_value == 'object') {
|
|
68
|
-
this.type = OBJECT;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return new_value;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Create a (shallow) clone of this backed map.
|
|
76
|
-
* Since we don't ever touch the backing itself, we don't have to clone that.
|
|
77
|
-
*
|
|
78
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
79
|
-
* @since 1.2.1
|
|
80
|
-
* @version 1.3.1
|
|
81
|
-
*
|
|
82
|
-
* @return {Backed}
|
|
83
|
-
*/
|
|
84
|
-
Backed.setMethod(function clone() {
|
|
85
|
-
let result = new this.constructor(this.backing);
|
|
86
|
-
result.local = new Map(this.local);
|
|
87
|
-
return result;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Create a (shallow) clone of this backed map.
|
|
92
|
-
* Since we don't ever touch the backing itself, we don't have to clone that.
|
|
93
|
-
*
|
|
94
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
95
|
-
* @since 1.2.1
|
|
96
|
-
* @version 1.2.1
|
|
97
|
-
*
|
|
98
|
-
* @return {Backed}
|
|
99
|
-
*/
|
|
100
|
-
Backed.setMethod(function dryClone(wm, custom_method) {
|
|
101
|
-
return this.clone();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Simplify the object for Hawkejs
|
|
106
|
-
*
|
|
107
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
108
|
-
* @since 1.2.1
|
|
109
|
-
* @version 1.2.1
|
|
110
|
-
*
|
|
111
|
-
* @param {WeakMap} wm
|
|
112
|
-
*
|
|
113
|
-
* @return {Backed}
|
|
114
|
-
*/
|
|
115
|
-
Backed.setMethod(function toHawkejs(wm) {
|
|
116
|
-
|
|
117
|
-
let values = new Map(),
|
|
118
|
-
value,
|
|
119
|
-
keys = this.keys(),
|
|
120
|
-
key;
|
|
121
|
-
|
|
122
|
-
for (key of keys) {
|
|
123
|
-
value = this.get(key);
|
|
124
|
-
values.set(key, JSON.clone(value, 'toHawkejs', wm));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return new this.constructor(values);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Get all the keys
|
|
132
|
-
*
|
|
133
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
134
|
-
* @since 1.2.1
|
|
135
|
-
* @version 1.2.1
|
|
136
|
-
*
|
|
137
|
-
* @return {String[]}
|
|
138
|
-
*/
|
|
139
|
-
Backed.setMethod(function keys() {
|
|
140
|
-
|
|
141
|
-
let result;
|
|
142
|
-
|
|
143
|
-
if (this.type == BACKING) {
|
|
144
|
-
result = this.backing.keys();
|
|
145
|
-
} else if (this.type == MAP) {
|
|
146
|
-
result = [...this.backing.keys()];
|
|
147
|
-
} else if (this.type == OBJECT) {
|
|
148
|
-
result = Object.keys(this.backing);
|
|
149
|
-
} else {
|
|
150
|
-
result = [];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (this.local.size) {
|
|
154
|
-
for (let key of this.local.keys()) {
|
|
155
|
-
if (result.indexOf(key) == -1) {
|
|
156
|
-
result.push(key);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return result;
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Get a value by it's name
|
|
166
|
-
*
|
|
167
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
168
|
-
* @since 1.2.1
|
|
169
|
-
* @version 1.2.1
|
|
170
|
-
*
|
|
171
|
-
* @param {String} name
|
|
172
|
-
*
|
|
173
|
-
* @return {Mixed}
|
|
174
|
-
*/
|
|
175
|
-
Backed.setMethod(function get(name) {
|
|
176
|
-
|
|
177
|
-
if (this.local.has(name)) {
|
|
178
|
-
return this.local.get(name);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (!this.type) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
let value;
|
|
186
|
-
|
|
187
|
-
if (this.type == BACKING || this.type == MAP) {
|
|
188
|
-
value = this.backing.get(name);
|
|
189
|
-
} else if (this.type == OBJECT) {
|
|
190
|
-
value = this.backing[name];
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return value;
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Set a value
|
|
198
|
-
*
|
|
199
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
200
|
-
* @since 1.2.1
|
|
201
|
-
* @version 1.2.1
|
|
202
|
-
*
|
|
203
|
-
* @param {String} name
|
|
204
|
-
* @param {*} value
|
|
205
|
-
*
|
|
206
|
-
* @return {*}
|
|
207
|
-
*/
|
|
208
|
-
Backed.setMethod(function set(name, value) {
|
|
209
|
-
this.local.set(name, value);
|
|
210
|
-
return value;
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Dry the object
|
|
215
|
-
*
|
|
216
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
217
|
-
* @since 1.2.1
|
|
218
|
-
* @version 1.2.1
|
|
219
|
-
*
|
|
220
|
-
* @return {Object}
|
|
221
|
-
*/
|
|
222
|
-
Backed.setMethod(function toDry() {
|
|
223
|
-
|
|
224
|
-
let result = {
|
|
225
|
-
backing : {}
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
let value,
|
|
229
|
-
key;
|
|
230
|
-
|
|
231
|
-
for (key of this.keys()) {
|
|
232
|
-
value = this.get(key);
|
|
233
|
-
result.backing[key] = value;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return {value: result};
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Iterate over the object
|
|
241
|
-
*
|
|
242
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
243
|
-
* @since 1.2.1
|
|
244
|
-
* @version 1.2.1
|
|
245
|
-
*
|
|
246
|
-
* @return {Object}
|
|
247
|
-
*/
|
|
248
|
-
Backed.setMethod(Symbol.iterator, function* iterate() {
|
|
249
|
-
|
|
250
|
-
let value,
|
|
251
|
-
key;
|
|
252
|
-
|
|
253
|
-
for (key of this.keys()) {
|
|
254
|
-
value = this.get(key);
|
|
255
|
-
yield value;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
10
|
+
const Backed = Function.inherits('Develry.BackedMap', 'Alchemy.Map', 'Backed');
|
|
@@ -91,7 +91,7 @@ EnumMap.setMethod(function set(name, value) {
|
|
|
91
91
|
*
|
|
92
92
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
93
93
|
* @since 1.2.1
|
|
94
|
-
* @version 1.
|
|
94
|
+
* @version 1.3.6
|
|
95
95
|
*
|
|
96
96
|
* @param {WeakMap} wm
|
|
97
97
|
*
|
|
@@ -100,23 +100,45 @@ EnumMap.setMethod(function set(name, value) {
|
|
|
100
100
|
EnumMap.setMethod(function toHawkejs(wm) {
|
|
101
101
|
|
|
102
102
|
let result = toHawkejs.super.call(this, wm),
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
original_entry,
|
|
104
|
+
cloned_entry,
|
|
105
105
|
keys = this.keys(),
|
|
106
106
|
key;
|
|
107
107
|
|
|
108
108
|
for (key of keys) {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
original_entry = this.get(key);
|
|
110
|
+
cloned_entry = result.get(key);
|
|
111
|
+
|
|
112
|
+
if (original_entry.value) {
|
|
111
113
|
|
|
112
|
-
|
|
114
|
+
let val = original_entry.value;
|
|
113
115
|
|
|
114
|
-
if (typeof
|
|
115
|
-
|
|
116
|
+
if (typeof val == 'function') {
|
|
117
|
+
cloned_entry.type = 'function';
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
+
if (val.schema) {
|
|
121
|
+
cloned_entry.schema = JSON.clone(val.schema, 'toHawkejs', wm);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let key,
|
|
125
|
+
field_val;
|
|
126
|
+
|
|
127
|
+
for (key in val) {
|
|
128
|
+
|
|
129
|
+
if (key == 'schema') {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
field_val = val[key];
|
|
134
|
+
|
|
135
|
+
if (field_val) {
|
|
136
|
+
const SchemaClass = Blast.isBrowser ? Classes.Alchemy.Client.Schema : Classes.Alchemy.Schema;
|
|
137
|
+
|
|
138
|
+
if (field_val instanceof SchemaClass) {
|
|
139
|
+
cloned_entry[key] = JSON.clone(field_val, 'toHawkejs', wm);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
120
142
|
}
|
|
121
143
|
}
|
|
122
144
|
}
|
|
@@ -221,9 +221,9 @@ Router.setMethod(function applyDirective(element, name, options) {
|
|
|
221
221
|
/**
|
|
222
222
|
* Return route name info
|
|
223
223
|
*
|
|
224
|
-
* @author Jelle De Loecker <jelle@
|
|
224
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
225
225
|
* @since 0.2.0
|
|
226
|
-
* @version 1.
|
|
226
|
+
* @version 1.3.6
|
|
227
227
|
*
|
|
228
228
|
* @param {String} name
|
|
229
229
|
* @param {Boolean} socket_route Look in the socket routes
|
|
@@ -232,13 +232,12 @@ Router.setMethod(function applyDirective(element, name, options) {
|
|
|
232
232
|
*/
|
|
233
233
|
Router.setMethod(function routeConfig(name, socket_route) {
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
key;
|
|
235
|
+
if (!name) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let section,
|
|
240
|
+
routes;
|
|
242
241
|
|
|
243
242
|
if (socket_route) {
|
|
244
243
|
|
|
@@ -264,7 +263,7 @@ Router.setMethod(function routeConfig(name, socket_route) {
|
|
|
264
263
|
return null;
|
|
265
264
|
}
|
|
266
265
|
|
|
267
|
-
pieces = name.split('@');
|
|
266
|
+
let pieces = name.split('@');
|
|
268
267
|
|
|
269
268
|
if (pieces.length == 1) {
|
|
270
269
|
name = pieces[0];
|
|
@@ -273,6 +272,8 @@ Router.setMethod(function routeConfig(name, socket_route) {
|
|
|
273
272
|
if (routes.default[name] != null) {
|
|
274
273
|
section = 'default';
|
|
275
274
|
} else {
|
|
275
|
+
let key;
|
|
276
|
+
|
|
276
277
|
for (key in routes) {
|
|
277
278
|
if (routes[key][name] != null) {
|
|
278
279
|
section = key
|
|
@@ -285,9 +286,9 @@ Router.setMethod(function routeConfig(name, socket_route) {
|
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
if (routes[section] != null && routes[section][name] != null) {
|
|
288
|
-
route = routes[section][name];
|
|
289
|
+
let route = routes[section][name];
|
|
289
290
|
|
|
290
|
-
result = {
|
|
291
|
+
let result = {
|
|
291
292
|
section : section,
|
|
292
293
|
name : name
|
|
293
294
|
};
|
|
@@ -311,16 +311,16 @@ Client.setMethod(function createStream() {
|
|
|
311
311
|
/**
|
|
312
312
|
* Make the actual connection
|
|
313
313
|
*
|
|
314
|
-
* @author Jelle De Loecker <jelle@
|
|
314
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
315
315
|
* @since 0.2.0
|
|
316
|
-
* @version 1.
|
|
316
|
+
* @version 1.3.5
|
|
317
317
|
*
|
|
318
318
|
* @param {Function} callback
|
|
319
319
|
*/
|
|
320
320
|
Client.setMethod(function connect(address, data, callback) {
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
let that = this,
|
|
323
|
+
io_client,
|
|
324
324
|
serverstream,
|
|
325
325
|
config = {},
|
|
326
326
|
server;
|
|
@@ -339,9 +339,9 @@ Client.setMethod(function connect(address, data, callback) {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
if (typeof io != 'undefined') {
|
|
342
|
-
|
|
342
|
+
io_client = io;
|
|
343
343
|
} else if (typeof alchemy != 'undefined') {
|
|
344
|
-
|
|
344
|
+
io_client = alchemy.use('socket.io-client');
|
|
345
345
|
} else {
|
|
346
346
|
return callback(new Error('Could not find socket.io client library'));
|
|
347
347
|
}
|
|
@@ -362,11 +362,19 @@ Client.setMethod(function connect(address, data, callback) {
|
|
|
362
362
|
config.reconnection = false;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
if (Blast.isNode) {
|
|
366
|
+
let msgpack_parser = alchemy.use('socket.io-msgpack-parser');
|
|
367
|
+
|
|
368
|
+
if (msgpack_parser) {
|
|
369
|
+
config.parser = msgpack_parser;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
365
373
|
// Create the connection to the server
|
|
366
374
|
if (address) {
|
|
367
|
-
server =
|
|
375
|
+
server = io_client(address, config);
|
|
368
376
|
} else {
|
|
369
|
-
server =
|
|
377
|
+
server = io_client(config);
|
|
370
378
|
}
|
|
371
379
|
|
|
372
380
|
if (Blast.isNode) {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
let mongo;
|
|
2
|
+
|
|
3
|
+
if (Blast.isNode) {
|
|
4
|
+
mongo = alchemy.use('mongodb');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The BigInt Field class
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*
|
|
12
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
13
|
+
* @since 1.3.6
|
|
14
|
+
* @version 1.3.6
|
|
15
|
+
*/
|
|
16
|
+
const BigIntField = Function.inherits('Alchemy.Field.Number', 'BigInt');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set the datatype name
|
|
20
|
+
*
|
|
21
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
22
|
+
* @since 1.3.6
|
|
23
|
+
* @version 1.3.6
|
|
24
|
+
*/
|
|
25
|
+
BigIntField.setDatatype('bigint');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Cast the given value to this field's type
|
|
29
|
+
*
|
|
30
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
31
|
+
* @since 1.3.6
|
|
32
|
+
* @version 1.3.6
|
|
33
|
+
*
|
|
34
|
+
* @param {Mixed} value
|
|
35
|
+
*
|
|
36
|
+
* @return {BigInt}
|
|
37
|
+
*/
|
|
38
|
+
BigIntField.setMethod(function cast(value) {
|
|
39
|
+
|
|
40
|
+
// Allow null
|
|
41
|
+
if (value == null) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return BigInt(value);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Cast the given value to this field's type for search in a db
|
|
50
|
+
*
|
|
51
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
52
|
+
* @since 1.3.6
|
|
53
|
+
* @version 1.3.6
|
|
54
|
+
*
|
|
55
|
+
* @param {Mixed} value
|
|
56
|
+
* @param {Array} field_paths The path to the field
|
|
57
|
+
*
|
|
58
|
+
* @return {Mixed}
|
|
59
|
+
*/
|
|
60
|
+
BigIntField.setMethod(function _castCondition(value, field_paths) {
|
|
61
|
+
|
|
62
|
+
value = this.cast(value);
|
|
63
|
+
|
|
64
|
+
if (mongo) {
|
|
65
|
+
value = mongo.Long.fromBigInt(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return value;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Convert the value for the given datasource
|
|
73
|
+
*
|
|
74
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
75
|
+
* @since 1.3.6
|
|
76
|
+
* @version 1.3.6
|
|
77
|
+
*
|
|
78
|
+
* @param {Mixed} value The field's own value
|
|
79
|
+
* @param {Object} data The main record
|
|
80
|
+
* @param {Datasource} datasource The datasource instance
|
|
81
|
+
*
|
|
82
|
+
* @return {Mixed}
|
|
83
|
+
*/
|
|
84
|
+
BigIntField.setMethod(function _toDatasource(value, data, datasource, callback) {
|
|
85
|
+
|
|
86
|
+
value = this.cast(value);
|
|
87
|
+
|
|
88
|
+
if (mongo) {
|
|
89
|
+
value = mongo.Long.fromBigInt(value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
callback(null, value);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Convert from database to app
|
|
97
|
+
*
|
|
98
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
99
|
+
* @since 1.3.6
|
|
100
|
+
* @version 1.3.6
|
|
101
|
+
*
|
|
102
|
+
* @param {Object} query The original query
|
|
103
|
+
* @param {Object} options The original query options
|
|
104
|
+
* @param {Mixed} value The field value, as stored in the DB
|
|
105
|
+
* @param {Function} callback
|
|
106
|
+
*/
|
|
107
|
+
BigIntField.setMethod(function _toApp(query, options, value, callback) {
|
|
108
|
+
|
|
109
|
+
if (mongo && value && value.toBigInt) {
|
|
110
|
+
value = value.toBigInt();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
value = this.cast(value);
|
|
114
|
+
|
|
115
|
+
callback(null, value);
|
|
116
|
+
});
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
<% set_title('Alchemy Info Page') %>
|
|
6
6
|
<% this.foundation({protoblast: true}) %>
|
|
7
7
|
<% style('alchemy-info') %>
|
|
8
|
+
<meta charset="UTF-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
10
|
</head>
|
|
9
11
|
<body>
|
|
10
12
|
|
|
@@ -64,11 +66,25 @@
|
|
|
64
66
|
<div class="row">
|
|
65
67
|
<article class="plugins col">
|
|
66
68
|
<h1>Plugins</h1>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
{% with plugins as plugin %}
|
|
70
|
+
|
|
71
|
+
{% none %}
|
|
72
|
+
<p class="none">No plugins are loaded</p>
|
|
73
|
+
{% /none %}
|
|
74
|
+
|
|
75
|
+
{% all %}
|
|
76
|
+
<ul>
|
|
77
|
+
{% /all %}
|
|
78
|
+
|
|
79
|
+
{% each %}
|
|
69
80
|
<li>{{ plugin }}</li>
|
|
70
81
|
{% /each %}
|
|
71
|
-
|
|
82
|
+
|
|
83
|
+
{% all %}
|
|
84
|
+
</ul>
|
|
85
|
+
{% /all %}
|
|
86
|
+
|
|
87
|
+
{% /with %}
|
|
72
88
|
</article>
|
|
73
89
|
|
|
74
90
|
<article class="settings col">
|
package/lib/class/conduit.js
CHANGED
|
@@ -1400,16 +1400,16 @@ Conduit.setMethod(function setResponseUrl(new_url) {
|
|
|
1400
1400
|
/**
|
|
1401
1401
|
* Redirect to another url
|
|
1402
1402
|
*
|
|
1403
|
-
* @author Jelle De Loecker <jelle@
|
|
1403
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
1404
1404
|
* @since 0.2.0
|
|
1405
|
-
* @version 1.
|
|
1405
|
+
* @version 1.3.6
|
|
1406
1406
|
*
|
|
1407
1407
|
* @param {Number} status 3xx redirection codes. 302 (temporary redirect) by default
|
|
1408
1408
|
* @param {String|Object} options Options or url
|
|
1409
1409
|
*/
|
|
1410
1410
|
Conduit.setMethod(function redirect(status, options) {
|
|
1411
1411
|
|
|
1412
|
-
|
|
1412
|
+
let hard_refresh = false,
|
|
1413
1413
|
url;
|
|
1414
1414
|
|
|
1415
1415
|
if (typeof status != 'number') {
|
|
@@ -1486,6 +1486,20 @@ Conduit.setMethod(function redirect(status, options) {
|
|
|
1486
1486
|
|
|
1487
1487
|
this.status = status;
|
|
1488
1488
|
|
|
1489
|
+
// Make sure the url is an internal one if no hard refresh is requested
|
|
1490
|
+
if (!hard_refresh && alchemy.settings.url) {
|
|
1491
|
+
let rurl = RURL.parse(url);
|
|
1492
|
+
|
|
1493
|
+
// If an explicit hostname is set, this might be an external url
|
|
1494
|
+
if (rurl.hostname) {
|
|
1495
|
+
let base_url = RURL.parse(alchemy.settings.url);
|
|
1496
|
+
|
|
1497
|
+
if (base_url.hostname != rurl.hostname) {
|
|
1498
|
+
hard_refresh = true;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1489
1503
|
if (hard_refresh && this.headers['x-hawkejs-request']) {
|
|
1490
1504
|
this.setHeader('x-hawkejs-navigate', url);
|
|
1491
1505
|
|
|
@@ -2217,7 +2231,7 @@ Conduit.setMethod(function _sendStream(stream, options) {
|
|
|
2217
2231
|
*
|
|
2218
2232
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
2219
2233
|
* @since 0.2.0
|
|
2220
|
-
* @version 1.3.
|
|
2234
|
+
* @version 1.3.6
|
|
2221
2235
|
*
|
|
2222
2236
|
* @param {Boolean} create Create a session if none exist
|
|
2223
2237
|
*
|
|
@@ -2231,7 +2245,6 @@ Conduit.setMethod(function getSession(allow_create = true) {
|
|
|
2231
2245
|
}
|
|
2232
2246
|
|
|
2233
2247
|
let cookie_name,
|
|
2234
|
-
fingerprint,
|
|
2235
2248
|
session_id,
|
|
2236
2249
|
session;
|
|
2237
2250
|
|
|
@@ -2246,30 +2259,11 @@ Conduit.setMethod(function getSession(allow_create = true) {
|
|
|
2246
2259
|
session = alchemy.sessions.get(session_id);
|
|
2247
2260
|
}
|
|
2248
2261
|
|
|
2249
|
-
// If no session is found, see if we can find one
|
|
2250
|
-
// based on the browser fingerprint
|
|
2251
|
-
if (!session && this.ip) {
|
|
2252
|
-
fingerprint = this.fingerprint;
|
|
2253
|
-
|
|
2254
|
-
if (fingerprint) {
|
|
2255
|
-
session = alchemy.fingerprints.get(fingerprint);
|
|
2256
|
-
|
|
2257
|
-
if (session && session.id) {
|
|
2258
|
-
session_id = session.id;
|
|
2259
|
-
this.cookie(cookie_name, session_id, {httpOnly: true});
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
|
|
2264
2262
|
// If no valid session exists, create a new one
|
|
2265
2263
|
if (!session && allow_create) {
|
|
2266
2264
|
session = new Classes.Alchemy.ClientSession(this);
|
|
2267
2265
|
session_id = session.id;
|
|
2268
2266
|
|
|
2269
|
-
if (fingerprint) {
|
|
2270
|
-
alchemy.fingerprints.set(fingerprint, session);
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
2267
|
this.cookie(cookie_name, session_id, {httpOnly: true});
|
|
2274
2268
|
|
|
2275
2269
|
alchemy.sessions.set(session_id, session);
|
package/lib/class/field.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @constructor
|
|
6
6
|
*
|
|
7
|
-
* @author Jelle De Loecker <jelle@
|
|
7
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
8
8
|
* @since 0.2.0
|
|
9
|
-
* @version 1.
|
|
9
|
+
* @version 1.3.6
|
|
10
10
|
*
|
|
11
11
|
* @param {Schema} schema The schema this field is added to
|
|
12
12
|
* @param {String} name The name of the field
|
|
@@ -22,8 +22,11 @@ Blast.Globals.Field = Function.inherits('Alchemy.Base', 'Alchemy.Field', functio
|
|
|
22
22
|
// Also store under parent
|
|
23
23
|
this.parent_schema = schema;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (schema) {
|
|
26
|
+
// Check the indexes
|
|
27
|
+
// @TODO: move this to the `addField` methods?
|
|
28
|
+
this.checkIndexes();
|
|
29
|
+
}
|
|
27
30
|
});
|
|
28
31
|
|
|
29
32
|
/**
|
|
@@ -974,9 +977,9 @@ Field.setMethod(function _getValue(wrapped, done_translation) {
|
|
|
974
977
|
/**
|
|
975
978
|
* See if we need to apply any indexes
|
|
976
979
|
*
|
|
977
|
-
* @author Jelle De Loecker <jelle@
|
|
980
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
978
981
|
* @since 1.1.0
|
|
979
|
-
* @version 1.
|
|
982
|
+
* @version 1.3.6
|
|
980
983
|
*/
|
|
981
984
|
Field.setMethod(function checkIndexes() {
|
|
982
985
|
|
|
@@ -997,7 +1000,7 @@ Field.setMethod(function checkIndexes() {
|
|
|
997
1000
|
index.sparse = this.options.sparse;
|
|
998
1001
|
}
|
|
999
1002
|
|
|
1000
|
-
if (this.options.unique) {
|
|
1003
|
+
if (this.options.unique && this.schema) {
|
|
1001
1004
|
this.schema.addIndex(this, index);
|
|
1002
1005
|
} else if (!Object.isEmpty(index)) {
|
|
1003
1006
|
console.log('@TODO: handle field index:', this, index);
|
|
@@ -84,7 +84,7 @@ PathParamDefinition.setStatic(function from(input) {
|
|
|
84
84
|
*
|
|
85
85
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
86
86
|
* @since 1.3.0
|
|
87
|
-
* @version 1.3.
|
|
87
|
+
* @version 1.3.6
|
|
88
88
|
*/
|
|
89
89
|
PathParamDefinition.setMethod(function parseTypeDefinition() {
|
|
90
90
|
|
|
@@ -109,8 +109,21 @@ PathParamDefinition.setMethod(function parseTypeDefinition() {
|
|
|
109
109
|
class_name = this.typedef;
|
|
110
110
|
}
|
|
111
111
|
} else {
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
|
|
113
|
+
let class_path = [],
|
|
114
|
+
field_path = [],
|
|
115
|
+
current = class_path;
|
|
116
|
+
|
|
117
|
+
for (let piece of this.typedef) {
|
|
118
|
+
if (piece[0] != piece[0].toUpperCase()) {
|
|
119
|
+
current = field_path;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
current.push(piece);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
class_name = class_path.join('.');
|
|
126
|
+
field_name = field_path.join('.');
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
if (class_name) {
|
package/lib/class/sitemap.js
CHANGED
|
@@ -353,11 +353,13 @@ Sitemap.setMethod(function addRouteWithParameters(route, config, parameters, for
|
|
|
353
353
|
*
|
|
354
354
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
355
355
|
* @since 1.3.4
|
|
356
|
-
* @version 1.3.
|
|
356
|
+
* @version 1.3.6
|
|
357
|
+
*
|
|
358
|
+
* @param {String} prefix
|
|
357
359
|
*
|
|
358
360
|
* @return {Hawkejs.Builder}
|
|
359
361
|
*/
|
|
360
|
-
Sitemap.setMethod(function getXmlBuilder() {
|
|
362
|
+
Sitemap.setMethod(function getXmlBuilder(prefix) {
|
|
361
363
|
|
|
362
364
|
let xml = Classes.Hawkejs.Builder.create({xml: true}),
|
|
363
365
|
urlset = xml.ele('urlset');
|
|
@@ -367,13 +369,18 @@ Sitemap.setMethod(function getXmlBuilder() {
|
|
|
367
369
|
.att('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd')
|
|
368
370
|
.att('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
|
|
369
371
|
|
|
370
|
-
let categories = this.getCategories();
|
|
372
|
+
let categories = this.getCategories(prefix);
|
|
371
373
|
|
|
372
374
|
for (let category of categories) {
|
|
373
|
-
|
|
375
|
+
|
|
376
|
+
if (!category.pages) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
for (let info of category.pages) {
|
|
374
381
|
let url = urlset.ele(url);
|
|
375
382
|
|
|
376
|
-
url.ele('loc').txt(info.url);
|
|
383
|
+
url.ele('loc').txt(''+info.url);
|
|
377
384
|
|
|
378
385
|
if (info.lastmod) {
|
|
379
386
|
url.ele('lastmod').txt(info.lastmod);
|
package/lib/core/socket.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let msgpack_parser,
|
|
4
4
|
iostream,
|
|
5
|
+
types = alchemy.shared('Socket.types'),
|
|
5
6
|
path = alchemy.use('path'),
|
|
6
7
|
fs = alchemy.use('fs');
|
|
7
8
|
|
|
@@ -10,16 +11,12 @@ var types = alchemy.shared('Socket.types'),
|
|
|
10
11
|
*
|
|
11
12
|
* Create the socket.io listener
|
|
12
13
|
*
|
|
13
|
-
* @author Jelle De Loecker <jelle@
|
|
14
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
15
|
* @since 0.1.0
|
|
15
|
-
* @version 1.
|
|
16
|
+
* @version 1.3.5
|
|
16
17
|
*/
|
|
17
18
|
alchemy.sputnik.add(function socket() {
|
|
18
19
|
|
|
19
|
-
var clientPath,
|
|
20
|
-
streamPath,
|
|
21
|
-
io;
|
|
22
|
-
|
|
23
20
|
if (!alchemy.settings.websockets) {
|
|
24
21
|
log.info('Websockets have been disabled');
|
|
25
22
|
return;
|
|
@@ -31,36 +28,50 @@ alchemy.sputnik.add(function socket() {
|
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
const socket_io = alchemy.use('socket.io');
|
|
35
32
|
|
|
36
|
-
if (!
|
|
33
|
+
if (!socket_io) {
|
|
37
34
|
return log.error('Could not load socket.io!');
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
iostream = alchemy.use('socket.io-stream');
|
|
38
|
+
msgpack_parser = alchemy.use('socket.io-msgpack-parser');
|
|
39
|
+
|
|
40
|
+
let socket_io_options = {
|
|
41
|
+
serveClient : false,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (msgpack_parser) {
|
|
45
|
+
socket_io_options.parser = msgpack_parser;
|
|
46
|
+
}
|
|
41
47
|
|
|
42
48
|
// Create the Socket.io listener
|
|
43
|
-
alchemy.io =
|
|
49
|
+
alchemy.io = socket_io(alchemy.server, socket_io_options);
|
|
44
50
|
|
|
45
51
|
// Get the core client path
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
let client_path = alchemy.findModule('socket.io-client').module_dir;
|
|
53
|
+
|
|
54
|
+
if (msgpack_parser) {
|
|
55
|
+
client_path = path.join(client_path, 'dist', 'socket.io.msgpack.min.js');
|
|
56
|
+
} else {
|
|
57
|
+
client_path = path.join(client_path, 'dist', 'socket.io.min.js');
|
|
58
|
+
}
|
|
48
59
|
|
|
49
60
|
// Get the stream client path
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
let stream_path = path.dirname(alchemy.findModule('@11ways/socket.io-stream').module_path);
|
|
62
|
+
stream_path = path.resolve(stream_path, 'socket.io-stream.js');
|
|
52
63
|
|
|
53
64
|
// Serve the socket io core file
|
|
54
65
|
Router.use('/scripts/socket.io.js', function getSocketIo(req, res, next) {
|
|
55
|
-
alchemy.minifyScript(
|
|
56
|
-
req.conduit.serveFile(mpath ||
|
|
66
|
+
alchemy.minifyScript(client_path, function gotMinifiedPath(err, mpath) {
|
|
67
|
+
req.conduit.serveFile(mpath || client_path);
|
|
57
68
|
});
|
|
58
69
|
});
|
|
59
70
|
|
|
60
71
|
// Serve the socket io stream file
|
|
61
72
|
Router.use('/scripts/socket.io-stream.js', function getSocketStream(req, res, next) {
|
|
62
|
-
alchemy.minifyScript(
|
|
63
|
-
req.conduit.serveFile(mpath ||
|
|
73
|
+
alchemy.minifyScript(stream_path, function gotMinifiedPath(err, mpath) {
|
|
74
|
+
req.conduit.serveFile(mpath || stream_path);
|
|
64
75
|
});
|
|
65
76
|
});
|
|
66
77
|
|
package/lib/stages.js
CHANGED
|
@@ -381,7 +381,7 @@ alchemy.sputnik.add(function routes() {
|
|
|
381
381
|
*
|
|
382
382
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
383
383
|
* @since 0.0.1
|
|
384
|
-
* @version 1.
|
|
384
|
+
* @version 1.3.5
|
|
385
385
|
*/
|
|
386
386
|
alchemy.sputnik.add(function start_server() {
|
|
387
387
|
|
|
@@ -429,7 +429,8 @@ alchemy.sputnik.add(function start_server() {
|
|
|
429
429
|
// The actual `requests` listener is defined in the 'http' stage
|
|
430
430
|
alchemy.server.listen(listen_target, function areListening(){
|
|
431
431
|
|
|
432
|
-
|
|
432
|
+
let address = alchemy.server.address();
|
|
433
|
+
let url = alchemy.settings.url;
|
|
433
434
|
|
|
434
435
|
if (typeof address == 'string') {
|
|
435
436
|
settings.socket = address;
|
|
@@ -439,19 +440,19 @@ alchemy.sputnik.add(function start_server() {
|
|
|
439
440
|
if (settings.socketfile_chmod) {
|
|
440
441
|
fs.chmodSync(address, settings.socketfile_chmod);
|
|
441
442
|
}
|
|
442
|
-
|
|
443
443
|
} else {
|
|
444
444
|
// Get the actual server port
|
|
445
445
|
settings.port = address.port;
|
|
446
446
|
log.info('HTTP server listening on port', settings.port);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
if (alchemy.settings.url) {
|
|
450
|
-
let url = alchemy.settings.url;
|
|
451
447
|
|
|
452
|
-
|
|
448
|
+
if (!url) {
|
|
449
|
+
url = 'http://localhost:' + address.port;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
453
452
|
|
|
454
|
-
|
|
453
|
+
if (url) {
|
|
454
|
+
let pretty_url = alchemy.colors.bg.getRgb(1, 0, 1) + alchemy.colors.fg.getRgb(5, 3, 0) + ' ' + url + ' ' + alchemy.colors.reset;
|
|
455
|
+
log.info('Served at »»', pretty_url, '««');
|
|
455
456
|
}
|
|
456
457
|
|
|
457
458
|
// If this process is a child, tell the parent we're ready
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemymvc",
|
|
3
3
|
"description": "MVC framework for Node.js",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.6",
|
|
5
5
|
"author": "Jelle De Loecker <jelle@elevenways.be>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"alchemy",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"body-parser" : "~1.19.2",
|
|
21
21
|
"bson" : "~4.6.1",
|
|
22
22
|
"chokidar" : "~3.5.3",
|
|
23
|
-
"formidable" : "~2.
|
|
23
|
+
"formidable" : "~2.1.1",
|
|
24
24
|
"graceful-fs" : "~4.2.9",
|
|
25
25
|
"hawkejs" : "~2.3.4",
|
|
26
26
|
"jsondiffpatch" : "~0.4.1",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"mongodb" : "~3.6.6",
|
|
32
32
|
"ncp" : "~2.0.0",
|
|
33
33
|
"postcss" : "~8.4.6",
|
|
34
|
-
"protoblast" : "~0.8.
|
|
34
|
+
"protoblast" : "~0.8.5",
|
|
35
35
|
"semver" : "~7.3.5",
|
|
36
|
-
"socket.io" : "~
|
|
36
|
+
"socket.io" : "~4.6.0",
|
|
37
37
|
"@11ways/socket.io-stream" : "~0.9.2",
|
|
38
38
|
"sputnik" : "~0.1.0",
|
|
39
|
-
"terser" : "~5.
|
|
39
|
+
"terser" : "~5.16.3",
|
|
40
40
|
"toobusy-js" : "~0.5.1",
|
|
41
41
|
"useragent" : "~2.3.0"
|
|
42
42
|
},
|
|
@@ -50,12 +50,13 @@
|
|
|
50
50
|
"sass" : "~1.53.0",
|
|
51
51
|
"sass-embedded" : "~1.53.0",
|
|
52
52
|
"nodent-compiler" : "~3.2.13",
|
|
53
|
-
"socket.io-client" : "~
|
|
53
|
+
"socket.io-client" : "~4.6.0",
|
|
54
|
+
"socket.io-msgpack-parser": "~3.0.2"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"codecov" : "~3.8.1",
|
|
57
58
|
"istanbul-lib-instrument" : "~4.0.3",
|
|
58
|
-
"mocha" : "~
|
|
59
|
+
"mocha" : "~10.2.0",
|
|
59
60
|
"mongo-unit" : "~3.2.0",
|
|
60
61
|
"nyc" : "^15.1.0",
|
|
61
62
|
"puppeteer" : "~19.0.0",
|