@athenna/http 1.7.3 → 1.7.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": "@athenna/http",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
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.6",
57
+ "@athenna/artisan": "1.5.7",
58
58
  "@athenna/config": "1.1.8",
59
- "@athenna/ioc": "1.2.7",
60
- "@athenna/logger": "1.3.4",
59
+ "@athenna/ioc": "1.2.8",
60
+ "@athenna/logger": "1.3.5",
61
61
  "@athenna/common": "1.0.0",
62
62
  "fastify": "3.27.4",
63
63
  "fastify-cors": "6.0.3",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/artisan
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @athenna/logger
2
+ * @athenna/http
3
3
  *
4
4
  * (c) João Lenon <lenon@athenna.io>
5
5
  *
@@ -1,3 +1,12 @@
1
+ /**
2
+ * @athenna/http
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
1
10
  import { Log } from '@athenna/logger'
2
11
  import { Config } from '@athenna/config'
3
12
  import { Exception, String } from '@athenna/common'
@@ -1,3 +1,12 @@
1
+ /**
2
+ * @athenna/http
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
1
10
  import { join } from 'node:path'
2
11
  import { Folder, Module } from '@athenna/common'
3
12
 
@@ -1,3 +1,12 @@
1
+ /**
2
+ * @athenna/http
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
1
10
  import { Log } from '@athenna/logger'
2
11
  import { Config } from '@athenna/config'
3
12
  import { Module, Path, Uuid } from '@athenna/common'
@@ -19,4 +19,19 @@ export class HttpServerProvider extends ServiceProvider {
19
19
  register() {
20
20
  this.container.instance('Athenna/Core/HttpServer', new Http())
21
21
  }
22
+
23
+ /**
24
+ * Shutdown any application services.
25
+ *
26
+ * @return {void|Promise<void>}
27
+ */
28
+ async shutdown() {
29
+ const Server = this.container.use('Athenna/Core/HttpServer')
30
+
31
+ if (!Server) {
32
+ return
33
+ }
34
+
35
+ await Server.close()
36
+ }
22
37
  }
@@ -1,3 +1,12 @@
1
+ /**
2
+ * @athenna/http
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
1
10
  import { Is } from '@athenna/common'
2
11
 
3
12
  /**
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