orator 3.0.6 → 3.0.7

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.6",
3
+ "version": "3.0.7",
4
4
  "description": "Unopinionated restful web API server container",
5
5
  "main": "source/Orator.js",
6
6
  "scripts": {
@@ -50,6 +50,7 @@
50
50
  "devDependencies": {
51
51
  "browserify": "^17.0.0",
52
52
  "chai": "4.3.7",
53
+ "fable": "^3.0.7",
53
54
  "gulp": "^4.0.2",
54
55
  "gulp-babel": "^8.0.0",
55
56
  "gulp-sourcemaps": "^3.0.0",
@@ -63,8 +64,6 @@
63
64
  },
64
65
  "dependencies": {
65
66
  "async": "^3.2.4",
66
- "fable": "^3.0.7",
67
- "find-my-way": "^7.5.0",
68
- "orator-serviceserver": "^1.0.2"
67
+ "find-my-way": "^7.5.0"
69
68
  }
70
69
  }
@@ -0,0 +1,160 @@
1
+ class OratorServiceServerBase
2
+ {
3
+ constructor(pOrator)
4
+ {
5
+ this.orator = pOrator;
6
+
7
+ this.log = pOrator.log;
8
+
9
+ this.Name = this.orator.settings.Product;
10
+ this.URL = 'BASE_SERVICE_SERVER';
11
+ this.Port = this.orator.settings.ServicePort;
12
+
13
+ this.Active = false;
14
+ }
15
+
16
+ /*
17
+ * Service Lifecycle Functions
18
+ *************************************************************************/
19
+ listen(pPort, fCallback)
20
+ {
21
+ // Sometimes, listen does not listen on network calls.
22
+ this.Active = true;
23
+
24
+ return fCallback();
25
+ }
26
+
27
+ close(fCallback)
28
+ {
29
+ this.Active = false;
30
+
31
+ return fCallback();
32
+ }
33
+ /*************************************************************************
34
+ * End of Service Lifecycle Functions
35
+ */
36
+
37
+ use(fHandlerFunction)
38
+ {
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;
46
+ }
47
+
48
+
49
+ /*
50
+ * Service Route Creation Functions
51
+ *
52
+ * These base functions provide basic validation for the routes, but don't actually
53
+ * do anything with them. The design intent here is to allow derived classes to call
54
+ * these functions to validate that they conform to expected standards.
55
+ *
56
+ * Something like:
57
+
58
+ get (pRoute, ...fRouteProcessingFunctions)
59
+ {
60
+ if (!super.get(pRoute, ...fRouteProcessingFunctions))
61
+ {
62
+ this.log.error(`Restify provider failed to map route [${pRoute}]!`);
63
+ return false;
64
+ }
65
+
66
+ //...now we can do our actual get mapping function!....
67
+ }
68
+
69
+ * This pattern and calling super is totally optional, obviously.
70
+ *************************************************************************/
71
+ get(pRoute, ...fRouteProcessingFunctions)
72
+ {
73
+ if (typeof(pRoute) != 'string')
74
+ {
75
+ this.log.error(`Orator GET Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
76
+ return false;
77
+ }
78
+
79
+ return true;
80
+ }
81
+
82
+ put(pRoute, ...fRouteProcessingFunctions)
83
+ {
84
+ if (typeof(pRoute) != 'string')
85
+ {
86
+ this.log.error(`Orator PUT Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
87
+ return false;
88
+ }
89
+
90
+ return true;
91
+ }
92
+
93
+ post(pRoute, ...fRouteProcessingFunctions)
94
+ {
95
+ if (typeof(pRoute) != 'string')
96
+ {
97
+ this.log.error(`Orator POST Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
98
+ return false;
99
+ }
100
+
101
+ return true;
102
+ }
103
+
104
+ del(pRoute, ...fRouteProcessingFunctions)
105
+ {
106
+ if (typeof(pRoute) != 'string')
107
+ {
108
+ this.log.error(`Orator DEL Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
109
+ return false;
110
+ }
111
+
112
+ return true;
113
+ }
114
+
115
+ patch(pRoute, ...fRouteProcessingFunctions)
116
+ {
117
+ if (typeof(pRoute) != 'string')
118
+ {
119
+ this.log.error(`Orator PATCH Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
120
+ return false;
121
+ }
122
+
123
+ return true;
124
+ }
125
+
126
+ opts(pRoute, ...fRouteProcessingFunctions)
127
+ {
128
+ if (typeof(pRoute) != 'string')
129
+ {
130
+ this.log.error(`Orator OPTS Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
131
+ return false;
132
+ }
133
+
134
+ return true;
135
+ }
136
+
137
+ head(pRoute, ...fRouteProcessingFunctions)
138
+ {
139
+ if (typeof(pRoute) != 'string')
140
+ {
141
+ this.log.error(`Orator HEAD Route mapping failed -- route parameter was ${typeof(pRoute)} instead of a string.`)
142
+ return false;
143
+ }
144
+
145
+ return true;
146
+ }
147
+ /*************************************************************************
148
+ * End of Service Route Creation Functions
149
+ */
150
+
151
+ // Programmatically invoke a route
152
+ invoke(pMethod, pRoute, pData, fCallback)
153
+ {
154
+ // The base class version of this does nothing
155
+ this.log.debug(`Orator invoke called for route [${pRoute}] and landed on the base class; the service provider likely does not implement programmatic invoke capabilities.`, pData);
156
+ return false;
157
+ }
158
+ }
159
+
160
+ module.exports = OratorServiceServerBase;
@@ -1,4 +1,4 @@
1
- const libOratorServiceServerBase = require('orator-serviceserver');
1
+ const libOratorServiceServerBase = require('./Orator-ServiceServer-Base.js');
2
2
 
3
3
  // A synthesized response object, for simple IPC.
4
4
  const libOratorServiceServerIPCSynthesizedResponse = require('./Orator-ServiceServer-IPC-SynthesizedResponse.js');
package/source/Orator.js CHANGED
@@ -7,8 +7,6 @@
7
7
  * @module Orator Service
8
8
  */
9
9
 
10
- const libFable = require('fable');
11
-
12
10
  const defaultOratorConfiguration = require('./Orator-Default-Configuration.js');
13
11
  const defaultOratorServiceServers = require('./Orator-Default-ServiceServers-Node.js');
14
12
 
@@ -16,20 +14,8 @@ class Orator
16
14
  {
17
15
  constructor(pFable, pServiceProvider)
18
16
  {
19
- // Need to figure out if pFable is a Fable object or a Settings object or neither
20
- if ((typeof(pFable) === 'object') && (pFable instanceof libFable))
21
- {
22
- // We were passed a fully operational fable -- use this
23
- this.fable = pFable;
24
- }
25
- else if (typeof(pFable) == 'object')
26
- {
27
- this.fable = new libFable(pFable);
28
- }
29
- else
30
- {
31
- this.fable = new libFable(defaultOratorConfiguration);
32
- }
17
+ // We were passed a fully operational fable -- use this
18
+ this.fable = pFable;
33
19
 
34
20
  // Carry core application requirements into the orator object for simplicity
35
21
  this.settings = this.fable.settings;
@@ -176,3 +162,4 @@ class Orator
176
162
  }
177
163
 
178
164
  module.exports = Orator;
165
+ module.exports.ServiceServerBase = require('./Orator-ServiceServer-Base.js');
@@ -14,14 +14,12 @@ const Assert = Chai.assert;
14
14
 
15
15
  //const libSuperTest = require('supertest');
16
16
  const libFable = require('fable');
17
- const _Fable = new libFable({Product:'Orator-BasicTests-Backplane'});
18
-
19
- const _MockSettings = (
20
- {
21
- Product: 'MockOratorAlternate',
22
- ProductVersion: '0.0.0',
23
- APIServerPort: 8099
24
- });
17
+ const _Fable = new libFable(
18
+ {
19
+ Product:'Orator-BasicTests-Backplane',
20
+ ProductVersion: '0.0.0',
21
+ APIServerPort: 8099
22
+ });
25
23
 
26
24
  suite
27
25
  (
@@ -38,7 +36,7 @@ suite
38
36
  'initialize should build a happy little object',
39
37
  (fDone) =>
40
38
  {
41
- let tmpOrator = new libOrator();
39
+ let tmpOrator = new libOrator(_Fable);
42
40
  Expect(tmpOrator).to.be.an('object', 'Orator should initialize as an object directly from the require statement.');
43
41
  Expect(tmpOrator.startService).to.be.an('function');
44
42
  Expect(tmpOrator.settings).to.be.an('object');
@@ -51,13 +49,17 @@ suite
51
49
  'orator should be able to initialize and start a service with no effort',
52
50
  (fDone) =>
53
51
  {
54
- let tmpOrator = new libOrator();
52
+ let tmpOrator = new libOrator(_Fable);
55
53
  // Start the service server
56
54
  tmpOrator.initializeServiceServer();
57
55
  // Start the service
58
56
  Expect(tmpOrator.serviceServer.Active).to.equal(false);
59
- tmpOrator.startService(fDone);
60
- Expect(tmpOrator.serviceServer.Active).to.equal(true);
57
+ tmpOrator.startService(
58
+ ()=>
59
+ {
60
+ Expect(tmpOrator.serviceServer.Active).to.equal(true);
61
+ fDone();
62
+ });
61
63
  }
62
64
  );
63
65
 
@@ -66,7 +68,7 @@ suite
66
68
  'ipc should be able to provide basic endpoint functionality',
67
69
  (fDone) =>
68
70
  {
69
- let tmpOrator = new libOrator();
71
+ let tmpOrator = new libOrator(_Fable);
70
72
  // Initialize the service server
71
73
  tmpOrator.initializeServiceServer();
72
74
  // Start the service
@@ -102,7 +104,7 @@ suite
102
104
  'ipc should be able to process any number of handler additions with the use function',
103
105
  (fDone) =>
104
106
  {
105
- let tmpOrator = new libOrator();
107
+ let tmpOrator = new libOrator(_Fable);
106
108
  // Initialize the service server
107
109
  tmpOrator.initializeServiceServer();
108
110
  // Start the service