fix(middleware-logger): fs.WriteStream -> WritableLike
MODIFY
packages/middleware-logger/src/logger.model.ts
packages/middleware-logger/src/logger.model.ts
-import { WriteStream } from 'fs';
import { HttpResponse, HttpRequest } from '@marblejs/core';
+export type WritableLike = {
+ write: (chunk: any) => void;
+}
+
export type LoggerCtx = {
req: HttpRequest;
res: HttpResponse;
@@ -8,7 +11,7 @@ export type LoggerCtx = {
export interface LoggerOptions {
silent?: boolean;
- stream?: WriteStream;
+ stream?: WritableLike;
filter?: (res: HttpResponse, req: HttpRequest) => boolean;
}

MODIFY
packages/middleware-logger/src/logger.util.ts
packages/middleware-logger/src/logger.util.ts
-import { WriteStream } from 'fs';
import { compose } from 'fp-ts/lib/function';
import { fromNullable } from 'fp-ts/lib/Option';
-import { LoggerOptions, LoggerCtx } from './logger.model';
+import { LoggerOptions, LoggerCtx, WritableLike } from './logger.model';
export const isNotSilent = (opts: LoggerOptions) => (_: LoggerCtx) =>
!opts.silent;
@@ -11,8 +10,8 @@ export const filterResponse = (opts: LoggerOptions) => (ctx: LoggerCtx) =>
.map(filter => filter(ctx.res, ctx.req))
.getOrElse(true);
-export const writeToStream = (stream: WriteStream, chunk: string) =>
- stream.write(`${chunk}\n\n`);
+export const writeToStream = (writable: WritableLike, chunk: string) =>
+ writable.write(`${chunk}\n\n`);
export const formatTime = (timeInMms: number) =>
timeInMms > 1000

fix(middleware-logger): fs.WriteStream -> WritableLike