1010import onFinished from 'on-finished'
1111import Middleware from '@poppinss/middleware'
1212import type { Logger } from '@adonisjs/logger'
13- import type { Emitter } from '@adonisjs/events'
1413import type { Encryption } from '@adonisjs/encryption'
1514import type { Server as HttpsServer } from 'node:https'
1615import type { Application } from '@adonisjs/application'
16+ import type { EmitterLike } from '@adonisjs/events/types'
1717import { ContainerResolver , moduleCaller , moduleImporter } from '@adonisjs/fold'
1818import type { ServerResponse , IncomingMessage , Server as HttpServer } from 'node:http'
1919
2020import type { LazyImport } from '../types/base.js'
2121import type { MiddlewareAsClass , ParsedGlobalMiddleware } from '../types/middleware.js'
2222import type {
2323 ServerConfig ,
24+ HttpServerEvents ,
2425 ServerErrorHandler ,
2526 ErrorHandlerAsAClass ,
2627 TestingMiddlewarePipeline ,
@@ -73,7 +74,7 @@ export class Server {
7374 /**
7475 * Emitter is required to notify when a request finishes
7576 */
76- #emitter: Emitter < any >
77+ #emitter: EmitterLike < HttpServerEvents >
7778
7879 /**
7980 * The application instance to be shared with the router
@@ -138,7 +139,7 @@ export class Server {
138139 constructor (
139140 app : Application < any > ,
140141 encryption : Encryption ,
141- emitter : Emitter < any > ,
142+ emitter : EmitterLike < HttpServerEvents > ,
142143 logger : Logger ,
143144 config : ServerConfig
144145 ) {
@@ -330,7 +331,7 @@ export class Server {
330331 /**
331332 * Setup for the "http:request_finished" event
332333 */
333- const hasRequestListener = this . #emitter. hasListeners ( 'http:request_finished ' )
334+ const hasRequestListener = this . #emitter. hasListeners ( 'http:request_completed ' )
334335 const startTime = hasRequestListener ? process . hrtime ( ) : null
335336
336337 /**
@@ -348,7 +349,7 @@ export class Server {
348349 */
349350 if ( startTime ) {
350351 onFinished ( res , ( ) => {
351- this . #emitter. emit ( 'http:request_finished ' , {
352+ this . #emitter. emit ( 'http:request_completed ' , {
352353 ctx : ctx ,
353354 duration : process . hrtime ( startTime ) ,
354355 } )
0 commit comments