configurapi 1.7.0 → 1.9.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 +28 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configurapi",
3
- "version": "1.7.0",
3
+ "version": "1.9.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
@@ -82,15 +82,41 @@ module.exports = class Service extends events.EventEmitter
82
82
 
83
83
  this.emit(LogLevel.Trace, `configurapi - - Registerd ${route.name} route.`);
84
84
  });
85
+ }
85
86
 
86
- this.onStartPromise = this._handleEvent('on_start');
87
+ initDone;
88
+ async init()
89
+ {
90
+ this.onStartPromise ??= this._handleEvent('on_start');
91
+ await this.onStartPromise;
92
+ this.initDone = true;
87
93
  }
88
94
 
89
95
  async process(event)
90
96
  {
97
+ if (!this.initDone)
98
+ {
99
+ await this.init();
100
+ }
101
+
91
102
  if (!this.isReady)
92
103
  {
93
- await this.onStartPromise
104
+ try
105
+ {
106
+ await this._handleEvent('on_first_request', event);
107
+ }
108
+ catch(error)
109
+ {
110
+ try
111
+ {
112
+ await this._handleError(event, error);
113
+ }
114
+ finally
115
+ {
116
+ throw error;
117
+ }
118
+ }
119
+
94
120
  this.isReady = true;
95
121
  }
96
122