refactor(core): `url` as not optional parameter
MODIFY
packages/core/src/http.interface.ts
packages/core/src/http.interface.ts
import * as http from 'http';
export interface HttpRequest extends http.IncomingMessage {
+ url: string;
body?: any;
params?: RouteParameters;
query?: QueryParameters;

MODIFY
packages/core/src/operators/matchPath/matchPath.operator.ts
packages/core/src/operators/matchPath/matchPath.operator.ts
@@ -24,12 +24,12 @@ export const matchPath = (path: string, opts: MatcherOpts = {}) => (source$: Obs
if (path === '*') { return true; }
const matcher = matcherFactory(req.matchers!, path, opts.suffix);
- const url = removeQueryParams(req.url!);
+ const url = removeQueryParams(req.url);
return pathToRegexp(matcher).test(url);
}),
tap(req => (req.params = urlParamsFactory(req, path))),
- tap(req => (req.query = queryParamsFactory(req.url!))),
+ tap(req => (req.query = queryParamsFactory(req.url))),
tap(req => opts.combiner && req.matchers!.push(path)),
tap(req => (req.matchPath = !opts.combiner ? true : false)),
);

MODIFY
packages/core/src/operators/matchPath/urlParams.factory.ts
packages/core/src/operators/matchPath/urlParams.factory.ts
@@ -2,12 +2,9 @@ import * as pathToRegexp from 'path-to-regexp';
import { HttpRequest, RouteParameters } from '../../http.interface';
import { matcherFactory, removeQueryParams } from './matcher.factory';
-export const urlParamsFactory = (
- req: HttpRequest,
- path: string
-): RouteParameters => {
+export const urlParamsFactory = (req: HttpRequest, path: string): RouteParameters => {
const match = matcherFactory(req.matchers!, path);
- const url = removeQueryParams(req.url!);
+ const url = removeQueryParams(req.url);
const params = pathToRegexp(match).exec(url);
const routes = pathToRegexp.parse(match);

MODIFY
packages/core/src/response/response.handler.ts
packages/core/src/response/response.handler.ts
@@ -6,7 +6,7 @@ import { headersFactory } from './responseHeaders.factory';
export const handleResponse = (res: HttpResponse) => (req: HttpRequest) => (effect: EffectResponse) => {
const status = effect.status || HttpStatus.OK;
- const headersFactoryWithData = headersFactory({ body: effect.body, path: req.url!, status });
+ const headersFactoryWithData = headersFactory({ body: effect.body, path: req.url, status });
const headers = headersFactoryWithData(effect.headers);
const bodyFactoryWithHeaders = bodyFactory(headers);

refactor(core): `url` as not optional parameter