Skip to content

Commit 7a652f6

Browse files
committed
add global async
1 parent bb1a5a5 commit 7a652f6

File tree

5 files changed

+26
-87
lines changed

5 files changed

+26
-87
lines changed

config/globals.js

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
11
module.exports = {
22

3-
4-
/****************************************************************************
5-
* *
6-
* Expose the async installed in Sails core as a global variable. If this is *
7-
* disabled, like any other node module you can always run npm install async *
8-
* --save, then var async = require('async') at the top of any file. *
9-
* *
10-
****************************************************************************/
11-
12-
async: false,
13-
143
/****************************************************************************
154
* *
16-
* Expose each of your app's services as global variables (using their *
17-
* "globalId"). E.g. a service defined in app/services/Auth.js *
18-
* would have a globalId of Auth by default. If this is disabled, *
19-
* you can still access your services via app.services.*. *
5+
* Expose each of your app's models as global variables (using their *
6+
* "globalId"). E.g. a model defined in app/controllers/HomeController.js *
7+
* would have a globalId of HomeController by default. If this is disabled, *
8+
* you can still access your models via app.controllers.*. *
209
* *
2110
****************************************************************************/
2211

23-
services: true,
12+
controllers: true,
2413

2514
/****************************************************************************
2615
* *
2716
* Expose each of your app's models as global variables (using their *
28-
* "globalId"). E.g. a model defined in app/controllers/HomeController.js *
29-
* would have a globalId of HomeController by default. If this is disabled, *
30-
* you can still access your models via app.controllers.*. *
17+
* "globalId"). E.g. a model defined in app/models/User.js would have a *
18+
* globalId of User by default. If this is disabled, you can still access *
19+
* your models via app.models.*. *
3120
* *
3221
****************************************************************************/
3322

34-
controllers: true,
35-
23+
models: true,
3624

3725
/****************************************************************************
3826
* *
@@ -47,12 +35,12 @@ module.exports = {
4735

4836
/****************************************************************************
4937
* *
50-
* Expose each of your app's models as global variables (using their *
51-
* "globalId"). E.g. a model defined in app/models/User.js would have a *
52-
* globalId of User by default. If this is disabled, you can still access *
53-
* your models via app.models.*. *
38+
* Expose each of your app's services as global variables (using their *
39+
* "globalId"). E.g. a service defined in app/services/Auth.js *
40+
* would have a globalId of Auth by default. If this is disabled, *
41+
* you can still access your services via app.services.*. *
5442
* *
5543
****************************************************************************/
5644

57-
models: true
45+
services: true
5846
};

libs/merge.js

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* https://raw.github.com/yeikos/js.merge/master/LICENSE
88
*/
99

10-
(function(isNode) {
10+
(function (isNode) {
1111

1212
/**
1313
* Merge one or more objects
@@ -16,10 +16,8 @@
1616
* @return object
1717
*/
1818

19-
var Public = function(clone) {
20-
19+
var Public = function (clone) {
2120
return merge(clone === true, false, arguments);
22-
2321
}, publicName = 'merge';
2422

2523
/**
@@ -29,10 +27,8 @@
2927
* @return object
3028
*/
3129

32-
Public.recursive = function(clone) {
33-
30+
Public.recursive = function (clone) {
3431
return merge(clone === true, true, arguments);
35-
3632
};
3733

3834
/**
@@ -41,33 +37,21 @@
4137
* @return mixed
4238
*/
4339

44-
Public.clone = function(input) {
45-
40+
Public.clone = function (input) {
4641
var output = input,
4742
type = typeOf(input),
4843
index, size;
49-
5044
if (type === 'array') {
51-
5245
output = [];
5346
size = input.length;
54-
55-
for (index=0;index<size;++index)
56-
47+
for (index = 0; index < size; ++index)
5748
output[index] = Public.clone(input[index]);
58-
5949
} else if (type === 'object') {
60-
6150
output = {};
62-
6351
for (index in input)
64-
6552
output[index] = Public.clone(input[index]);
66-
6753
}
68-
6954
return output;
70-
7155
};
7256

7357
/**
@@ -78,27 +62,16 @@
7862
*/
7963

8064
function merge_recursive(base, extend) {
81-
8265
if (typeOf(base) !== 'object')
83-
8466
return extend;
85-
8667
for (var key in extend) {
87-
8868
if (typeOf(base[key]) === 'object' && typeOf(extend[key]) === 'object') {
89-
9069
base[key] = merge_recursive(base[key], extend[key]);
91-
9270
} else {
93-
9471
base[key] = extend[key];
95-
9672
}
97-
9873
}
99-
10074
return base;
101-
10275
}
10376

10477
/**
@@ -110,42 +83,24 @@
11083
*/
11184

11285
function merge(clone, recursive, argv) {
113-
11486
var result = argv[0],
11587
size = argv.length;
116-
11788
if (clone || typeOf(result) !== 'object')
118-
11989
result = {};
120-
121-
for (var index=0;index<size;++index) {
122-
90+
for (var index = 0; index < size; ++index) {
12391
var item = argv[index],
124-
12592
type = typeOf(item);
126-
12793
if (type !== 'object') continue;
128-
12994
for (var key in item) {
130-
13195
var sitem = clone ? Public.clone(item[key]) : item[key];
132-
13396
if (recursive) {
134-
13597
result[key] = merge_recursive(result[key], sitem);
136-
13798
} else {
138-
13999
result[key] = sitem;
140-
141100
}
142-
143101
}
144-
145102
}
146-
147103
return result;
148-
149104
}
150105

151106
/**
@@ -157,19 +112,13 @@
157112
*/
158113

159114
function typeOf(input) {
160-
161115
return ({}).toString.call(input).slice(8, -1).toLowerCase();
162-
163116
}
164117

165118
if (isNode) {
166-
167119
module.exports = Public;
168-
169120
} else {
170-
171121
window[publicName] = Public;
172-
173122
}
174123

175124
})(typeof module === 'object' && module && typeof module.exports === 'object' && module.exports);

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"express-back": "0.0.2",
2222
"express-flash": "0.0.2",
2323
"express-session": "^1.15.6",
24-
"express-validator": "^4.2.1",
24+
"express-validator": "^4.3.0",
2525
"i18n": "^0.8.3",
2626
"jsonwebtoken": "^8.1.0",
2727
"mongoose": "^4.12.4",

server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ global.__basepath = process.cwd();
44

55
global.app = new require("express")();
66

7+
global.async = new require("async");
8+
79
require("./app");
810

911
require("./app/kernel");

0 commit comments

Comments
 (0)