retold-data-service 2.0.1 → 2.0.5

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": "retold-data-service",
3
- "version": "2.0.1",
3
+ "version": "2.0.5",
4
4
  "description": "Serve up a whole model!",
5
5
  "main": "source/Retold-Data-Service.js",
6
6
  "scripts": {
@@ -54,7 +54,7 @@
54
54
  "meadow": "^2.0.15",
55
55
  "meadow-connection-mysql": "^1.0.4",
56
56
  "meadow-endpoints": "^4.0.5",
57
- "orator": "^4.0.2",
58
- "orator-serviceserver-restify": "^2.0.2"
57
+ "orator": "^4.0.3",
58
+ "orator-serviceserver-restify": "^2.0.3"
59
59
  }
60
60
  }
@@ -47,7 +47,7 @@ class RetoldDataService extends libFableServiceProviderBase
47
47
  this.fable.serviceManager.instantiateServiceProvider('Orator', this.options);
48
48
 
49
49
  // TODO: This code will be much cleaner with meadow and meadow-endpoints as services
50
- this._Meadow = libMeadow.new(_Fable);
50
+ this._Meadow = libMeadow.new(pFable);
51
51
 
52
52
  // Create DAL objects for each table in the schema
53
53
  // These will be unnecessary when meadow and meadow-endpoints are full fledged fable services
@@ -92,32 +92,32 @@ class RetoldDataService extends libFableServiceProviderBase
92
92
  // Create DAL objects for each table in the schema
93
93
 
94
94
  // 1. Load full compiled schema of the model from stricture
95
- _Fable.log.info(`...loading full model stricture schema...`);
95
+ this.fable.log.info(`...loading full model stricture schema...`);
96
96
  this.fullModel = require (`${this.options.FullMeadowSchemaPath}${this.options.FullMeadowSchemaFilename}`);
97
- _Fable.log.info(`...full model stricture schema loaded.`);
97
+ this.fable.log.info(`...full model stricture schema loaded.`);
98
98
 
99
99
  // 2. Extract an array of each table in the schema
100
- _Fable.log.info(`...getting entity list...`);
100
+ this.fable.log.info(`...getting entity list...`);
101
101
  this.entityList = Object.keys(this.fullModel.Tables);
102
102
 
103
103
  // 3. Enumerate each entry in the compiled model and load a DAL for that table
104
- _Fable.log.info(`...initializing ${this.entityList.length} DAL objects and corresponding Meadow Endpoints...`);
104
+ this.fable.log.info(`...initializing ${this.entityList.length} DAL objects and corresponding Meadow Endpoints...`);
105
105
  for (let i = 0; i < this.entityList.length; i++)
106
106
  {
107
107
  // 4. Create the DAL for each entry (e.g. it would be at _DAL.Movie for the Movie entity)
108
108
  let tmpDALEntityName = this.entityList[i];
109
109
  let tmpDALPackageFile = `${this.options.DALMeadowSchemaPath}${this.options.DALMeadowSchemaPrefix}${tmpDALEntityName}${this.options.DALMeadowSchemaPostfix}.json`
110
- _Fable.log.info(`Initializing the ${tmpDALEntityName} DAL from [${tmpDALPackageFile}]...`);
110
+ this.fable.log.info(`Initializing the ${tmpDALEntityName} DAL from [${tmpDALPackageFile}]...`);
111
111
  this._DAL[tmpDALEntityName] = this._Meadow.loadFromPackage(tmpDALPackageFile);
112
112
  // 5. Tell this DAL object to use MySQL
113
- _Fable.log.info(`...defaulting the ${tmpDALEntityName} DAL to use MySQL`);
113
+ this.fable.log.info(`...defaulting the ${tmpDALEntityName} DAL to use MySQL`);
114
114
  this._DAL[tmpDALEntityName].setProvider('MySQL');
115
115
  // 6. Create a Meadow Endpoints class for this DAL
116
- _Fable.log.info(`...initializing the ${tmpDALEntityName} Meadow Endpoints to use MySQL`);
116
+ this.fable.log.info(`...initializing the ${tmpDALEntityName} Meadow Endpoints to use MySQL`);
117
117
  this._MeadowEndpoints[tmpDALEntityName] = libMeadowEndpoints.new(this._DAL[tmpDALEntityName]);
118
118
  // 8. Expose the meadow endpoints on Orator
119
- _Fable.log.info(`...mapping the ${tmpDALEntityName} Meadow Endpoints to Orator`);
120
- this._MeadowEndpoints[tmpDALEntityName].connectRoutes(this.fable.Orator.webServer);
119
+ this.fable.log.info(`...mapping the ${tmpDALEntityName} Meadow Endpoints to Orator`);
120
+ this._MeadowEndpoints[tmpDALEntityName].connectRoutes(this.fable.OratorServiceServer);
121
121
  }
122
122
 
123
123
  return fCallback();
@@ -137,7 +137,19 @@ class RetoldDataService extends libFableServiceProviderBase
137
137
 
138
138
  tmpAnticipate.anticipate(this.onBeforeInitialize.bind(this));
139
139
 
140
- tmpAnticipate.anticipate(this.fable.Orator.startWebServer.bind(this.fable.Orator));
140
+ tmpAnticipate.anticipate(
141
+ (fInitCallback) =>
142
+ {
143
+ if (this.options.AutoStartOrator)
144
+ {
145
+ this.fable.Orator.startWebServer(fInitCallback);
146
+ }
147
+ else
148
+ {
149
+ return fInitCallback();
150
+ }
151
+ });
152
+
141
153
  tmpAnticipate.anticipate(this.initializePersistenceEngine.bind(this));
142
154
 
143
155
  tmpAnticipate.anticipate(this.onInitialize.bind(this));
@@ -154,7 +166,7 @@ class RetoldDataService extends libFableServiceProviderBase
154
166
  this.log.error(`Error initializing Retold Data Service: ${pError}`);
155
167
  return fCallback(pError);
156
168
  }
157
-
169
+ this.fable.Orator.startWebServer.bind(this.fable.Orator);
158
170
  this.serviceInitialized = true;
159
171
  return fCallback();
160
172
  });
@@ -42,9 +42,7 @@ suite
42
42
  AutoStartOrator: true
43
43
  });
44
44
 
45
- tmpRetoldDataService.initializeService();
46
-
47
- return fDone();
45
+ tmpRetoldDataService.initializeService(()=>{return fDone()});
48
46
  }
49
47
  );
50
48
  }