mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
RC.8 fixes
This commit is contained in:
@@ -16,13 +16,10 @@ export class MiddlewareBuilder {
|
||||
resolveParams = data;
|
||||
return configProxy as MiddlewareConfigProxy;
|
||||
},
|
||||
forRoutes: (routes) => {
|
||||
if (isUndefined(routes)) {
|
||||
throw new InvalidMiddlewareConfigurationException();
|
||||
}
|
||||
forRoutes: (...routes) => {
|
||||
const configuration = {
|
||||
middlewares: this.bindValuesToResolve(metatypes, resolveParams),
|
||||
forRoutes: [].concat(routes)
|
||||
forRoutes: routes
|
||||
};
|
||||
this.middlewaresCollection.add(<MiddlewareConfiguration>configuration);
|
||||
return this;
|
||||
@@ -62,5 +59,5 @@ export class MiddlewareBuilder {
|
||||
|
||||
export interface MiddlewareConfigProxy {
|
||||
with: (...data) => MiddlewareConfigProxy;
|
||||
forRoutes: (routes) => MiddlewareBuilder;
|
||||
forRoutes: (...routes) => MiddlewareBuilder;
|
||||
}
|
||||
@@ -22,17 +22,12 @@ describe('MiddlewareBuilder', () => {
|
||||
});
|
||||
describe('when "forRoutes()" called', () => {
|
||||
class Test {}
|
||||
it('should throws "InvalidMiddlewareConfigurationException" when passed argument is undefined', () => {
|
||||
expect(() => configProxy.forRoutes()).to.throws(
|
||||
InvalidMiddlewareConfigurationException
|
||||
);
|
||||
});
|
||||
it('should store configuration passed as argument', () => {
|
||||
configProxy.forRoutes(Test);
|
||||
configProxy.forRoutes(Test, 'test');
|
||||
|
||||
expect(builder.build()).to.deep.equal([{
|
||||
middlewares: [],
|
||||
forRoutes: [ Test ]
|
||||
forRoutes: [ Test, 'test' ]
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user