configurapi 1.6.10 → 1.8.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/service.js +23 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configurapi",
3
- "version": "1.6.10",
3
+ "version": "1.8.0",
4
4
  "description": "A configurable API framework",
5
5
  "main": "src/configurapi.js",
6
6
  "types": "src/configurapi.d.ts",
package/src/service.js CHANGED
@@ -83,11 +83,33 @@ module.exports = class Service extends events.EventEmitter
83
83
  this.emit(LogLevel.Trace, `configurapi - - Registerd ${route.name} route.`);
84
84
  });
85
85
 
86
- this._handleEvent('on_start');
86
+ this.onStartPromise = this._handleEvent('on_start');
87
87
  }
88
88
 
89
89
  async process(event)
90
90
  {
91
+ if (!this.isReady)
92
+ {
93
+ try
94
+ {
95
+ await this.onStartPromise
96
+ await this._handleEvent('on_first_request', event);
97
+ }
98
+ catch(error)
99
+ {
100
+ try
101
+ {
102
+ await this._handleError(event, error);
103
+ }
104
+ finally
105
+ {
106
+ throw error;
107
+ }
108
+ }
109
+
110
+ this.isReady = true;
111
+ }
112
+
91
113
  let watch = new Stopwatch();
92
114
 
93
115
  try