Skip to content

Commit

Permalink
Merge pull request #677 from magieno/update-cli-to-use-data-mapper
Browse files Browse the repository at this point in the history
- Added more logging.
  • Loading branch information
etiennenoel authored Mar 9, 2024
2 parents af61c17 + e3572d7 commit 7d94dc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/http/src/commands/file-server.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class FileServerCommand implements CommandInterface<FileServerCommandOpti
async run(args: FileServerCommandOptions): Promise<ExitCodeEnum | number> {
await this.fileHttpServer.start(args.directory ?? "./", args.port, args.address, (port, address) => {
this.consoleManager.writeLine(`Pristine HTTP File server listening on: '${address}:${port}'`);
}, (req) => {
this.consoleManager.writeLine(`Request received: ${req.url}`);
});

return ExitCodeEnum.Success;
Expand Down
4 changes: 3 additions & 1 deletion packages/http/src/servers/file.http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FileHttpServer {
return 0;
}

async start(directory: string, port?: number, address?: string, listeningCallback?: (port?: number, address?: string) => void) {
async start(directory: string, port?: number, address?: string, listeningCallback?: (port?: number, address?: string) => void, requestCallback?:(req: IncomingMessage) => void) {
port = port ?? this.getPort();
address = address ?? this.address;

Expand All @@ -36,6 +36,8 @@ export class FileHttpServer {
return;
}

requestCallback?.(req);

this.logHandler.info("Request received: " + req.url, {req, directory, port, address});

// parse URL
Expand Down

0 comments on commit 7d94dc0

Please sign in to comment.