orator 3.0.7 → 3.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orator",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "description": "Unopinionated restful web API server container",
5
5
  "main": "source/Orator.js",
6
6
  "scripts": {
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "browserify": "^17.0.0",
52
52
  "chai": "4.3.7",
53
- "fable": "^3.0.7",
53
+ "fable": "^3.0.11",
54
54
  "gulp": "^4.0.2",
55
55
  "gulp-babel": "^8.0.0",
56
56
  "gulp-sourcemaps": "^3.0.0",
@@ -6,6 +6,8 @@ class OratorServiceServerBase
6
6
 
7
7
  this.log = pOrator.log;
8
8
 
9
+ this.ServiceServerType = 'Base';
10
+
9
11
  this.Name = this.orator.settings.Product;
10
12
  this.URL = 'BASE_SERVICE_SERVER';
11
13
  this.Port = this.orator.settings.ServicePort;
@@ -34,17 +36,19 @@ class OratorServiceServerBase
34
36
  * End of Service Lifecycle Functions
35
37
  */
36
38
 
37
- use(fHandlerFunction)
39
+ /*
40
+ * Content parsing functions
41
+ *************************************************************************/
42
+ bodyParser(pOptions)
38
43
  {
39
- if (typeof(fHandlerFunction) != 'function')
40
- {
41
- this.log.error(`Orator USE global handler mapping failed -- parameter was expected to be a function with prototype function(Request, Response, Next) but type was ${typeof(fHandlerFunction)} instead of a string.`)
42
- return false;
43
- }
44
-
45
- return true;
44
+ return (pRequest, pResponse, fNext) =>
45
+ {
46
+ fNext();
47
+ };
46
48
  }
47
-
49
+ /*************************************************************************
50
+ * End of Service Lifecycle Functions
51
+ */
48
52
 
49
53
  /*
50
54
  * Service Route Creation Functions
@@ -68,6 +72,21 @@ class OratorServiceServerBase
68
72
 
69
73
  * This pattern and calling super is totally optional, obviously.
70
74
  *************************************************************************/
75
+ use(fHandlerFunction)
76
+ {
77
+ if (typeof(fHandlerFunction) != 'function')
78
+ {
79
+ this.log.error(`Orator USE global handler mapping failed -- parameter was expected to be a function with prototype function(Request, Response, Next) but type was ${typeof(fHandlerFunction)} instead of a string.`)
80
+ return false;
81
+ }
82
+
83
+ return true;
84
+ }
85
+
86
+ doGet(pRoute, ...fRouteProcessingFunctions)
87
+ {
88
+ return true;
89
+ }
71
90
  get(pRoute, ...fRouteProcessingFunctions)
72
91
  {
73
92
  if (typeof(pRoute) != 'string')
@@ -75,10 +94,17 @@ class OratorServiceServerBase
75
94
  this.log.error(`Orator GET Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
76
95
  return false;
77
96
  }
97
+ return this.doGet(pRoute, ...fRouteProcessingFunctions);
98
+ }
99
+ getWithBodyParser(pRoute, ...fRouteProcessingFunctions)
100
+ {
101
+ return this.get(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
102
+ }
78
103
 
104
+ doPut(pRoute, ...fRouteProcessingFunctions)
105
+ {
79
106
  return true;
80
107
  }
81
-
82
108
  put(pRoute, ...fRouteProcessingFunctions)
83
109
  {
84
110
  if (typeof(pRoute) != 'string')
@@ -86,10 +112,17 @@ class OratorServiceServerBase
86
112
  this.log.error(`Orator PUT Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
87
113
  return false;
88
114
  }
115
+ return this.doPut(pRoute, ...fRouteProcessingFunctions);
116
+ }
117
+ putWithBodyParser(pRoute, ...fRouteProcessingFunctions)
118
+ {
119
+ return this.put(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
120
+ }
89
121
 
122
+ doPost(pRoute, ...fRouteProcessingFunctions)
123
+ {
90
124
  return true;
91
125
  }
92
-
93
126
  post(pRoute, ...fRouteProcessingFunctions)
94
127
  {
95
128
  if (typeof(pRoute) != 'string')
@@ -100,7 +133,15 @@ class OratorServiceServerBase
100
133
 
101
134
  return true;
102
135
  }
136
+ postWithBodyParser(pRoute, ...fRouteProcessingFunctions)
137
+ {
138
+ return this.post(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
139
+ }
103
140
 
141
+ doDel(pRoute, ...fRouteProcessingFunctions)
142
+ {
143
+ return true;
144
+ }
104
145
  del(pRoute, ...fRouteProcessingFunctions)
105
146
  {
106
147
  if (typeof(pRoute) != 'string')
@@ -111,6 +152,10 @@ class OratorServiceServerBase
111
152
 
112
153
  return true;
113
154
  }
155
+ delWithBodyParser(pRoute, ...fRouteProcessingFunctions)
156
+ {
157
+ return this.del(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
158
+ }
114
159
 
115
160
  patch(pRoute, ...fRouteProcessingFunctions)
116
161
  {
@@ -122,6 +167,11 @@ class OratorServiceServerBase
122
167
 
123
168
  return true;
124
169
  }
170
+ patchWithBodyParser(pRoute, ...fRouteProcessingFunctions)
171
+ {
172
+ return this.patch(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
173
+ }
174
+
125
175
 
126
176
  opts(pRoute, ...fRouteProcessingFunctions)
127
177
  {
@@ -133,6 +183,11 @@ class OratorServiceServerBase
133
183
 
134
184
  return true;
135
185
  }
186
+ optsWithBodyParser(pRoute, ...fRouteProcessingFunctions)
187
+ {
188
+ return this.opts(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
189
+ }
190
+
136
191
 
137
192
  head(pRoute, ...fRouteProcessingFunctions)
138
193
  {
@@ -144,6 +199,10 @@ class OratorServiceServerBase
144
199
 
145
200
  return true;
146
201
  }
202
+ headWithBodyParser(pRoute, ...fRouteProcessingFunctions)
203
+ {
204
+ return this.head(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
205
+ }
147
206
  /*************************************************************************
148
207
  * End of Service Route Creation Functions
149
208
  */
@@ -21,6 +21,8 @@ class OratorServiceServerIPC extends libOratorServiceServerBase
21
21
  this.router = libFindMyWay(this.routerOptions);
22
22
  this.router.addConstraintStrategy(libOratorServiceServerIPCCustomConstrainer);
23
23
 
24
+ this.ServiceServerType = 'IPC';
25
+
24
26
  this.URL = 'IPC';
25
27
 
26
28
  this.preBehaviorFunctions = [];
@@ -163,6 +165,8 @@ class OratorServiceServerIPC extends libOratorServiceServerBase
163
165
  return true;
164
166
  }
165
167
 
168
+ // This is the virtualized "body parser"
169
+
166
170
  get(pRoute, ...fRouteProcessingFunctions)
167
171
  {
168
172
  if (!super.get(pRoute, ...fRouteProcessingFunctions))
@@ -173,6 +177,10 @@ class OratorServiceServerIPC extends libOratorServiceServerBase
173
177
 
174
178
  return this.addRouteProcessor('GET', pRoute, Array.from(fRouteProcessingFunctions));
175
179
  }
180
+ getWithBodyParser(pRoute, ...fRouteProcessingFunctions)
181
+ {
182
+ return this.get(pRoute, fS)
183
+ }
176
184
 
177
185
  put(pRoute, ...fRouteProcessingFunctions)
178
186
  {
@@ -40,7 +40,12 @@ suite
40
40
  Expect(tmpOrator).to.be.an('object', 'Orator should initialize as an object directly from the require statement.');
41
41
  Expect(tmpOrator.startService).to.be.an('function');
42
42
  Expect(tmpOrator.settings).to.be.an('object');
43
- fDone();
43
+ tmpOrator.initializeServiceServer(
44
+ (pError)=>
45
+ {
46
+ Expect(tmpOrator.serviceServer.ServiceServerType).to.equal('IPC', 'The default service server provider should be IPC.');
47
+ fDone();
48
+ });
44
49
  }
45
50
  );
46
51