@nitra/fastify 1.6.1 → 1.7.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.
- package/package.json +4 -4
- package/src/index.js +13 -6
- package/src/pubsub.js +7 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitra/fastify",
|
|
3
3
|
"description": "Fastify helper",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"files": [
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"homepage": "https://github.com/nitra/fastify",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@fastify/sensible": "^5.
|
|
27
|
-
"@nitra/bunyan": "^2.0.
|
|
28
|
-
"fastify": "^4.
|
|
26
|
+
"@fastify/sensible": "^5.6.0",
|
|
27
|
+
"@nitra/bunyan": "^2.0.3",
|
|
28
|
+
"fastify": "^4.27.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fastify from 'fastify'
|
|
2
1
|
import fastifySensible from '@fastify/sensible'
|
|
3
2
|
import getLogger from '@nitra/bunyan/trace'
|
|
4
|
-
import
|
|
3
|
+
import fastify from 'fastify'
|
|
4
|
+
import { env, exit } from 'node:process'
|
|
5
5
|
|
|
6
6
|
const port = Number(env.PORT) || 8080
|
|
7
7
|
|
|
@@ -34,18 +34,25 @@ app.addHook('preHandler', (req, reply, done) => {
|
|
|
34
34
|
|
|
35
35
|
done()
|
|
36
36
|
})
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
//
|
|
38
|
+
/**
|
|
39
|
+
* Запускаємо сервер
|
|
40
|
+
*/
|
|
39
41
|
export function listen() {
|
|
40
42
|
app
|
|
41
43
|
.listen({ port, host: '0.0.0.0' })
|
|
42
44
|
.then(address => console.log(`🚀 Server ready at ${address}`))
|
|
43
|
-
.catch(
|
|
44
|
-
console.error('Error starting server:',
|
|
45
|
+
.catch(error => {
|
|
46
|
+
console.error('Error starting server:', error)
|
|
45
47
|
exit(1)
|
|
46
48
|
})
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param req
|
|
54
|
+
* @param reply
|
|
55
|
+
*/
|
|
49
56
|
function setHeaders(req, reply) {
|
|
50
57
|
let host = env.ORIGIN || req.headers.origin || req.headers.referer
|
|
51
58
|
if (!host) {
|
package/src/pubsub.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import fastify from 'fastify'
|
|
2
1
|
import getLogger from '@nitra/bunyan/trace'
|
|
3
|
-
import
|
|
2
|
+
import fastify from 'fastify'
|
|
3
|
+
import { env, exit } from 'node:process'
|
|
4
4
|
|
|
5
5
|
const port = Number(env.PORT) || 8080
|
|
6
6
|
|
|
@@ -15,13 +15,15 @@ app.addHook('preHandler', (req, _, done) => {
|
|
|
15
15
|
done()
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Запускаємо сервер
|
|
20
|
+
*/
|
|
19
21
|
export function listen() {
|
|
20
22
|
app
|
|
21
23
|
.listen({ port, host: '0.0.0.0' })
|
|
22
24
|
.then(address => console.log(`🚀 PubSub Consumer ready at ${address}`))
|
|
23
|
-
.catch(
|
|
24
|
-
console.error('Error starting server:',
|
|
25
|
+
.catch(error => {
|
|
26
|
+
console.error('Error starting server:', error)
|
|
25
27
|
exit(1)
|
|
26
28
|
})
|
|
27
29
|
}
|