not-node 5.1.44 → 6.0.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.
Files changed (53) hide show
  1. package/.eslintrc.json +32 -38
  2. package/index.js +6 -0
  3. package/package.json +12 -11
  4. package/src/app.js +2 -2
  5. package/src/auth/index.js +0 -2
  6. package/src/auth/routes.js +25 -61
  7. package/src/auth/rules.js +8 -7
  8. package/src/common.js +19 -0
  9. package/src/identity/exceptions.js +17 -0
  10. package/src/identity/identity.js +61 -0
  11. package/src/identity/index.js +35 -0
  12. package/src/identity/providers/session.js +137 -0
  13. package/src/identity/providers/token.js +255 -0
  14. package/src/manifest/result.filter.js +268 -0
  15. package/src/manifest/route.js +6 -36
  16. package/static2.js +24 -0
  17. package/test/auth/identity.js +0 -0
  18. package/test/auth/routes.js +1 -1
  19. package/test/auth.js +427 -229
  20. package/test/env.js +20 -20
  21. package/test/fields.js +3 -2
  22. package/test/identity/identity.js +1 -0
  23. package/test/identity/index.js +12 -0
  24. package/test/identity/providers/session.js +227 -0
  25. package/test/identity/providers/token.js +244 -0
  26. package/test/identity.js +5 -0
  27. package/test/init/app.js +359 -365
  28. package/test/init/bodyparser.js +37 -39
  29. package/test/init/compression.js +29 -31
  30. package/test/init/cors.js +38 -39
  31. package/test/init/db.js +60 -64
  32. package/test/init/env.js +109 -114
  33. package/test/init/express.js +50 -47
  34. package/test/init/fileupload.js +30 -32
  35. package/test/init/http.js +258 -240
  36. package/test/init/informer.js +20 -24
  37. package/test/init/methodoverride.js +29 -31
  38. package/test/init/middleware.js +56 -58
  39. package/test/init/modules.js +19 -19
  40. package/test/init/monitoring.js +22 -22
  41. package/test/init/routes.js +185 -171
  42. package/test/init/security.js +77 -103
  43. package/test/init/sessions/mongoose.js +56 -57
  44. package/test/init/sessions/redis.js +59 -61
  45. package/test/init/sessions.js +84 -79
  46. package/test/init/static.js +108 -113
  47. package/test/init/template.js +46 -41
  48. package/test/notInit.js +217 -217
  49. package/test/notManifest.js +232 -191
  50. package/test/notRoute.js +1022 -799
  51. package/test/result.filter.js +422 -0
  52. package/src/auth/session.js +0 -151
  53. package/test/auth/session.js +0 -266
@@ -1,126 +1,121 @@
1
- const mock = require('mock-require');
1
+ const mock = require("mock-require");
2
2
 
3
- let staticFunction = function(){
4
-
5
- };
3
+ let staticFunction = function () {};
6
4
 
7
5
  const mod = {
8
- static: function(){
9
- return staticFunction;
10
- }
6
+ static: function () {
7
+ return staticFunction;
8
+ },
11
9
  };
12
- mock.stop('serve-static');
13
- mock('serve-static', mod.static);
14
-
15
- const InitStatic = require('../../src/init/static');
16
-
17
- module.exports = ({expect})=>{
18
- describe('Static', ()=>{
19
- describe('getUserRole', ()=>{
20
- it('user exists', ()=>{
21
- const res = InitStatic.getUserRole({
22
- user:{
23
- role: 'user'
24
- }
25
- });
26
- expect(res).to.be.equal('user');
27
- });
28
-
29
- it('user not exists', ()=>{
30
- const res = InitStatic.getUserRole({});
31
- expect(res).to.be.equal('guest');
32
- });
33
- });
10
+ mock.stop("serve-static");
11
+ mock("serve-static", mod.static);
34
12
 
35
- describe('selectVersion', ()=>{
36
- it('user exists, ext - js', ()=>{
37
- const config = {
38
- get(str){
39
- return {
40
- 'user:roles:priority': ['root','user','guest'],
41
- 'path:front': 'path_from_fake'
42
- }[str];
43
- }
44
- };
45
- const res = InitStatic.selectVersion(config, {
46
- user:{
47
- role: 'user'
48
- }
49
- }, 'js');
50
- expect(res).to.be.equal('path_from_fake/user.js');
51
- });
13
+ const InitStatic = require("../../src/init/lib/static");
52
14
 
53
- it('user role not in list', ()=>{
54
- const config = {
55
- get(str){
56
- return {
57
- 'path:front': 'path_from_fake'
58
- }[str];
59
- }
60
- };
61
- const res = InitStatic.selectVersion(config, {
62
- user:{
63
- role: 'manager'
64
- }
65
- }, 'js');
66
- expect(res).to.be.equal('path_from_fake/guest.js');
67
- });
68
- });
15
+ module.exports = ({ expect }) => {
16
+ describe("Static", () => {
17
+ describe("getUserRole", () => {
18
+ it("user exists", () => {
19
+ const res = InitStatic.getUserRole({
20
+ user: {
21
+ role: "user",
22
+ },
23
+ });
24
+ expect(res).to.be.equal("user");
25
+ });
69
26
 
70
- describe('createStaticFrontServer', ()=>{
27
+ it("user not exists", () => {
28
+ const res = InitStatic.getUserRole({});
29
+ expect(res).to.be.equal("guest");
30
+ });
31
+ });
71
32
 
72
- it('user exists, ext - js', ()=>{
73
- InitStatic.serveStatic = mod.static;
74
- const config = {
75
- get(str){
76
- return {
77
- 'user:roles:priority': ['root','user','guest'],
78
- 'path:front': 'path_from_fake'
79
- }[str];
80
- }
81
- };
82
- const res = InitStatic.createStaticFrontServer(
83
- 'js',
84
- {
85
- config,
86
- options: {
87
- pathToApp: 'pathToApp__fake'
88
- }
89
- }
90
- );
91
- staticFunction = (rq,rs,nxt)=>{
92
- console.log('new static function');
93
- throw new Error('Some fake error');
94
- };
95
- expect(typeof res).to.be.equal('function');
96
- res(
97
- {},
98
- {},
99
- (e)=>{
100
- expect(e).to.be.instanceof(Error);
101
- expect(e.message).to.be.equal('Some fake error');
102
- }
103
- );
104
- });
105
- });
33
+ describe("selectVersion", () => {
34
+ it("user exists, ext - js", () => {
35
+ const config = {
36
+ get(str) {
37
+ return {
38
+ "user:roles:priority": ["root", "user", "guest"],
39
+ "path:front": "path_from_fake",
40
+ }[str];
41
+ },
42
+ };
43
+ const res = InitStatic.selectVersion(
44
+ config,
45
+ {
46
+ user: {
47
+ role: "user",
48
+ },
49
+ },
50
+ "js"
51
+ );
52
+ expect(res).to.be.equal("path_from_fake/user.js");
53
+ });
106
54
 
55
+ it("user role not in list", () => {
56
+ const config = {
57
+ get(str) {
58
+ return {
59
+ "path:front": "path_from_fake",
60
+ }[str];
61
+ },
62
+ };
63
+ const res = InitStatic.selectVersion(
64
+ config,
65
+ {
66
+ user: {
67
+ role: "manager",
68
+ },
69
+ },
70
+ "js"
71
+ );
72
+ expect(res).to.be.equal("path_from_fake/guest.js");
73
+ });
74
+ });
107
75
 
108
- describe('run', ()=>{
76
+ describe("createStaticFrontServer", () => {
77
+ it("user exists, ext - js", () => {
78
+ InitStatic.serveStatic = mod.static;
79
+ const config = {
80
+ get(str) {
81
+ return {
82
+ "user:roles:priority": ["root", "user", "guest"],
83
+ "path:front": "path_from_fake",
84
+ }[str];
85
+ },
86
+ };
87
+ const res = InitStatic.createStaticFrontServer("js", {
88
+ config,
89
+ options: {
90
+ pathToApp: "pathToApp__fake",
91
+ },
92
+ });
93
+ staticFunction = (rq, rs, nxt) => {
94
+ console.log("new static function");
95
+ throw new Error("Some fake error");
96
+ };
97
+ expect(typeof res).to.be.equal("function");
98
+ res({}, {}, (e) => {
99
+ expect(e).to.be.instanceof(Error);
100
+ expect(e.message).to.be.equal("Some fake error");
101
+ });
102
+ });
103
+ });
109
104
 
110
- it('generic', async ()=>{
111
- const master = {
112
- getServer(){
113
- return {
114
- use(route, func){
115
- expect(typeof route).to.be.equal('string');
116
- expect(typeof func).to.be.equal('function');
117
- }
118
- };
119
- }
120
- };
121
- await new InitStatic().run({master});
122
- });
105
+ describe("run", () => {
106
+ it("generic", async () => {
107
+ const master = {
108
+ getServer() {
109
+ return {
110
+ use(route, func) {
111
+ expect(typeof route).to.be.equal("string");
112
+ expect(typeof func).to.be.equal("function");
113
+ },
114
+ };
115
+ },
116
+ };
117
+ await new InitStatic().run({ master });
118
+ });
119
+ });
123
120
  });
124
-
125
- });
126
121
  };
@@ -1,46 +1,51 @@
1
- const InitTemplate = require('../../src/init/template');
1
+ const InitTemplate = require("../../src/init/lib/template");
2
2
 
3
- module.exports = ({
4
- expect
5
- }) => {
6
- describe('InitTemplate', () => {
7
- describe('run', () => {
8
- it('run, middleware returned and set', async () => {
9
- let setCalled = 0;
10
- const master = {
11
- getAbsolutePath(str){return `${str}_fake_path`;},
12
- getServer() {
13
- return {
14
- set(key, val){
15
- setCalled++;
16
- expect(key).to.be.ok;
17
- expect(val).to.be.ok;
18
- }
19
- };
20
- }
21
- };
22
- const config = {
23
- get(str){
24
- return {
25
- engine: `${str}_fake_config_engine`,
26
- views: `${str}_fake_config_views`
27
- };
28
- }
29
- };
30
- await (new InitTemplate()).run({master, config});
31
- expect(setCalled).to.be.equal(2);
32
- });
33
-
34
- });
3
+ module.exports = ({ expect }) => {
4
+ describe("InitTemplate", () => {
5
+ describe("run", () => {
6
+ it("run, middleware returned and set", async () => {
7
+ let setCalled = 0;
8
+ const master = {
9
+ getAbsolutePath(str) {
10
+ return `${str}_fake_path`;
11
+ },
12
+ getServer() {
13
+ return {
14
+ set(key, val) {
15
+ setCalled++;
16
+ expect(key).to.be.ok;
17
+ expect(val).to.be.ok;
18
+ },
19
+ };
20
+ },
21
+ };
22
+ const config = {
23
+ get(str) {
24
+ return {
25
+ engine: `${str}_fake_config_engine`,
26
+ views: `${str}_fake_config_views`,
27
+ };
28
+ },
29
+ };
30
+ await new InitTemplate().run({ master, config });
31
+ expect(setCalled).to.be.equal(2);
32
+ });
33
+ });
35
34
 
36
- describe('loadConfig', () => {
37
- it('config not set for template', async () => {
38
- const res = InitTemplate.loadConfig({config:{get(){return false;}}});
39
- expect(res).to.be.deep.equal({
40
- views: 'views',
41
- engine: 'pug'
35
+ describe("loadConfig", () => {
36
+ it("config not set for template", async () => {
37
+ const res = InitTemplate.loadConfig({
38
+ config: {
39
+ get() {
40
+ return false;
41
+ },
42
+ },
43
+ });
44
+ expect(res).to.be.deep.equal({
45
+ views: "views",
46
+ engine: "pug",
47
+ });
48
+ });
42
49
  });
43
- });
44
50
  });
45
- });
46
51
  };