diff --git a/src/lib/middleware/framework-services/express.ts b/src/lib/middleware/framework-services/express.ts index 46f48e3..8d29414 100644 --- a/src/lib/middleware/framework-services/express.ts +++ b/src/lib/middleware/framework-services/express.ts @@ -2,7 +2,7 @@ import { FrameworkService } from "../interfaces"; export default class ExpressService implements FrameworkService { - getReqHeaderField(req: any, fieldName: string): string { + getReqHeaderField(req: any, fieldName: string): string | undefined { return req.header(fieldName); } @@ -30,7 +30,7 @@ export default class ExpressService implements FrameworkService { return value } - getResHeaderField(res: any, fieldName: string): string { + getResHeaderField(res: any, fieldName: string): string | undefined { return res.get(fieldName); } diff --git a/src/lib/middleware/framework-services/fastify.ts b/src/lib/middleware/framework-services/fastify.ts index 426780a..1f5ac40 100644 --- a/src/lib/middleware/framework-services/fastify.ts +++ b/src/lib/middleware/framework-services/fastify.ts @@ -2,8 +2,8 @@ import { FrameworkService } from "../interfaces"; export default class FastifyService implements FrameworkService { - getReqHeaderField(req: any, fieldName: string): string { - return req.headers[fieldName] ? req.headers[fieldName] : "" + getReqHeaderField(req: any, fieldName: string): string | undefined { + return req.headers[fieldName] } getReqField(req: any, fieldName: string): any { @@ -31,8 +31,7 @@ export default class FastifyService implements FrameworkService { } getResHeaderField(res: any, fieldName: string): string { - let value = res.getHeader(fieldName) - return value ? value : ""; + return res.getHeader(fieldName) } getResField(res: any, fieldName: string): any { diff --git a/src/lib/middleware/framework-services/plainhttp.ts b/src/lib/middleware/framework-services/plainhttp.ts index 0266d23..00abf2e 100644 --- a/src/lib/middleware/framework-services/plainhttp.ts +++ b/src/lib/middleware/framework-services/plainhttp.ts @@ -31,7 +31,7 @@ export default class HttpService implements FrameworkService { } getResHeaderField(res: any, fieldName: string): string { - return res.getHeader ? res.getHeader(fieldName) : ""; + return res.getHeader ? res.getHeader(fieldName) : undefined; } getResField(res: any, fieldName: string): any { diff --git a/src/lib/middleware/framework-services/restify.ts b/src/lib/middleware/framework-services/restify.ts index 8855668..543a1bd 100644 --- a/src/lib/middleware/framework-services/restify.ts +++ b/src/lib/middleware/framework-services/restify.ts @@ -31,7 +31,7 @@ export default class RestifyService implements FrameworkService { } getResHeaderField(res: any, fieldName: string): string { - return res.get ? res.get(fieldName) : ""; + return res.get ? res.get(fieldName) : undefined; } getResField(res: any, fieldName: string): any { diff --git a/src/lib/middleware/interfaces.ts b/src/lib/middleware/interfaces.ts index 53b9533..80017c4 100644 --- a/src/lib/middleware/interfaces.ts +++ b/src/lib/middleware/interfaces.ts @@ -1,7 +1,7 @@ export interface FrameworkService { - getReqHeaderField(req: any, fieldName: string): string; + getReqHeaderField(req: any, fieldName: string): string | undefined; getReqField(req: any, fieldName: string): string | number | boolean | undefined; - getResHeaderField(req: any, fieldName: string): string; + getResHeaderField(req: any, fieldName: string): string | undefined; getResField(req: any, fieldName: string): string | number | boolean | undefined; onResFinish(res: any, handler: () => void): undefined; } diff --git a/src/lib/middleware/requestAccessor.ts b/src/lib/middleware/requestAccessor.ts index 2d17d16..2d6c044 100644 --- a/src/lib/middleware/requestAccessor.ts +++ b/src/lib/middleware/requestAccessor.ts @@ -16,7 +16,7 @@ export default class RequestAccessor { return RequestAccessor.instance; } - getHeaderField(req: any, fieldName: string): string { + getHeaderField(req: any, fieldName: string): string | undefined { return this.frameworkService.getReqHeaderField(req, fieldName); } diff --git a/src/lib/middleware/responseAccessor.ts b/src/lib/middleware/responseAccessor.ts index d1a3172..425eb0e 100644 --- a/src/lib/middleware/responseAccessor.ts +++ b/src/lib/middleware/responseAccessor.ts @@ -16,7 +16,7 @@ export default class ResponseAccessor { return ResponseAccessor.instance; } - getHeaderField(res: any, fieldName: string): string { + getHeaderField(res: any, fieldName: string): string | undefined { return this.frameworkService.getResHeaderField(res, fieldName); }