Skip to content

Commit

Permalink
samples(@nestjs) update sample applications
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Mar 25, 2018
1 parent e50ddf9 commit 91b4974
Show file tree
Hide file tree
Showing 177 changed files with 808 additions and 1,370 deletions.
1 change: 0 additions & 1 deletion integration/microservices/e2e/broadcast-nats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('NATS transport', () => {
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.NATS,
url: 'nats://localhost:4222'
});
app.connectMicroservice({
transport: Transport.NATS,
Expand Down
2 changes: 1 addition & 1 deletion integration/microservices/src/grpc/math.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ service Math {
}

message SumResult {
required int32 result = 1;
int32 result = 1;
}

message RequestSum {
Expand Down
144 changes: 6 additions & 138 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"author": "Kamil Mysliwiec",
"license": "MIT",
"dependencies": {
"@nestjs/common": "^4.0.0",
"@nestjs/core": "^4.0.0",
"@nestjs/microservices": "^4.0.0",
"@nestjs/testing": "^4.0.0",
"@nestjs/websockets": "^4.0.0",
"@nestjs/common": "^5.0.0",
"@nestjs/core": "^5.0.0",
"@nestjs/microservices": "^5.0.0",
"@nestjs/testing": "^5.0.0",
"@nestjs/websockets": "^5.0.0",
"axios": "^0.17.1",
"class-transformer": "^0.1.8",
"class-validator": "^0.8.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/decorators/core/component.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ export function mixin(mixinClass) {
Object.defineProperty(mixinClass, 'name', {
value: JSON.stringify(this.offset),
});
Component()(mixinClass);
Injectable()(mixinClass);
return mixinClass;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ import { EXCEPTION_FILTERS_METADATA } from '../../constants';
import { Logger } from '@nestjs/common';
import { ExceptionFilter } from '../../index';
import { extendArrayMetadata } from '../../utils/extend-metadata.util';
import { isFunction } from '../../utils/shared.utils';
import { validateEach } from '../../utils/validate-each.util';

const defineFiltersMetadata = (...filters: ExceptionFilter[]) => {
return (target: object, key?, descriptor?) => {
return (target: any, key?, descriptor?) => {
const isFilterValid = (filter) => isFunction(filter.catch);
if (descriptor) {
validateEach(target.constructor, filters, isFilterValid, '@UseFilters', 'filter');
extendArrayMetadata(
EXCEPTION_FILTERS_METADATA,
filters,
descriptor.value,
);
return descriptor;
}
validateEach(target, filters, isFilterValid, '@UseFilters', 'filter');
extendArrayMetadata(EXCEPTION_FILTERS_METADATA, filters, target);
return target;
};
Expand Down
6 changes: 5 additions & 1 deletion packages/common/decorators/core/use-guards.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { GUARDS_METADATA } from '../../constants';
import { extendArrayMetadata } from '../../utils/extend-metadata.util';
import { validateEach } from '../../utils/validate-each.util';
import { isFunction } from '../../utils/shared.utils';

/**
* Binds guards to the particular context.
Expand All @@ -12,11 +14,13 @@ import { extendArrayMetadata } from '../../utils/extend-metadata.util';
* @param {} ...guards (types)
*/
export function UseGuards(...guards: any[]) {
return (target: object, key?, descriptor?) => {
return (target: any, key?, descriptor?) => {
if (descriptor) {
validateEach(target.constructor, guards, isFunction, '@UseGuards', 'guard');
extendArrayMetadata(GUARDS_METADATA, guards, descriptor.value);
return descriptor;
}
validateEach(target, guards, isFunction, '@UseGuards', 'guard');
extendArrayMetadata(GUARDS_METADATA, guards, target);
return target;
};
Expand Down
18 changes: 17 additions & 1 deletion packages/common/decorators/core/use-interceptors.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { INTERCEPTORS_METADATA } from '../../constants';
import { extendArrayMetadata } from '../../utils/extend-metadata.util';
import { isFunction } from '../../utils/shared.utils';
import { validateEach } from '../../utils/validate-each.util';

/**
* Binds interceptors to the particular context.
Expand All @@ -12,15 +14,29 @@ import { extendArrayMetadata } from '../../utils/extend-metadata.util';
* @param {} ...interceptors (types)
*/
export function UseInterceptors(...interceptors: any[]) {
return (target: object, key?, descriptor?) => {
return (target: any, key?, descriptor?) => {
if (descriptor) {
validateEach(
target.constructor,
interceptors,
isFunction,
'@UseInterceptors',
'interceptor',
);
extendArrayMetadata(
INTERCEPTORS_METADATA,
interceptors,
descriptor.value,
);
return descriptor;
}
validateEach(
target,
interceptors,
isFunction,
'@UseInterceptors',
'interceptor',
);
extendArrayMetadata(INTERCEPTORS_METADATA, interceptors, target);
return target;
};
Expand Down
7 changes: 6 additions & 1 deletion packages/common/decorators/core/use-pipes.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { PipeTransform } from '../../interfaces/index';
import { PIPES_METADATA } from '../../constants';
import { extendArrayMetadata } from '../../utils/extend-metadata.util';
import { validateEach } from '../../utils/validate-each.util';
import { isFunction } from '../../utils/shared.utils';

/**
* Binds pipes to the particular context.
Expand All @@ -13,11 +15,14 @@ import { extendArrayMetadata } from '../../utils/extend-metadata.util';
* @param {PipeTransform[]} ...pipes (instances)
*/
export function UsePipes(...pipes: PipeTransform<any>[]) {
return (target: object, key?, descriptor?) => {
return (target: any, key?, descriptor?) => {
const isPipeValid = (pipe) => isFunction(pipe.transform);
if (descriptor) {
validateEach(target.constructor, pipes, isPipeValid, '@UsePipes', 'pipe');
extendArrayMetadata(PIPES_METADATA, pipes, descriptor.value);
return descriptor;
}
validateEach(target, pipes, isPipeValid, '@UsePipes', 'pipe');
extendArrayMetadata(PIPES_METADATA, pipes, target);
return target;
};
Expand Down
Loading

0 comments on commit 91b4974

Please sign in to comment.