@athenna/http 1.7.4 → 1.7.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 +4 -4
- package/src/Providers/HttpServerProvider.js +5 -1
- package/src/index.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/http",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7",
|
|
4
4
|
"description": "The Athenna Http server. Built on top of fastify.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "João Lenon <lenon@athenna.io>",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"#tests/*": "./tests/*.js"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@athenna/artisan": "1.5.
|
|
58
|
-
"@athenna/config": "1.1.
|
|
57
|
+
"@athenna/artisan": "1.5.8",
|
|
58
|
+
"@athenna/config": "1.1.9",
|
|
59
59
|
"@athenna/ioc": "1.2.8",
|
|
60
|
-
"@athenna/logger": "1.3.
|
|
60
|
+
"@athenna/logger": "1.3.6",
|
|
61
61
|
"@athenna/common": "1.0.0",
|
|
62
62
|
"fastify": "3.27.4",
|
|
63
63
|
"fastify-cors": "6.0.3",
|
|
@@ -26,7 +26,11 @@ export class HttpServerProvider extends ServiceProvider {
|
|
|
26
26
|
* @return {void|Promise<void>}
|
|
27
27
|
*/
|
|
28
28
|
async shutdown() {
|
|
29
|
-
const Server = this.container.
|
|
29
|
+
const Server = this.container.use('Athenna/Core/HttpServer')
|
|
30
|
+
|
|
31
|
+
if (!Server) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
30
34
|
|
|
31
35
|
await Server.close()
|
|
32
36
|
}
|
package/src/index.js
CHANGED
|
@@ -48,6 +48,13 @@ export class Http {
|
|
|
48
48
|
*/
|
|
49
49
|
#server
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Indicates if the http server is running or not.
|
|
53
|
+
*
|
|
54
|
+
* @type {boolean}
|
|
55
|
+
*/
|
|
56
|
+
#isListening
|
|
57
|
+
|
|
51
58
|
/**
|
|
52
59
|
* Creates a new instance of Http class.
|
|
53
60
|
*
|
|
@@ -55,6 +62,7 @@ export class Http {
|
|
|
55
62
|
*/
|
|
56
63
|
constructor() {
|
|
57
64
|
this.#server = fastify()
|
|
65
|
+
this.#isListening = false
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
/**
|
|
@@ -176,6 +184,8 @@ export class Http {
|
|
|
176
184
|
* @return {Promise<string>}
|
|
177
185
|
*/
|
|
178
186
|
async listen(port = 1335, host = '0.0.0.0') {
|
|
187
|
+
this.#isListening = true
|
|
188
|
+
|
|
179
189
|
return this.#server.listen(port, host)
|
|
180
190
|
}
|
|
181
191
|
|
|
@@ -185,6 +195,10 @@ export class Http {
|
|
|
185
195
|
* @return {Promise<void>}
|
|
186
196
|
*/
|
|
187
197
|
async close() {
|
|
198
|
+
if (!this.#isListening) {
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
|
|
188
202
|
return this.#server.close()
|
|
189
203
|
}
|
|
190
204
|
|