fix(core): missing router middlewares
ADD
packages/core/src/+internal/utils/spec/any.util.spec.ts
+import { isNonNullable, isNullable } from '../any.util';
+
+test('#isNonNullable', () => {
+ expect(isNonNullable({})).toBe(true);
+ expect(isNonNullable(2)).toBe(true);
+ expect(isNonNullable('test')).toBe(true);
+ expect(isNonNullable('')).toBe(true);
+ expect(isNonNullable(false)).toBe(true);
+ expect(isNonNullable(null)).toBe(false);
+ expect(isNonNullable(undefined)).toBe(false);
+});
+
+test('#isNullable', () => {
+ expect(isNullable({})).toBe(false);
+ expect(isNullable(2)).toBe(false);
+ expect(isNullable('test')).toBe(false);
+ expect(isNullable('')).toBe(false);
+ expect(isNullable(false)).toBe(false);
+ expect(isNullable(null)).toBe(true);
+ expect(isNullable(undefined)).toBe(true);
+});

MODIFY
packages/core/src/router/router.factory.ts
packages/core/src/router/router.factory.ts
@@ -33,10 +33,8 @@ export const factorizeRouting = (
const method: RoutingMethod = {
effect: route.effect,
middleware: middlewares.length
- ? route.middleware
- ? combineMiddlewares(...middlewares, route.middleware)
- : combineMiddlewares(...middlewares)
- : undefined,
+ ? combineMiddlewares(...middlewares)
+ : route.middleware,
parameters,
};

MODIFY
packages/core/src/router/specs/router.factory.spec.ts
packages/core/src/router/specs/router.factory.spec.ts
@@ -22,7 +22,7 @@ describe('#factorizeRouting', () => {
const routeGroupNested: RouteEffectGroup = {
path: '/nested',
- effects: [{ path: '/', method: 'GET', effect: e5$ }],
+ effects: [{ path: '/', method: 'GET', effect: e5$, middlewares: m$ }],
middlewares: [m$],
};
@@ -30,11 +30,11 @@ describe('#factorizeRouting', () => {
path: '/:id',
effects: [
{ path: '/', method: 'GET', effect: e2$ },
- { path: '/', method: 'POST', effect: e3$ },
+ { path: '/', method: 'POST', effect: e3$, middlewares: m$ },
routeGroupNested,
{ path: '*', method: '*', effect: e4$ },
],
- middlewares: [m$],
+ middlewares: [m$, m$],
};
const routing: (RouteEffect | RouteEffectGroup)[] = [
@@ -51,7 +51,9 @@ describe('#factorizeRouting', () => {
{
regExp: /^(?:\/)?$/i,
path: '',
- methods: { GET: { effect: e1$, middleware: undefined, parameters: undefined } },
+ methods: {
+ GET: { effect: e1$, middleware: undefined, parameters: undefined },
+ },
},
{
regExp: /^\/([^\/]+?)(?:\/)?$/i,
@@ -64,12 +66,16 @@ describe('#factorizeRouting', () => {
{
regExp: /^\/([^\/]+?)\/nested(?:\/)?$/i,
path: '/:id/nested',
- methods: { GET: { middleware: m$, effect: e5$, parameters: ['id'] } },
+ methods: {
+ GET: { middleware: m$, effect: e5$, parameters: ['id'] },
+ },
},
{
regExp: /^\/([^\/]+?)\/(.*)(?:\/)?$/i,
path: '/:id/(.*)',
- methods: { '*': { middleware: m$, effect: e4$, parameters: ['id'] } },
+ methods: {
+ '*': { middleware: m$, effect: e4$, parameters: ['id'] },
+ },
},
] as Routing);
});

fix(core): missing router middlewares