repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-hybrid...
[poolifier.git]
/
examples
/
typescript
/
http-server-pool
/
fastify-hybrid
/
src
/
fastify-worker.ts
diff --git
a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
index 89fc333872ef1fea7603ec58290af8e191f10d49..0f4f6370b4c5249a2dfc8f2b4169d0245bbdda68 100644
(file)
--- a/
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
+++ b/
examples/typescript/http-server-pool/fastify-hybrid/src/fastify-worker.ts
@@
-13,26
+13,30
@@
ClusterWorkerResponse
private static readonly startFastify = async (
workerData?: ClusterWorkerData
): Promise<ClusterWorkerResponse> => {
private static readonly startFastify = async (
workerData?: ClusterWorkerData
): Promise<ClusterWorkerResponse> => {
- const { port } = workerData as ClusterWorkerData
+ const { port, ...fastifyPoolifierOptions } = workerData!
+
FastifyWorker.fastify = Fastify({
logger: true
})
FastifyWorker.fastify = Fastify({
logger: true
})
- await FastifyWorker.fastify.register(fastifyPoolifier, workerData)
+ await FastifyWorker.fastify.register(
+ fastifyPoolifier,
+ fastifyPoolifierOptions
+ )
- FastifyWorker.fastify.all('/api/echo', async
(request)
=> {
+ FastifyWorker.fastify.all('/api/echo', async
request
=> {
return (
return (
- await FastifyWorker.fastify.execute({
body
: request.body }, 'echo')
- ).
body
+ await FastifyWorker.fastify.execute({
data
: request.body }, 'echo')
+ ).
data
})
FastifyWorker.fastify.get<{
Params: { number: number }
})
FastifyWorker.fastify.get<{
Params: { number: number }
- }>('/api/factorial/:number', async
(request)
=> {
+ }>('/api/factorial/:number', async
request
=> {
const { number } = request.params
return (
const { number } = request.params
return (
- await FastifyWorker.fastify.execute({
body
: { number } }, 'factorial')
- ).
body
+ await FastifyWorker.fastify.execute({
data
: { number } }, 'factorial')
+ ).
data
})
await FastifyWorker.fastify.listen({ port })
})
await FastifyWorker.fastify.listen({ port })
@@
-43,7
+47,12
@@
ClusterWorkerResponse
}
public constructor () {
}
public constructor () {
- super(FastifyWorker.startFastify)
+ super(FastifyWorker.startFastify, {
+ killHandler: async () => {
+ await FastifyWorker.fastify.pool.destroy()
+ await FastifyWorker.fastify.close()
+ }
+ })
}
}
}
}