nodefony 7.0.0-beta.2 → 7.0.0-beta.21
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/CHANGELOG.md +534 -8028
- package/README.md +33 -30
- package/autoloader.es6 +46 -48
- package/builder.es6 +66 -76
- package/cli/builder/bundles/bundle.js +57 -63
- package/cli/builder/bundles/controller.js +34 -38
- package/cli/builder/bundles/users-bundle/Command/fixtureTask.js +11 -12
- package/cli/builder/bundles/users-bundle/Command/usersCommand.js +23 -24
- package/cli/builder/bundles/users-bundle/Entity/mongoose/userEntity.js +25 -30
- package/cli/builder/bundles/users-bundle/Entity/sequelize/userEntity.js +42 -31
- package/cli/builder/bundles/users-bundle/Fixtures/users.js +24 -26
- package/cli/builder/bundles/users-bundle/Fixtures/usersFixtures.js +28 -29
- package/cli/builder/bundles/users-bundle/Resources/config/config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/routing.js +2 -2
- package/cli/builder/bundles/users-bundle/Resources/config/security.js +9 -8
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.dev.config.js +3 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.prod.config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack.config.js +74 -75
- package/cli/builder/bundles/users-bundle/Resources/scss/awesome/font-awesome.config.js +9 -9
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/login.js +13 -13
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/users.js +14 -14
- package/cli/builder/bundles/users-bundle/controller/api/graphql/graphqlController.js +13 -15
- package/cli/builder/bundles/users-bundle/controller/api/graphql/userResolver.js +29 -29
- package/cli/builder/bundles/users-bundle/controller/api/graphql/usertype.js +2 -2
- package/cli/builder/bundles/users-bundle/controller/api/openapi/loginApiController.js +34 -36
- package/cli/builder/bundles/users-bundle/controller/api/openapi/restUserController.js +32 -36
- package/cli/builder/bundles/users-bundle/controller/loginController.js +30 -34
- package/cli/builder/bundles/users-bundle/controller/usersController.js +54 -60
- package/cli/builder/bundles/users-bundle/package.json +27 -25
- package/cli/builder/bundles/users-bundle/pnpm-lock.yaml +4262 -0
- package/cli/builder/bundles/users-bundle/readme.md +7 -7
- package/cli/builder/bundles/users-bundle/services/usersService.js +97 -102
- package/cli/builder/bundles/users-bundle/src/providers/mongoose/userProvider.js +6 -8
- package/cli/builder/bundles/users-bundle/src/providers/sequelize/userProvider.js +9 -10
- package/cli/builder/bundles/users-bundle/tests/loginTest.js +119 -70
- package/cli/builder/bundles/users-bundle/usersBundle.js +2 -3
- package/cli/builder/microService/microService.js +139 -141
- package/cli/builder/microService/skeletons/package.json +23 -22
- package/cli/builder/project/project.js +228 -181
- package/cli/builder/project/skeletons/README.md +33 -30
- package/cli/builder/project/skeletons/bin/dev-deploy.sh +5 -0
- package/cli/builder/project/skeletons/bin/prod-deploy.sh +3 -0
- package/cli/builder/project/skeletons/config/config.js.skeleton +1 -0
- package/cli/builder/project/skeletons/config/pm2.config.js.skeleton +41 -17
- package/cli/builder/project/skeletons/eslintignore.skeleton +15 -0
- package/cli/builder/project/skeletons/eslintrc.js.skeleton +97 -0
- package/cli/builder/project/skeletons/gitignore.skeleton +1 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.37.entity-user.js +137 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.38.entity-session.js +97 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.39.entity-requests.js +115 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.40.entity-jwts.js +97 -0
- package/cli/builder/project/skeletons/migrations/migrations.skeleton.js +0 -2
- package/cli/builder/project/skeletons/package.json.twig +70 -0
- package/cli/builder/react/reactBuilder.js +59 -65
- package/cli/builder/sandbox/sandBoxBuilder.js +132 -134
- package/cli/builder/skeletons/app/appKernel.js +120 -2
- package/cli/builder/skeletons/config/config.js +1 -1
- package/cli/builder/skeletons/config/nodefony/framework-bundle.js +2 -1
- package/cli/builder/skeletons/config/nodefony/http-bundle.js +1 -0
- package/cli/builder/skeletons/config/nodefony/mongoose-bundle.js +38 -12
- package/cli/builder/skeletons/config/nodefony/monitoring-bundle.js +21 -2
- package/cli/builder/skeletons/config/nodefony/sequelize-bundle.js +122 -13
- package/cli/builder/skeletons/package.json.twig +57 -0
- package/cli/builder/skeletons/unittest/testFile.js +44 -45
- package/cli/builder/vue/skeletons/vue.config.js +84 -10
- package/cli/builder/vue/vueBuilder.js +116 -114
- package/cli/generate/generate.es6 +38 -39
- package/cli/install/install.js +45 -58
- package/cli/sequelize/sequelize.js +50 -39
- package/cli/start.js +353 -347
- package/cli/tools/pm2.es6 +55 -57
- package/cli/tools/tools.es6 +36 -37
- package/cli.es6 +280 -228
- package/container.es6 +51 -59
- package/error.es6 +25 -27
- package/fileClass.es6 +53 -55
- package/finder/file.es6 +5 -4
- package/finder/fileResult.es6 +23 -22
- package/finder/finder2.es6 +46 -54
- package/finder.es6 +88 -97
- package/kernel/annotations/annotations.es6 +44 -46
- package/kernel/api/api.es6 +6 -8
- package/kernel/api/graphqlApi.es6 +21 -21
- package/kernel/api/jsonApi.es6 +40 -45
- package/kernel/api/openApi.es6 +9 -11
- package/kernel/api/schemas/openApiSchema.js +61 -32
- package/kernel/babylon.es6 +31 -38
- package/kernel/bundle.es6 +252 -220
- package/kernel/cliKernel.es6 +157 -170
- package/kernel/command.es6 +17 -20
- package/kernel/commands/nodefonyCommand.es6 +111 -58
- package/kernel/commands/tasks/bundlesTask.es6 +14 -19
- package/kernel/controllers/controller.es6 +167 -180
- package/kernel/fixture.es6 +4 -7
- package/kernel/injections/injections.es6 +97 -103
- package/kernel/kernel.es6 +476 -384
- package/kernel/kernelWatcher.es6 +64 -54
- package/kernel/orm/entity.es6 +10 -12
- package/kernel/orm/orm.es6 +68 -48
- package/kernel/reader.es6 +45 -47
- package/kernel/security/encoder.es6 +8 -6
- package/kernel/security/factories/factory.es6 +34 -37
- package/kernel/security/factories/passeportFactory.es6 +13 -14
- package/kernel/security/provider.es6 +11 -13
- package/kernel/security/providers/chainProvider.es6 +13 -28
- package/kernel/security/providers/memoryProvider.es6 +7 -11
- package/kernel/security/providers/providerManager.es6 +11 -14
- package/kernel/security/providers/userEntityProvider.es6 +7 -8
- package/kernel/security/role.es6 +3 -3
- package/kernel/security/secureArea.es6 +143 -149
- package/kernel/security/tokens/token.es6 +30 -32
- package/kernel/security/user.es6 +19 -19
- package/kernel/serviceRealTime.es6 +5 -7
- package/kernel/services/connectionsService.es6 +20 -22
- package/kernel/services/cron/cronService.es6 +14 -16
- package/kernel/task.es6 +20 -26
- package/kernel/templates.es6 +4 -5
- package/kernel/templating/twig.es6 +56 -47
- package/kernel/tests/cliTest.js +7 -11
- package/kernel/tests/containerTest.js +25 -37
- package/kernel/tests/kernelTest.js +9 -16
- package/nodefony.es6 +279 -256
- package/notificationsCenter.es6 +28 -20
- package/package.json +40 -40
- package/protocol.es6 +19 -21
- package/protocols/bayeux.es6 +35 -38
- package/protocols/jsonRpc/jsonrpc.es6 +12 -14
- package/result.es6 +11 -12
- package/service.es6 +62 -62
- package/syslog/pdu.es6 +99 -91
- package/syslog/syslog.es6 +101 -102
- package/watcher.es6 +21 -20
- package/cli/builder/project/skeletons/jshintignore.skeleton +0 -1
- package/cli/builder/project/skeletons/jshintrc.skeleton +0 -60
- package/cli/builder/project/skeletons/package.json.skeleton +0 -52
- package/cli/builder/skeletons/package.json +0 -61
|
@@ -10,7 +10,7 @@ try {
|
|
|
10
10
|
} catch (e) {}
|
|
11
11
|
|
|
12
12
|
const twigOptions = {
|
|
13
|
-
|
|
13
|
+
"twig options": {
|
|
14
14
|
async: true,
|
|
15
15
|
allowAsync: true,
|
|
16
16
|
cache: true
|
|
@@ -19,35 +19,34 @@ const twigOptions = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
class Twig extends nodefony.Template {
|
|
22
|
-
|
|
23
|
-
constructor(container, options) {
|
|
22
|
+
constructor (container, options) {
|
|
24
23
|
super(container, twig, options);
|
|
25
24
|
this.kernelSettings = this.container.getParameters("kernel");
|
|
26
|
-
this.cache =
|
|
25
|
+
this.cache = this.kernelSettings.environment !== "dev";
|
|
27
26
|
twig.cache(this.cache);
|
|
28
27
|
this.rootDir = this.kernel.rootDir;
|
|
29
28
|
this.name = "Twig";
|
|
30
29
|
container.set("Twig", this);
|
|
31
30
|
this.version = version || twig.VERSION;
|
|
32
31
|
this.nodefonyExtend();
|
|
33
|
-
this.on("onBoot", ()=>{
|
|
34
|
-
this.router = this.get("router")
|
|
35
|
-
this.translation = this.get("translation")
|
|
32
|
+
this.on("onBoot", () => {
|
|
33
|
+
this.router = this.get("router");
|
|
34
|
+
this.translation = this.get("translation");
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
nodefonyExtend(){
|
|
38
|
+
nodefonyExtend () {
|
|
40
39
|
// router
|
|
41
|
-
this.extendFunction("url"
|
|
42
|
-
this.extendFunction("path"
|
|
40
|
+
this.extendFunction("url", this.url.bind(this));
|
|
41
|
+
this.extendFunction("path", this.url.bind(this));
|
|
43
42
|
// control
|
|
44
|
-
this.extendFunction("controller"
|
|
45
|
-
this.extendFunction("render"
|
|
43
|
+
this.extendFunction("controller", Twig.controller);
|
|
44
|
+
this.extendFunction("render", Twig.render);
|
|
46
45
|
// translation
|
|
47
|
-
this.extendFunction("trans"
|
|
48
|
-
this.extendFunction("translate"
|
|
49
|
-
this.extendFilter("trans"
|
|
50
|
-
this.extendFilter("translate"
|
|
46
|
+
this.extendFunction("trans", Twig.translate);
|
|
47
|
+
this.extendFunction("translate", Twig.translate);
|
|
48
|
+
this.extendFilter("trans", Twig.translate);
|
|
49
|
+
this.extendFilter("translate", Twig.translate);
|
|
51
50
|
this.extendFunction("getLangs", this.getLangs.bind(this));
|
|
52
51
|
this.extendFunction("getLocale", Twig.getLocale);
|
|
53
52
|
this.extendFunction("trans_default_domain", Twig.trans_default_domain);
|
|
@@ -60,46 +59,54 @@ class Twig extends nodefony.Template {
|
|
|
60
59
|
this.extendFunction("CDN", Twig.CDN);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
static getFlashBag (...args){
|
|
62
|
+
static getFlashBag (...args) {
|
|
64
63
|
return this.context.nodefony.getContext().getFlashBag(...args);
|
|
65
64
|
}
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
static getUser (...args) {
|
|
67
67
|
return this.context.nodefony.getContext().getUser(...args);
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
|
|
70
|
+
static CDN (...args) {
|
|
71
|
+
const context = this.context.nodefony.getContext();
|
|
72
|
+
const cdn = context.kernelHttp.getCDN(...args);
|
|
73
|
+
const res = `${context.request.url.protocol}//`;
|
|
73
74
|
if (cdn) {
|
|
74
75
|
return `${res}${cdn}`;
|
|
75
|
-
} else {
|
|
76
|
-
return `${res}${context.request.url.host}`;
|
|
77
76
|
}
|
|
77
|
+
return "";
|
|
78
|
+
// return `${res}${context.request.url.host}`;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
static absolute_url (...args){
|
|
81
|
+
static absolute_url (...args) {
|
|
81
82
|
return this.context.nodefony.getContext().generateAbsoluteUrl(...args);
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
|
|
85
|
+
static is_granted (...args) {
|
|
84
86
|
return this.context.nodefony.getContext().is_granted(...args);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
static getLocale (){
|
|
89
|
+
static getLocale () {
|
|
88
90
|
return this.context.nodefony.getContext().translation.getLocale();
|
|
89
91
|
}
|
|
90
|
-
|
|
92
|
+
|
|
93
|
+
static trans_default_domain (domain) {
|
|
91
94
|
return this.context.nodefony.getContext().translation.trans_default_domain(domain);
|
|
92
95
|
}
|
|
93
|
-
|
|
96
|
+
|
|
97
|
+
static getTransDefaultDomain () {
|
|
94
98
|
return this.context.nodefony.getContext().translation.getTransDefaultDomain();
|
|
95
99
|
}
|
|
96
|
-
|
|
100
|
+
|
|
101
|
+
static translate (value, domain, local) {
|
|
97
102
|
return this.context.nodefony.getContext().translation.trans(value, domain, local);
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
|
|
105
|
+
getLangs () {
|
|
106
|
+
return this.translation.getLangs();
|
|
101
107
|
}
|
|
102
|
-
|
|
108
|
+
|
|
109
|
+
url (name, variables, host) {
|
|
103
110
|
try {
|
|
104
111
|
return this.router.generatePath(name, variables, host);
|
|
105
112
|
} catch (e) {
|
|
@@ -107,19 +114,21 @@ class Twig extends nodefony.Template {
|
|
|
107
114
|
return null;
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
|
|
118
|
+
static controller () {
|
|
119
|
+
const pattern = Array.prototype.shift.call(arguments);
|
|
120
|
+
const data = Array.prototype.slice.call(arguments);
|
|
113
121
|
return new nodefony.subRequest(this.context.nodefony.getContext(), pattern, data);
|
|
114
122
|
}
|
|
115
|
-
|
|
123
|
+
|
|
124
|
+
static render (subRequest) {
|
|
116
125
|
return subRequest.handle();
|
|
117
126
|
}
|
|
118
127
|
|
|
119
|
-
renderFile(file, option = {}, callback = null) {
|
|
128
|
+
renderFile (file, option = {}, callback = null) {
|
|
120
129
|
option.settings = nodefony.extend(true, {}, twigOptions, {
|
|
121
130
|
views: this.rootDir,
|
|
122
|
-
|
|
131
|
+
"twig options": {
|
|
123
132
|
cache: this.cache
|
|
124
133
|
}
|
|
125
134
|
});
|
|
@@ -132,7 +141,7 @@ class Twig extends nodefony.Template {
|
|
|
132
141
|
return this.engine.renderFile(file.path, option, (error, result) => {
|
|
133
142
|
if (error || result === undefined) {
|
|
134
143
|
if (!error) {
|
|
135
|
-
error = new Error(
|
|
144
|
+
error = new Error(`ERROR PARSING TEMPLATE :${file.path}`);
|
|
136
145
|
return reject(error);
|
|
137
146
|
}
|
|
138
147
|
return reject(error);
|
|
@@ -154,10 +163,10 @@ class Twig extends nodefony.Template {
|
|
|
154
163
|
}
|
|
155
164
|
}
|
|
156
165
|
|
|
157
|
-
async render(view, param) {
|
|
166
|
+
async render (view, param) {
|
|
158
167
|
try {
|
|
159
|
-
|
|
160
|
-
.catch(e => {
|
|
168
|
+
const template = await this.compile(view)
|
|
169
|
+
.catch((e) => {
|
|
161
170
|
this.log(e, "ERROR");
|
|
162
171
|
throw e;
|
|
163
172
|
});
|
|
@@ -170,14 +179,14 @@ class Twig extends nodefony.Template {
|
|
|
170
179
|
}
|
|
171
180
|
}
|
|
172
181
|
|
|
173
|
-
compile(file, callback) {
|
|
182
|
+
compile (file, callback) {
|
|
174
183
|
return new Promise((resolve, reject) => {
|
|
175
184
|
this.engine.twig({
|
|
176
185
|
path: file.path,
|
|
177
186
|
async: true,
|
|
178
187
|
allowAsync: true,
|
|
179
188
|
base: this.rootDir,
|
|
180
|
-
//precompiled:false,
|
|
189
|
+
// precompiled:false,
|
|
181
190
|
name: file.name,
|
|
182
191
|
load: (template) => {
|
|
183
192
|
if (callback) {
|
|
@@ -195,11 +204,11 @@ class Twig extends nodefony.Template {
|
|
|
195
204
|
});
|
|
196
205
|
}
|
|
197
206
|
|
|
198
|
-
extendFunction() {
|
|
207
|
+
extendFunction () {
|
|
199
208
|
return twig.extendFunction.apply(twig, arguments);
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
extendFilter() {
|
|
211
|
+
extendFilter () {
|
|
203
212
|
return twig.extendFilter.apply(twig, arguments);
|
|
204
213
|
}
|
|
205
214
|
}
|
package/kernel/tests/cliTest.js
CHANGED
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
* kernel : instance of kernel who launch the test
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
const assert = require(
|
|
12
|
+
const assert = require("assert");
|
|
13
13
|
|
|
14
14
|
describe("NODEFONY CLI", () => {
|
|
15
|
-
|
|
16
15
|
beforeEach(() => {});
|
|
17
16
|
|
|
18
|
-
describe(
|
|
17
|
+
describe("SIMPLE", () => {
|
|
19
18
|
it("CREATE", (done) => {
|
|
20
19
|
const project = new nodefony.cli("project", {
|
|
21
20
|
version: nodefony.version,
|
|
@@ -24,12 +23,12 @@ describe("NODEFONY CLI", () => {
|
|
|
24
23
|
});
|
|
25
24
|
assert.strictEqual(project.name, "project");
|
|
26
25
|
assert.strictEqual(project.commander.version(), nodefony.version);
|
|
27
|
-
|
|
28
|
-
processName:
|
|
26
|
+
const options = {
|
|
27
|
+
processName: "nodefony",
|
|
29
28
|
autostart: true,
|
|
30
29
|
asciify: true,
|
|
31
30
|
clear: true,
|
|
32
|
-
prompt:
|
|
31
|
+
prompt: "default",
|
|
33
32
|
commander: true,
|
|
34
33
|
color: clc.red.bold,
|
|
35
34
|
signals: true,
|
|
@@ -42,7 +41,7 @@ describe("NODEFONY CLI", () => {
|
|
|
42
41
|
};
|
|
43
42
|
assert.deepStrictEqual(options, project.options);
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
const banner = ` Version : ${clc.blueBright.bold(nodefony.version)} Platform : ${clc.green(process.platform)} Process : ${clc.green("project")} Pid : ${project.pid}`;
|
|
46
45
|
let res = null;
|
|
47
46
|
project.start()
|
|
48
47
|
.then((cli) => {
|
|
@@ -52,12 +51,9 @@ describe("NODEFONY CLI", () => {
|
|
|
52
51
|
assert.strictEqual(res, 0);
|
|
53
52
|
done();
|
|
54
53
|
})
|
|
55
|
-
.catch(e => {
|
|
54
|
+
.catch((e) => {
|
|
56
55
|
throw e;
|
|
57
56
|
});
|
|
58
57
|
});
|
|
59
|
-
|
|
60
58
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
59
|
});
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
const assert = require(
|
|
14
|
+
const assert = require("assert");
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const myObject = {
|
|
17
17
|
|
|
18
18
|
foo: "bar",
|
|
19
19
|
bar: "foo"
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const myObject2 = {
|
|
23
23
|
foo: "bar2",
|
|
24
24
|
bar: "foo2"
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const myClass = function () {
|
|
28
28
|
this.settings = {
|
|
29
29
|
foo: "bar"
|
|
30
30
|
};
|
|
@@ -55,30 +55,26 @@ var myClass = function() {
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
myClass.prototype.getConfig = function() {
|
|
58
|
+
myClass.prototype.getConfig = function () {
|
|
59
59
|
return this.settings;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
myClass.prototype.getConfig2 = function() {
|
|
62
|
+
myClass.prototype.getConfig2 = function () {
|
|
63
63
|
return this.setting2;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
describe("NODEFONY KERNEL ", () => {
|
|
68
|
+
describe("CONTAINER", () => {
|
|
69
|
+
beforeEach(() => {});
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
describe("NODEFONY KERNEL ", function() {
|
|
70
|
-
|
|
71
|
-
describe('CONTAINER', function() {
|
|
72
|
-
|
|
73
|
-
beforeEach(function() {});
|
|
74
|
-
|
|
75
|
-
before(function() {
|
|
71
|
+
before(() => {
|
|
76
72
|
if (!global.globalContainer) {
|
|
77
73
|
global.globalContainer = new nodefony.Container();
|
|
78
74
|
}
|
|
79
75
|
});
|
|
80
76
|
|
|
81
|
-
it("LIB LOADED",
|
|
77
|
+
it("LIB LOADED", (done) => {
|
|
82
78
|
// check nodefony namespace
|
|
83
79
|
assert.equal(typeof nodefony, "object");
|
|
84
80
|
|
|
@@ -89,8 +85,7 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
89
85
|
done();
|
|
90
86
|
});
|
|
91
87
|
|
|
92
|
-
it("INSTANCE CONTAINER",
|
|
93
|
-
|
|
88
|
+
it("INSTANCE CONTAINER", (done) => {
|
|
94
89
|
// YOU CAN REGISTER INSTANCE HERSELF HAS SERVICES
|
|
95
90
|
global.globalContainer.set("global", global.globalContainer);
|
|
96
91
|
let res = global.globalContainer.get("global");
|
|
@@ -101,7 +96,7 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
101
96
|
res = global.globalContainer.get("obj");
|
|
102
97
|
assert.deepStrictEqual(res, myObject);
|
|
103
98
|
|
|
104
|
-
|
|
99
|
+
const service = global.globalContainer.set("myService", new myClass());
|
|
105
100
|
assert.deepEqual(service.getConfig(), {
|
|
106
101
|
foo: "bar"
|
|
107
102
|
});
|
|
@@ -113,19 +108,17 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
113
108
|
assert.equal(global.globalContainer.getParameters("config.foo"), "bar");
|
|
114
109
|
|
|
115
110
|
|
|
116
|
-
|
|
117
111
|
done();
|
|
118
112
|
});
|
|
119
113
|
|
|
120
|
-
it("SCOPE CONTAINER",
|
|
121
|
-
|
|
114
|
+
it("SCOPE CONTAINER", (done) => {
|
|
122
115
|
// CREATE SCOPE WITH NAME
|
|
123
116
|
global.globalContainer.addScope("request");
|
|
124
117
|
assert.deepEqual(global.globalContainer.scope.request, {});
|
|
125
118
|
|
|
126
119
|
// CLONE ;
|
|
127
120
|
global.scope = global.globalContainer.enterScope("request");
|
|
128
|
-
|
|
121
|
+
const {id} = global.scope;
|
|
129
122
|
assert(global.globalContainer.scope.request[id], "SCOPE ID ERROR");
|
|
130
123
|
assert.deepStrictEqual(global.globalContainer, global.scope.parent);
|
|
131
124
|
assert.deepStrictEqual(global.globalContainer.scope.request[id], global.scope);
|
|
@@ -136,7 +129,7 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
136
129
|
assert.deepStrictEqual(global.scope.get("obj2"), myObject2);
|
|
137
130
|
|
|
138
131
|
|
|
139
|
-
|
|
132
|
+
const service = global.scope.get("myService");
|
|
140
133
|
assert.deepEqual(service.getConfig(), {
|
|
141
134
|
foo: "bar"
|
|
142
135
|
});
|
|
@@ -157,13 +150,12 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
157
150
|
done();
|
|
158
151
|
});
|
|
159
152
|
|
|
160
|
-
it("EXTENDED SCOPE ALREADY SCOPED",
|
|
161
|
-
|
|
153
|
+
it("EXTENDED SCOPE ALREADY SCOPED", (done) => {
|
|
162
154
|
global.scope.addScope("response");
|
|
163
155
|
assert.deepEqual(global.scope.scope.response, {});
|
|
164
156
|
// CLONE ;
|
|
165
|
-
|
|
166
|
-
|
|
157
|
+
const scope = global.scope.enterScopeExtended("response");
|
|
158
|
+
const {id} = scope;
|
|
167
159
|
assert(global.scope.scope.response[id], "SCOPE ID ERROR");
|
|
168
160
|
assert.deepStrictEqual(global.scope, scope.parent);
|
|
169
161
|
assert.deepStrictEqual(global.scope.scope.response[id], scope);
|
|
@@ -172,7 +164,7 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
172
164
|
|
|
173
165
|
assert.deepStrictEqual(scope.get("obj2"), myObject2);
|
|
174
166
|
|
|
175
|
-
|
|
167
|
+
const myObj = {
|
|
176
168
|
bar: "foo"
|
|
177
169
|
};
|
|
178
170
|
scope.set("myObj", myObj);
|
|
@@ -182,8 +174,8 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
182
174
|
|
|
183
175
|
// CHECK extended recursif
|
|
184
176
|
scope.addScope("websocket");
|
|
185
|
-
//clone
|
|
186
|
-
|
|
177
|
+
// clone
|
|
178
|
+
const scope2 = scope.enterScope("websocket");
|
|
187
179
|
assert.deepStrictEqual(scope2.get("obj2"), myObject2);
|
|
188
180
|
|
|
189
181
|
|
|
@@ -204,8 +196,7 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
204
196
|
done();
|
|
205
197
|
});
|
|
206
198
|
|
|
207
|
-
it("Leave and remove Scope ",
|
|
208
|
-
|
|
199
|
+
it("Leave and remove Scope ", (done) => {
|
|
209
200
|
global.scope.removeScope("response");
|
|
210
201
|
assert.deepEqual(global.scope.scope.response, undefined);
|
|
211
202
|
|
|
@@ -216,11 +207,10 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
216
207
|
global.globalContainer.removeScope("request");
|
|
217
208
|
assert.deepEqual(global.globalContainer.scope.request, undefined);
|
|
218
209
|
done();
|
|
219
|
-
|
|
220
210
|
});
|
|
221
211
|
|
|
222
|
-
it("After remove scope ",
|
|
223
|
-
|
|
212
|
+
it("After remove scope ", (done) => {
|
|
213
|
+
const service = global.globalContainer.get("myService");
|
|
224
214
|
assert.deepEqual(service.getConfig(), {
|
|
225
215
|
foo: "bar"
|
|
226
216
|
});
|
|
@@ -238,7 +228,5 @@ describe("NODEFONY KERNEL ", function() {
|
|
|
238
228
|
|
|
239
229
|
done();
|
|
240
230
|
});
|
|
241
|
-
|
|
242
231
|
});
|
|
243
|
-
|
|
244
232
|
});
|
|
@@ -13,34 +13,27 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
const assert = require("assert");
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
describe("NODEFONY KERNEL", function(){
|
|
21
|
-
|
|
22
|
-
describe('LIBRARY', function(){
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
beforeEach(function(){
|
|
18
|
+
describe("NODEFONY KERNEL", () => {
|
|
19
|
+
describe("LIBRARY", () => {
|
|
20
|
+
beforeEach(() => {
|
|
26
21
|
});
|
|
27
22
|
|
|
28
|
-
before(
|
|
23
|
+
before(() => {
|
|
29
24
|
|
|
30
25
|
});
|
|
31
26
|
|
|
32
|
-
it("NAMESPACE LOADED",
|
|
27
|
+
it("NAMESPACE LOADED", (done) => {
|
|
33
28
|
// check nodefony namespace
|
|
34
|
-
assert.equal(
|
|
29
|
+
assert.equal(typeof nodefony, "object");
|
|
35
30
|
done();
|
|
36
31
|
});
|
|
37
32
|
|
|
38
|
-
it("INSTANCE KERNEL LOADED",
|
|
33
|
+
it("INSTANCE KERNEL LOADED", (done) => {
|
|
39
34
|
// check instance kernel
|
|
40
|
-
assert.equal(
|
|
35
|
+
assert.equal(kernel instanceof nodefony.kernel, true);
|
|
41
36
|
done();
|
|
42
37
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
38
|
});
|
|
46
39
|
});
|