Compare commits

..

42 Commits

Author SHA1 Message Date
Kamil Myśliwiec
79fc37f093 chore(@nestjs) publish v5.6.2 release 2019-01-16 22:45:26 +01:00
Kamil Myśliwiec
8eedff85bd chore() publish 5.6.1 release 2019-01-16 21:47:30 +01:00
Kamil Myśliwiec
159a947f1b chore(@nestjs) publish v5.6.1 release 2019-01-16 21:46:35 +01:00
Kamil Myśliwiec
5eee77ea20 Merge branch '5.6.0' 2019-01-16 21:39:08 +01:00
Kamil Myśliwiec
c90b8e3d07 chore() publish 5.6.0 release 2019-01-16 21:37:29 +01:00
Kamil Myśliwiec
acf97a2e1d chore(@nestjs) publish v5.6.0 release 2019-01-16 21:36:15 +01:00
Kamil Myśliwiec
84c156356b feature(websockets) support regexp in namespaces 2019-01-16 21:34:18 +01:00
Kamil Myśliwiec
9a3f760b6c bugfix(core) fix missing abstract type typing 2019-01-16 21:33:53 +01:00
Kamil Myśliwiec
d1ad94324b feature() support abstract classes in nest ctx 2019-01-16 21:15:29 +01:00
Kamil Myśliwiec
69fb434def Merge branch 'master' of https://github.com/nestjs/nest 2019-01-16 21:05:10 +01:00
Kamil Myśliwiec
c448e56611 chore() merge changes 2019-01-16 21:04:02 +01:00
Kamil Myśliwiec
b8e6553a06 Merge branch 'FionaLovett-validate-transform' into 5.6.0 2019-01-16 21:00:19 +01:00
Kamil Myśliwiec
6fc4826b30 Merge branch 'FionaLovett-validate-transform' 2019-01-16 20:59:29 +01:00
Kamil Myśliwiec
2f888d3abe refactor() adjust code style 2019-01-16 20:59:06 +01:00
Kamil Myśliwiec
0db05f62f1 Merge branch 'validate-transform' of https://github.com/FionaLovett/nest into FionaLovett-validate-transform 2019-01-16 20:55:36 +01:00
Kamil Mysliwiec
255ca7ef99 Merge pull request #1448 from caohuilin/patch-2
sample(mongoose) should await on create POST
2019-01-16 20:51:50 +01:00
Kamil Mysliwiec
6744a8648d Update Readme.md 2019-01-16 20:35:19 +01:00
Belinda Cao
7a0808ed5b Update cats.controller.ts 2019-01-15 09:57:06 +08:00
Kamil Mysliwiec
5940ec7d62 Merge pull request #1388 from hschiavone/grpc-server-max-received-and-send-message-length
feature(microservices) add server gRPC max received & message length options
2019-01-15 00:30:02 +01:00
Kamil Mysliwiec
535c881a95 Merge branch '5.6.0' into grpc-server-max-received-and-send-message-length 2019-01-15 00:29:17 +01:00
Kamil Mysliwiec
986ad4e746 Merge pull request #1424 from quaternion/master
bugfix(common) add missing axios provider in HttpModule.registerAsync
2019-01-15 00:26:41 +01:00
Kamil Myśliwiec
6204fe1a09 Merge branch 'anton-alation-feature/grpc-method-with-namespaces' into 5.6.0 2019-01-15 00:25:16 +01:00
Kamil Myśliwiec
3cb73111bf refactor() adjust code style 2019-01-15 00:23:18 +01:00
Kamil Mysliwiec
1b872d66b7 Update Readme.md 2019-01-15 00:12:24 +01:00
Kamil Myśliwiec
891de8eea8 Merge branch 'feature/grpc-method-with-namespaces' of https://github.com/anton-alation/nest into anton-alation-feature/grpc-method-with-namespaces 2019-01-15 00:03:29 +01:00
Kamil Mysliwiec
0f788efd0c Merge pull request #1441 from iblamefish/circular-dependency-message
bugfix(core) update URL for circular dependency in the error message
2019-01-14 23:17:34 +01:00
Kamil Mysliwiec
72491e7d62 Merge pull request #1410 from BrunnerLivio/feature/discord-badge
chore() add discord badge to README.md
2019-01-14 22:06:00 +01:00
Clinton Montague
4b74c275bd bugfix(core) update url for circular dependency in error message
Fixes the url in INVALID_MODULE_MESSAGE

This closes #1369
2019-01-13 17:50:03 +00:00
Livio
3939a67bd3 chore: add discord badge to README.md 2019-01-07 18:48:39 +01:00
Andrew Nikolaev
1212c6034a fix(common): add missing axios provider in HttpModule.registerAsync 2019-01-05 18:46:53 +03:00
Fiona Lovett
94679b2d79 feature(common): add transformOptions to ValidationPipeOptions
allows plainToClass to expose class properties to defined groups as per issue #1374
2019-01-02 20:52:29 +01:00
Fiona Lovett
83fc4c3bc4 feature(common): add transformOptions to ValidationPipeOptions
allows plainToClass to expose class properties to defined groups as per issue #1374
2019-01-02 20:07:50 +01:00
Fiona Lovett
69f2f3dd0b feature(common): add transformOptions to ValidationPipeOptions
allows plainToClass to expose class properties to defined groups as per issue #1374
2019-01-02 19:56:33 +01:00
Fiona Lovett
b49a9a1098 feature(common): add transformOptions to ValidationPipeOptions
allows plainToClass to expose class properties to defined groups as per issue #1374
2019-01-02 17:53:46 +01:00
Kamil Myśliwiec
2a5e22e2c6 scripts() fix prepare script (install all deps) 2018-12-29 10:21:18 +01:00
Hugo Schiavone
84e4bdef1e fix getOptionsProp method 2018-12-27 18:25:43 +01:00
Hugo Schiavone
da110d01dd use getOptionsProp method on grcp max_send_message_length & max_receive_message_length implementation 2018-12-27 12:24:38 +01:00
Hugo Schiavone
bd3222ad62 implement server grpc max received & send message length option 2018-12-20 10:10:16 +01:00
Anton Repin
595bc988ec GRPC Server test stub updated to match getServiceNames new output 2018-12-12 15:50:10 -08:00
Anton Repin
ea26100ec3 GRPC server tests updated:
- Added package recursive search test for support of proto-namespaces
- Updated tests which were testing single level proto structure
2018-12-12 13:27:06 -08:00
Kamil Mysliwiec
ff2e310a18 Update cats.controller.ts 2018-12-12 14:24:41 +01:00
Anton Repin
8d41edadce GRPC Server namespaces support added for loaded proto descriptors
- Recursive scan of descriptors object
- Service names with namespaces concatenated with dot-syntax
2018-12-11 23:37:38 -08:00
431 changed files with 3869 additions and 16407 deletions

View File

@@ -16,6 +16,7 @@
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#8" alt="Coverage" /></a>
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
<a href="https://discord.gg/G7Qnnhy"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
@@ -48,13 +49,10 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="320" /></a>
#### Gold Sponsors
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
#### Silver Sponsors
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a> &nbsp;
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a>
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a> &nbsp;
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" /></a>
#### Sponsors

View File

@@ -1,50 +1,28 @@
'use strict';
var __decorate =
(this && this.__decorate) ||
function(decorators, target, key, desc) {
var c = arguments.length,
r =
c < 3
? target
: desc === null
? (desc = Object.getOwnPropertyDescriptor(target, key))
: desc,
d;
if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if ((d = decorators[i]))
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata =
(this && this.__metadata) ||
function(k, v) {
if (typeof Reflect === 'object' && typeof Reflect.metadata === 'function')
return Reflect.metadata(k, v);
};
Object.defineProperty(exports, '__esModule', { value: true });
const common_1 = require('@nestjs/common');
let AppController = class AppController {
root() {
return 'Hello world!';
}
};
__decorate(
[
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("@nestjs/common");
let AppController = class AppController {
root() {
return 'Hello world!';
}
};
__decorate([
common_1.Get(),
__metadata('design:type', Function),
__metadata('design:paramtypes', []),
__metadata('design:returntype', String),
],
AppController.prototype,
'root',
null,
);
AppController = __decorate(
[common_1.Controller({ scope: common_1.Scope.REQUEST })],
AppController,
);
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", String)
], AppController.prototype, "root", null);
AppController = __decorate([
common_1.Controller()
], AppController);
exports.AppController = AppController;
//# sourceMappingURL=app.controller.js.map
//# sourceMappingURL=app.controller.js.map

View File

@@ -12,16 +12,6 @@ const packages = {
microservices: ts.createProject('packages/microservices/tsconfig.json'),
websockets: ts.createProject('packages/websockets/tsconfig.json'),
testing: ts.createProject('packages/testing/tsconfig.json'),
'platform-express': ts.createProject(
'packages/platform-express/tsconfig.json',
),
'platform-fastify': ts.createProject(
'packages/platform-fastify/tsconfig.json',
),
'platform-socket.io': ts.createProject(
'packages/platform-socket.io/tsconfig.json',
),
'platform-ws': ts.createProject('packages/platform-ws/tsconfig.json'),
};
const modules = Object.keys(packages);
const source = 'packages';
@@ -44,21 +34,14 @@ gulp.task('copy-misc', function() {
.pipe(gulp.dest(`${source}/core`))
.pipe(gulp.dest(`${source}/microservices`))
.pipe(gulp.dest(`${source}/websockets`))
.pipe(gulp.dest(`${source}/testing`))
.pipe(gulp.dest(`${source}/platform-fastify`))
.pipe(gulp.dest(`${source}/platform-express`))
.pipe(gulp.dest(`${source}/platform-ws`))
.pipe(gulp.dest(`${source}/platform-socket.io`));
.pipe(gulp.dest(`${source}/testing`));
});
gulp.task('clean:output', function() {
return gulp
.src(
[`${source}/**/*.js`, `${source}/**/*.d.ts`, `${source}/**/*.js.map`],
{
read: false,
},
)
.src([`${source}/**/*.js`, `${source}/**/*.d.ts`], {
read: false,
})
.pipe(clean());
});

View File

@@ -1,4 +1,4 @@
/*import { INestApplication } from '@nestjs/common';
import { INestApplication } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import * as request from 'supertest';
import { AsyncClassApplicationModule } from '../src/async-options-class.module';
@@ -36,4 +36,3 @@ describe('GraphQL (async class)', () => {
await app.close();
});
});
*/

View File

@@ -1,4 +1,4 @@
/*import { INestApplication } from '@nestjs/common';
import { INestApplication } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import * as request from 'supertest';
import { AsyncExistingApplicationModule } from '../src/async-options-existing.module';
@@ -36,4 +36,3 @@ describe('GraphQL (async existing)', () => {
await app.close();
});
});
*/

View File

@@ -1,4 +1,4 @@
/*import { INestApplication } from '@nestjs/common';
import { INestApplication } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import * as request from 'supertest';
import { AsyncApplicationModule } from '../src/async-options.module';
@@ -34,4 +34,3 @@ describe('GraphQL (async configuration)', () => {
await app.close();
});
});
*/

View File

@@ -1,4 +1,4 @@
/*import { INestApplication } from '@nestjs/common';
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { ApplicationModule } from '../src/app.module';
@@ -38,4 +38,3 @@ describe('GraphQL', () => {
await app.close();
});
});
*/

View File

@@ -18,7 +18,7 @@
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"subscriptions-transport-ws": "^0.9.5",
"typescript": "^3.1.0",
"typescript": "^2.8.0",
"ws": "^4.0.0"
},
"devDependencies": {

View File

@@ -1,8 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { ExpressAdapter } from '@nestjs/platform-express';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { Test } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import { ApplicationModule } from '../src/app.module';
describe('Hello world (express instance)', () => {
@@ -12,9 +11,10 @@ describe('Hello world (express instance)', () => {
beforeEach(async () => {
const module = await Test.createTestingModule({
imports: [ApplicationModule],
}).compile();
})
.compile();
app = module.createNestApplication(new ExpressAdapter(express()));
app = module.createNestApplication(express());
server = app.getHttpServer();
await app.init();
});

View File

@@ -1,22 +1,19 @@
import {
FastifyAdapter,
INestFastifyApplication,
} from '@nestjs/platform-fastify';
import { INestApplication } from '@nestjs/common';
import { INestFastifyApplication } from '@nestjs/common/interfaces/nest-fastify-application.interface';
import { FastifyAdapter } from '@nestjs/core/adapters/fastify-adapter';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import { ApplicationModule } from '../src/app.module';
describe('Hello world (fastify adapter)', () => {
let app: INestFastifyApplication;
let app: INestApplication & INestFastifyApplication;
beforeEach(async () => {
const module = await Test.createTestingModule({
imports: [ApplicationModule],
}).compile();
app = module.createNestApplication<INestFastifyApplication>(
new FastifyAdapter(),
);
app = module.createNestApplication(new FastifyAdapter());
await app.init();
});

View File

@@ -1,30 +1,24 @@
import {
CallHandler,
ExecutionContext,
INestApplication,
Injectable,
NestInterceptor,
} from '@nestjs/common';
import { APP_INTERCEPTOR } from '@nestjs/core';
import * as request from 'supertest';
import { Test } from '@nestjs/testing';
import { INestApplication, Injectable } from '@nestjs/common';
import { ApplicationModule } from '../src/app.module';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { of } from 'rxjs';
import { map } from 'rxjs/operators';
import * as request from 'supertest';
import { ApplicationModule } from '../src/app.module';
const RETURN_VALUE = 'test';
@Injectable()
export class OverrideInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler) {
export class OverrideInterceptor {
intercept(context, stream) {
return of(RETURN_VALUE);
}
}
@Injectable()
export class TransformInterceptor {
intercept(context: ExecutionContext, next: CallHandler) {
return next.handle().pipe(map(data => ({ data })));
intercept(context, stream) {
return stream.pipe(map(data => ({ data })));
}
}
@@ -47,7 +41,7 @@ describe('Interceptors', () => {
app = (await createTestModule(
new OverrideInterceptor(),
)).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello')
@@ -58,7 +52,7 @@ describe('Interceptors', () => {
app = (await createTestModule(
new TransformInterceptor(),
)).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello')
@@ -69,7 +63,7 @@ describe('Interceptors', () => {
app = (await createTestModule(
new TransformInterceptor(),
)).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello/stream')
@@ -80,7 +74,7 @@ describe('Interceptors', () => {
app = (await createTestModule(
new TransformInterceptor(),
)).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello/async')

View File

@@ -17,7 +17,7 @@
"fastify": "^1.1.1",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typescript": "^3.1.0"
"typescript": "^2.8.0"
},
"devDependencies": {
"@types/node": "^7.0.41",

View File

@@ -1,4 +1,4 @@
import { BadRequestException, Controller, Get } from '@nestjs/common';
import { Get, BadRequestException, Controller } from '@nestjs/common';
@Controller()
export class ErrorsController {
@@ -13,10 +13,6 @@ export class ErrorsController {
}
throwError() {
throw new BadRequestException({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
throw new BadRequestException('Integration test');
}
}

View File

@@ -16,7 +16,7 @@
"class-validator": "^0.7.2",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typescript": "^3.1.0"
"typescript": "^2.8.0"
},
"devDependencies": {
"@types/node": "^7.0.41",

View File

@@ -1,7 +1,8 @@
import * as express from 'express';
import * as request from 'supertest';
import { Test } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { MqttBroadcastController } from '../src/mqtt/mqtt-broadcast.controller';
describe('MQTT transport', () => {
@@ -13,9 +14,8 @@ describe('MQTT transport', () => {
controllers: [MqttBroadcastController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.MQTT,
});

View File

@@ -1,7 +1,8 @@
import * as express from 'express';
import * as request from 'supertest';
import { Test } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { NatsBroadcastController } from '../src/nats/nats-broadcast.controller';
describe('NATS transport', () => {
@@ -13,9 +14,8 @@ describe('NATS transport', () => {
controllers: [NatsBroadcastController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.NATS,
});

View File

@@ -1,7 +1,9 @@
import * as express from 'express';
import * as request from 'supertest';
import { Test } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { RedisController } from '../src/redis/redis.controller';
import { RedisBroadcastController } from '../src/redis/redis-broadcast.controller';
describe('REDIS transport', () => {
@@ -13,9 +15,8 @@ describe('REDIS transport', () => {
controllers: [RedisBroadcastController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.REDIS,
});

View File

@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { DisconnectedClientController } from '../src/disconnected.controller';
@@ -13,9 +14,8 @@ describe('Disconnected client', () => {
controllers: [DisconnectedClientController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
await app.init();
});

View File

@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import { join } from 'path';
import * as request from 'supertest';
import { GrpcController } from '../src/grpc/grpc.controller';
@@ -14,9 +15,8 @@ describe('GRPC transport', () => {
controllers: [GrpcController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.GRPC,
options: {

View File

@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { MqttController } from '../src/mqtt/mqtt.controller';
@@ -13,9 +14,8 @@ describe('MQTT transport', () => {
controllers: [MqttController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.MQTT,
});

View File

@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { NatsController } from '../src/nats/nats.controller';
@@ -13,9 +14,8 @@ describe('NATS transport', () => {
controllers: [NatsController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.NATS,
options: {

View File

@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { RedisController } from '../src/redis/redis.controller';
@@ -13,9 +14,8 @@ describe('REDIS transport', () => {
controllers: [RedisController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.REDIS,
});

View File

@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { RMQController } from '../src/rmq/rmq.controller';
@@ -13,9 +14,8 @@ describe('RabbitMQ transport', () => {
controllers: [RMQController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.RMQ,
options: {

View File

@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Transport } from '@nestjs/microservices';
import { Test } from '@nestjs/testing';
import * as express from 'express';
import * as request from 'supertest';
import { ApplicationModule } from '../src/app.module';
@@ -13,9 +14,8 @@ describe('RPC transport', () => {
imports: [ApplicationModule],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
server = express();
app = module.createNestApplication(server);
app.connectMicroservice({
transport: Transport.TCP,
});

View File

@@ -17,7 +17,7 @@
"class-validator": "^0.7.2",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typescript": "^3.1.0"
"typescript": "^2.8.0"
},
"devDependencies": {
"@types/node": "^7.0.41",

View File

@@ -15,7 +15,7 @@
"mongoose": "^5.0.1",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typescript": "^3.1.0"
"typescript": "^2.8.0"
},
"devDependencies": {
"@types/mongoose": "^4.7.23",

View File

@@ -1,21 +0,0 @@
# dependencies
/node_modules
# IDE
/.idea
/.awcache
/.vscode
# misc
npm-debug.log
# example
/quick-start
# tests
/test
/coverage
/.nyc_output
# dist
/dist

View File

@@ -1,71 +0,0 @@
import { INestApplication, Scope } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import * as request from 'supertest';
import { HelloController } from '../src/circular-hello/hello.controller';
import { HelloModule } from '../src/circular-hello/hello.module';
import { HelloService } from '../src/circular-hello/hello.service';
import { UsersService } from '../src/circular-hello/users/users.service';
class Meta {
static COUNTER = 0;
constructor(private readonly helloService: HelloService) {
Meta.COUNTER++;
}
}
describe('Circular request scope', () => {
let server;
let app: INestApplication;
before(async () => {
const module = await Test.createTestingModule({
imports: [
HelloModule.forRoot({
provide: 'META',
useClass: Meta,
scope: Scope.REQUEST,
}),
],
}).compile();
app = module.createNestApplication();
server = app.getHttpServer();
await app.init();
});
describe('when one service is request scoped', () => {
before(async () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
expect(HelloService.COUNTER).to.be.eql(3);
});
it(`should create provider for each inquirer`, async () => {
expect(Meta.COUNTER).to.be.eql(3);
});
});
after(async () => {
await app.close();
});
});

View File

@@ -1,71 +0,0 @@
import { INestApplication, Scope } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import * as request from 'supertest';
import { HelloController } from '../src/circular-transient/hello.controller';
import { HelloModule } from '../src/circular-transient/hello.module';
import { HelloService } from '../src/circular-transient/hello.service';
import { UsersService } from '../src/circular-transient/users/users.service';
class Meta {
static COUNTER = 0;
constructor(private readonly helloService: HelloService) {
Meta.COUNTER++;
}
}
describe('Circular transient scope', () => {
let server;
let app: INestApplication;
before(async () => {
const module = await Test.createTestingModule({
imports: [
HelloModule.forRoot({
provide: 'META',
useClass: Meta,
scope: Scope.TRANSIENT,
}),
],
}).compile();
app = module.createNestApplication();
server = app.getHttpServer();
await app.init();
});
describe('when one service is request scoped', () => {
before(async () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
expect(HelloService.COUNTER).to.be.eql(3);
});
it(`should create provider for each inquirer`, async () => {
expect(Meta.COUNTER).to.be.eql(7);
});
});
after(async () => {
await app.close();
});
});

View File

@@ -1,80 +0,0 @@
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import * as request from 'supertest';
import { Guard } from '../src/hello/guards/request-scoped.guard';
import { HelloController } from '../src/hello/hello.controller';
import { HelloModule } from '../src/hello/hello.module';
import { Interceptor } from '../src/hello/interceptors/logging.interceptor';
import { UserByIdPipe } from '../src/hello/users/user-by-id.pipe';
import { UsersService } from '../src/hello/users/users.service';
class Meta {
static COUNTER = 0;
constructor() {
Meta.COUNTER++;
}
}
describe('Request scope', () => {
let server;
let app: INestApplication;
before(async () => {
const module = await Test.createTestingModule({
imports: [
HelloModule.forRoot({
provide: 'META',
useClass: Meta,
}),
],
}).compile();
app = module.createNestApplication();
server = app.getHttpServer();
await app.init();
});
describe('when one service is request scoped', () => {
before(async () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should share static provider across requests`, async () => {
expect(Meta.COUNTER).to.be.eql(1);
});
it(`should create request scoped pipe for each request`, async () => {
expect(UserByIdPipe.COUNTER).to.be.eql(3);
});
it(`should create request scoped interceptor for each request`, async () => {
expect(Interceptor.COUNTER).to.be.eql(3);
});
it(`should create request scoped guard for each request`, async () => {
expect(Guard.COUNTER).to.be.eql(3);
});
});
after(async () => {
await app.close();
});
});

View File

@@ -1,81 +0,0 @@
import { INestApplication, Scope } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import * as request from 'supertest';
import { Guard } from '../src/transient/guards/request-scoped.guard';
import { HelloController } from '../src/transient/hello.controller';
import { HelloModule } from '../src/transient/hello.module';
import { Interceptor } from '../src/transient/interceptors/logging.interceptor';
import { UserByIdPipe } from '../src/transient/users/user-by-id.pipe';
import { UsersService } from '../src/transient/users/users.service';
class Meta {
static COUNTER = 0;
constructor() {
Meta.COUNTER++;
}
}
describe('Transient scope', () => {
let server;
let app: INestApplication;
before(async () => {
const module = await Test.createTestingModule({
imports: [
HelloModule.forRoot({
provide: 'META',
useClass: Meta,
scope: Scope.TRANSIENT,
}),
],
}).compile();
app = module.createNestApplication();
server = app.getHttpServer();
await app.init();
});
describe('when one service is request scoped', () => {
before(async () => {
const performHttpCall = end =>
request(server)
.get('/hello')
.end((err, res) => {
if (err) return end(err);
end();
});
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
await new Promise(resolve => performHttpCall(resolve));
});
it(`should create controller for each request`, async () => {
expect(HelloController.COUNTER).to.be.eql(3);
});
it(`should create service for each request`, async () => {
expect(UsersService.COUNTER).to.be.eql(3);
});
it(`should create provider for each inquirer`, async () => {
expect(Meta.COUNTER).to.be.eql(7);
});
it(`should create transient pipe for each controller`, async () => {
expect(UserByIdPipe.COUNTER).to.be.eql(2);
});
it(`should create transient interceptor for each controller`, async () => {
expect(Interceptor.COUNTER).to.be.eql(2);
});
it(`should create transient guard for each controller`, async () => {
expect(Guard.COUNTER).to.be.eql(2);
});
});
after(async () => {
await app.close();
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,27 +0,0 @@
{
"name": "nest-typescript-starter",
"version": "1.0.0",
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"start": "ts-node src/main"
},
"dependencies": {
"@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",
"class-transformer": "^0.1.7",
"class-validator": "^0.7.2",
"fastify": "^1.1.1",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typescript": "^3.1.0"
},
"devDependencies": {
"@types/node": "^7.0.41",
"supertest": "^3.0.0",
"ts-node": "^6.0.0"
}
}

View File

@@ -1,7 +0,0 @@
import { Module } from '@nestjs/common';
import { HelloModule } from './hello/hello.module';
@Module({
imports: [HelloModule.forRoot({ provide: 'META', useValue: true })],
})
export class ApplicationModule {}

View File

@@ -1,10 +0,0 @@
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
export class TestDto {
@IsString()
@IsNotEmpty()
string: string;
@IsNumber()
number: number;
}

View File

@@ -1,21 +0,0 @@
import {
CanActivate,
ExecutionContext,
Injectable,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.REQUEST })
export class Guard implements CanActivate {
static COUNTER = 0;
constructor() {
Guard.COUNTER++;
}
canActivate(
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
return true;
}
}

View File

@@ -1,30 +0,0 @@
import {
Controller,
Get,
Param,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { Guard } from './guards/request-scoped.guard';
import { HelloService } from './hello.service';
import { Interceptor } from './interceptors/logging.interceptor';
import { UserByIdPipe } from './users/user-by-id.pipe';
import { UsersService } from './users/users.service';
@Controller('hello')
export class HelloController {
static COUNTER = 0;
constructor(
private readonly helloService: HelloService,
private readonly usersService: UsersService,
) {
HelloController.COUNTER++;
}
@UseGuards(Guard)
@UseInterceptors(Interceptor)
@Get()
greeting(@Param('id', UserByIdPipe) id): string {
return this.helloService.greeting();
}
}

View File

@@ -1,19 +0,0 @@
import { DynamicModule, Inject, Module, Provider } from '@nestjs/common';
import { HelloController } from './hello.controller';
import { HelloService } from './hello.service';
import { UsersService } from './users/users.service';
@Module({
controllers: [HelloController],
providers: [HelloService, UsersService],
})
export class HelloModule {
constructor(@Inject('META') private readonly meta) {}
static forRoot(meta: Provider): DynamicModule {
return {
module: HelloModule,
providers: [meta],
};
}
}

View File

@@ -1,13 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class HelloService {
static COUNTER = 0;
constructor(@Inject('META') private readonly meta) {
HelloService.COUNTER++;
}
greeting(): string {
return 'Hello world!';
}
}

View File

@@ -1,19 +0,0 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.REQUEST })
export class Interceptor implements NestInterceptor {
static COUNTER = 0;
constructor() {
Interceptor.COUNTER++;
}
intercept(context: ExecutionContext, call: CallHandler): Observable<any> {
return call.handle();
}
}

View File

@@ -1,14 +0,0 @@
import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';
import { UsersService } from './users.service';
@Injectable()
export class UserByIdPipe implements PipeTransform<string> {
static COUNTER = 0;
constructor(private readonly usersService: UsersService) {
UserByIdPipe.COUNTER++;
}
transform(value: string, metadata: ArgumentMetadata) {
return this.usersService.findById(value);
}
}

View File

@@ -1,13 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class UsersService {
static COUNTER = 0;
constructor(@Inject('META') private readonly meta) {
UsersService.COUNTER++;
}
findById(id: string) {
return { id };
}
}

View File

@@ -1,10 +0,0 @@
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
export class TestDto {
@IsString()
@IsNotEmpty()
string: string;
@IsNumber()
number: number;
}

View File

@@ -1,21 +0,0 @@
import {
CanActivate,
ExecutionContext,
Injectable,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.TRANSIENT })
export class Guard implements CanActivate {
static COUNTER = 0;
constructor() {
Guard.COUNTER++;
}
canActivate(
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
return true;
}
}

View File

@@ -1,30 +0,0 @@
import {
Controller,
Get,
Param,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { Guard } from './guards/request-scoped.guard';
import { HelloService } from './hello.service';
import { Interceptor } from './interceptors/logging.interceptor';
import { UserByIdPipe } from './users/user-by-id.pipe';
import { UsersService } from './users/users.service';
@Controller('hello')
export class HelloController {
static COUNTER = 0;
constructor(
private readonly helloService: HelloService,
private readonly usersService: UsersService,
) {
HelloController.COUNTER++;
}
@UseGuards(Guard)
@UseInterceptors(Interceptor)
@Get()
greeting(@Param('id', UserByIdPipe) id): string {
return this.helloService.greeting();
}
}

View File

@@ -1,20 +0,0 @@
import { DynamicModule, Inject, Module, Provider } from '@nestjs/common';
import { HelloController } from './hello.controller';
import { HelloService } from './hello.service';
import { TestController } from './test.controller';
import { UsersService } from './users/users.service';
@Module({
controllers: [HelloController, TestController],
providers: [HelloService, UsersService],
})
export class HelloModule {
constructor(@Inject('META') private readonly meta) {}
static forRoot(meta: Provider): DynamicModule {
return {
module: HelloModule,
providers: [meta],
};
}
}

View File

@@ -1,13 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class HelloService {
static COUNTER = 0;
constructor(@Inject('META') private readonly meta) {
HelloService.COUNTER++;
}
greeting(): string {
return 'Hello world!';
}
}

View File

@@ -1,19 +0,0 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.TRANSIENT })
export class Interceptor implements NestInterceptor {
static COUNTER = 0;
constructor() {
Interceptor.COUNTER++;
}
intercept(context: ExecutionContext, call: CallHandler): Observable<any> {
return call.handle();
}
}

View File

@@ -1,20 +0,0 @@
import {
Controller,
Get,
Param,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { Guard } from './guards/request-scoped.guard';
import { Interceptor } from './interceptors/logging.interceptor';
import { UserByIdPipe } from './users/user-by-id.pipe';
@Controller('test')
export class TestController {
@UseGuards(Guard)
@UseInterceptors(Interceptor)
@Get()
greeting(@Param('id', UserByIdPipe) id): string {
return 'hey';
}
}

View File

@@ -1,18 +0,0 @@
import {
ArgumentMetadata,
Injectable,
PipeTransform,
Scope,
} from '@nestjs/common';
@Injectable({ scope: Scope.TRANSIENT })
export class UserByIdPipe implements PipeTransform<string> {
static COUNTER = 0;
constructor() {
UserByIdPipe.COUNTER++;
}
transform(value: string, metadata: ArgumentMetadata) {
return value;
}
}

View File

@@ -1,13 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class UsersService {
static COUNTER = 0;
constructor(@Inject('META') private readonly meta) {
UsersService.COUNTER++;
}
findById(id: string) {
return { id };
}
}

View File

@@ -1,10 +0,0 @@
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
export class TestDto {
@IsString()
@IsNotEmpty()
string: string;
@IsNumber()
number: number;
}

View File

@@ -1,21 +0,0 @@
import {
CanActivate,
ExecutionContext,
Injectable,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.REQUEST })
export class Guard implements CanActivate {
static COUNTER = 0;
constructor() {
Guard.COUNTER++;
}
canActivate(
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
return true;
}
}

View File

@@ -1,30 +0,0 @@
import {
Controller,
Get,
Param,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { Guard } from './guards/request-scoped.guard';
import { HelloService } from './hello.service';
import { Interceptor } from './interceptors/logging.interceptor';
import { UserByIdPipe } from './users/user-by-id.pipe';
import { UsersService } from './users/users.service';
@Controller('hello')
export class HelloController {
static COUNTER = 0;
constructor(
private readonly helloService: HelloService,
private readonly usersService: UsersService,
) {
HelloController.COUNTER++;
}
@UseGuards(Guard)
@UseInterceptors(Interceptor)
@Get()
greeting(@Param('id', UserByIdPipe) id): string {
return this.helloService.greeting();
}
}

View File

@@ -1,19 +0,0 @@
import { DynamicModule, Inject, Module, Provider } from '@nestjs/common';
import { HelloController } from './hello.controller';
import { HelloService } from './hello.service';
import { UsersService } from './users/users.service';
@Module({
controllers: [HelloController],
providers: [HelloService, UsersService],
})
export class HelloModule {
constructor(@Inject('META') private readonly meta) {}
static forRoot(meta: Provider): DynamicModule {
return {
module: HelloModule,
providers: [meta],
};
}
}

View File

@@ -1,10 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class HelloService {
constructor(@Inject('META') private readonly meta) {}
greeting(): string {
return 'Hello world!';
}
}

View File

@@ -1,19 +0,0 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.REQUEST })
export class Interceptor implements NestInterceptor {
static COUNTER = 0;
constructor() {
Interceptor.COUNTER++;
}
intercept(context: ExecutionContext, call: CallHandler): Observable<any> {
return call.handle();
}
}

View File

@@ -1,14 +0,0 @@
import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';
import { UsersService } from './users.service';
@Injectable()
export class UserByIdPipe implements PipeTransform<string> {
static COUNTER = 0;
constructor(private readonly usersService: UsersService) {
UserByIdPipe.COUNTER++;
}
transform(value: string, metadata: ArgumentMetadata) {
return this.usersService.findById(value);
}
}

View File

@@ -1,13 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class UsersService {
static COUNTER = 0;
constructor(@Inject('META') private readonly meta) {
UsersService.COUNTER++;
}
findById(id: string) {
return { id };
}
}

View File

@@ -1,8 +0,0 @@
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);
await app.listen(3000);
}
bootstrap();

View File

@@ -1,10 +0,0 @@
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
export class TestDto {
@IsString()
@IsNotEmpty()
string: string;
@IsNumber()
number: number;
}

View File

@@ -1,21 +0,0 @@
import {
CanActivate,
ExecutionContext,
Injectable,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.TRANSIENT })
export class Guard implements CanActivate {
static COUNTER = 0;
constructor() {
Guard.COUNTER++;
}
canActivate(
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
return true;
}
}

View File

@@ -1,30 +0,0 @@
import {
Controller,
Get,
Param,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { Guard } from './guards/request-scoped.guard';
import { HelloService } from './hello.service';
import { Interceptor } from './interceptors/logging.interceptor';
import { UserByIdPipe } from './users/user-by-id.pipe';
import { UsersService } from './users/users.service';
@Controller('hello')
export class HelloController {
static COUNTER = 0;
constructor(
private readonly helloService: HelloService,
private readonly usersService: UsersService,
) {
HelloController.COUNTER++;
}
@UseGuards(Guard)
@UseInterceptors(Interceptor)
@Get()
greeting(@Param('id', UserByIdPipe) id): string {
return this.helloService.greeting();
}
}

View File

@@ -1,20 +0,0 @@
import { DynamicModule, Inject, Module, Provider } from '@nestjs/common';
import { HelloController } from './hello.controller';
import { HelloService } from './hello.service';
import { TestController } from './test.controller';
import { UsersService } from './users/users.service';
@Module({
controllers: [HelloController, TestController],
providers: [HelloService, UsersService],
})
export class HelloModule {
constructor(@Inject('META') private readonly meta) {}
static forRoot(meta: Provider): DynamicModule {
return {
module: HelloModule,
providers: [meta],
};
}
}

View File

@@ -1,10 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class HelloService {
constructor(@Inject('META') private readonly meta) {}
greeting(): string {
return 'Hello world!';
}
}

View File

@@ -1,19 +0,0 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
Scope,
} from '@nestjs/common';
import { Observable } from 'rxjs';
@Injectable({ scope: Scope.TRANSIENT })
export class Interceptor implements NestInterceptor {
static COUNTER = 0;
constructor() {
Interceptor.COUNTER++;
}
intercept(context: ExecutionContext, call: CallHandler): Observable<any> {
return call.handle();
}
}

View File

@@ -1,20 +0,0 @@
import {
Controller,
Get,
Param,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { Guard } from './guards/request-scoped.guard';
import { Interceptor } from './interceptors/logging.interceptor';
import { UserByIdPipe } from './users/user-by-id.pipe';
@Controller('test')
export class TestController {
@UseGuards(Guard)
@UseInterceptors(Interceptor)
@Get()
greeting(@Param('id', UserByIdPipe) id): string {
return 'hey';
}
}

View File

@@ -1,18 +0,0 @@
import {
ArgumentMetadata,
Injectable,
PipeTransform,
Scope,
} from '@nestjs/common';
@Injectable({ scope: Scope.TRANSIENT })
export class UserByIdPipe implements PipeTransform<string> {
static COUNTER = 0;
constructor() {
UserByIdPipe.COUNTER++;
}
transform(value: string, metadata: ArgumentMetadata) {
return value;
}
}

View File

@@ -1,13 +0,0 @@
import { Inject, Injectable, Scope } from '@nestjs/common';
@Injectable({ scope: Scope.REQUEST })
export class UsersService {
static COUNTER = 0;
constructor(@Inject('META') private readonly meta) {
UsersService.COUNTER++;
}
findById(id: string) {
return { id };
}
}

View File

@@ -1,22 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"allowJs": true,
"outDir": "./dist"
},
"include": [
"src/**/*",
"e2e/**/*"
],
"exclude": [
"node_modules",
]
}

View File

@@ -1,53 +0,0 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {
"no-unused-expression": true
},
"rules": {
"eofline": false,
"quotemark": [
true,
"single"
],
"ordered-imports": [
false
],
"max-line-length": [
150
],
"member-ordering": [
false
],
"curly": false,
"interface-name": [
false
],
"array-type": [
false
],
"member-access": [
false
],
"no-empty-interface": false,
"no-empty": false,
"arrow-parens": false,
"object-literal-sort-keys": false,
"no-unused-expression": false,
"max-classes-per-file": [
false
],
"variable-name": [
false
],
"one-line": [
false
],
"one-variable-per-declaration": [
false
]
},
"rulesDirectory": []
}

View File

@@ -16,7 +16,7 @@
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typeorm": "^0.1.16",
"typescript": "^3.1.0"
"typescript": "^2.8.0"
},
"devDependencies": {
"@types/node": "^7.0.41",

View File

@@ -15,6 +15,7 @@ async function createNestApp(...gateways): Promise<INestApplication> {
}
describe('WebSocketGateway', () => {
const event = 'push';
let ws, app;
it(`should handle message (2nd port)`, async () => {

View File

@@ -1,6 +1,6 @@
import { INestApplication } from '@nestjs/common';
import { WsAdapter } from '@nestjs/platform-ws';
import { Test } from '@nestjs/testing';
import { WsAdapter } from '@nestjs/websockets/adapters/ws-adapter';
import { expect } from 'chai';
import * as WebSocket from 'ws';
import { ApplicationGateway } from '../src/app.gateway';

View File

@@ -16,7 +16,7 @@
"class-validator": "^0.7.2",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typescript": "^3.1.0"
"typescript": "^2.8.0"
},
"devDependencies": {
"@types/node": "^7.0.41",

View File

@@ -3,5 +3,5 @@
"packages": [
"packages/*"
],
"version": "5.5.0"
"version": "5.6.2"
}

197
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "nestjs",
"version": "5.4.1",
"version": "5.6.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -124,7 +124,7 @@
"dependencies": {
"axios": {
"version": "0.18.0",
"resolved": "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
"integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=",
"requires": {
"follow-redirects": "^1.3.0",
@@ -171,7 +171,7 @@
},
"express": {
"version": "4.16.3",
"resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz",
"resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz",
"integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=",
"requires": {
"accepts": "~1.3.5",
@@ -237,7 +237,7 @@
},
"finalhandler": {
"version": "1.1.1",
"resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz",
"integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==",
"requires": {
"debug": "2.6.9",
@@ -340,9 +340,9 @@
}
},
"@nestjs/microservices": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-5.1.0.tgz",
"integrity": "sha512-g9ez7N+QgjlJSSak27KhUHXi1YMnk/DuGpAn/TWlm5rSmcsrArdTSvinGBMyb0mL3CMJJz8y0/CZwAUdy9HQzA==",
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-5.5.0.tgz",
"integrity": "sha512-sOZ2+dPxHvb+RNbmn4wo+MFg9ZHxx9N9RGZmlYQEJQ+s4zk0rJBalzJhKNuNkiL6oJDYYNom98YhWRVvuAkvwg==",
"requires": {
"iterare": "0.0.8",
"json-socket": "^0.2.1",
@@ -598,9 +598,9 @@
"dev": true
},
"@types/node": {
"version": "10.12.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.14.tgz",
"integrity": "sha512-0rVcFRhM93kRGAU88ASCjX9Y3FWDCh+33G5Z5evpKOea4xcpLqDGwmo64+DjgaSezTN5j9KdnUzvxhOw7fNciQ=="
"version": "7.0.48",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.48.tgz",
"integrity": "sha512-LLlXafM3BD52MH056tHxTXO8JFCnpJJQkdzIU3+m8ew+CXJY/5zIXgDNb4TK/QFvlI8QexLS5tL+sE0Qhegr1w=="
},
"@types/pino": {
"version": "4.7.1",
@@ -1698,9 +1698,9 @@
"dev": true
},
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz",
"integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==",
"dev": true
},
"buffer-more-ints": {
@@ -4984,30 +4984,6 @@
}
}
},
"fastify-cors": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/fastify-cors/-/fastify-cors-0.2.0.tgz",
"integrity": "sha512-bw14FmjHm8oF4TDLkwj2TpssH6O2gE0NpsRqLe7F1Gh9Jf30Lx9ZzIznhqaAKOYS+LJqLIt5snurv7urgqYntA==",
"requires": {
"fastify-plugin": "^1.2.0",
"vary": "^1.1.2"
},
"dependencies": {
"fastify-plugin": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-1.4.0.tgz",
"integrity": "sha512-l6uqDyBp3gBjLQRAi3j2NwSvlbe9LuqULZugnO9iRFfYHWd2SpsZBLI1l4Jakk0VMGfYlB322JPIPYh/2qSHig==",
"requires": {
"semver": "^5.5.0"
}
},
"semver": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg=="
}
}
},
"fastify-formbody": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fastify-formbody/-/fastify-formbody-2.0.0.tgz",
@@ -8503,11 +8479,6 @@
"sshpk": "^1.7.0"
}
},
"http2": {
"version": "3.3.7",
"resolved": "https://registry.npmjs.org/http2/-/http2-3.3.7.tgz",
"integrity": "sha512-puSi8M8WNlFJm9Pk4c/Mbz9Gwparuj3gO9/RRO5zv6piQ0FY+9Qywp0PdWshYgsMJSalixFY7eC6oPu0zRxLAQ=="
},
"husky": {
"version": "0.14.3",
"resolved": "https://registry.npmjs.org/husky/-/husky-0.14.3.tgz",
@@ -10504,9 +10475,9 @@
}
},
"make-error": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
"integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",
"integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==",
"dev": true
},
"make-iterator": {
@@ -13461,9 +13432,9 @@
"dev": true
},
"prettier": {
"version": "1.15.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.3.tgz",
"integrity": "sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==",
"version": "1.10.2",
"resolved": "http://192.168.228.42:5000/prettier/-/prettier-1.10.2.tgz",
"integrity": "sha512-TcdNoQIWFoHblurqqU6d1ysopjq7UX0oRcT/hJ8qvBAELiYWn+Ugf0AXdnzISEJ7vuhNnQ98N8jR8Sh53x4IZg==",
"dev": true
},
"pretty-format": {
@@ -15460,21 +15431,47 @@
}
},
"ts-node": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
"integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.0.1.tgz",
"integrity": "sha512-LDS8WJRTEztvQEXbRK/0l/apWE0BNR/USGUhVcJDe2/hbNiB/v/lCqk6YJzgwKjScgdWOAhPQsfur7hmQ1Y1jA==",
"dev": true,
"requires": {
"arrify": "^1.0.0",
"buffer-from": "^1.1.0",
"chalk": "^2.3.0",
"diff": "^3.1.0",
"make-error": "^1.1.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"source-map-support": "^0.5.6",
"source-map-support": "^0.5.3",
"yn": "^2.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"chalk": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz",
"integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
}
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@@ -15482,14 +15479,23 @@
"dev": true
},
"source-map-support": {
"version": "0.5.9",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz",
"integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==",
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.5.tgz",
"integrity": "sha512-mR7/Nd5l1z6g99010shcXJiNEaf3fEtmLhRB/sBcQVJGodcHCULPp2y4Sfa43Kv2zq7T+Izmfp/WHCR6dYkQCA==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"supports-color": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
}
}
},
@@ -15574,9 +15580,9 @@
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ=="
},
"tslint": {
"version": "5.11.0",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz",
"integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=",
"version": "5.9.1",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.9.1.tgz",
"integrity": "sha1-ElX4ej/1frCw4fDmEKi0dIBGya4=",
"dev": true,
"requires": {
"babel-code-frame": "^6.22.0",
@@ -15590,7 +15596,7 @@
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.8.0",
"tsutils": "^2.27.2"
"tsutils": "^2.12.1"
},
"dependencies": {
"ansi-styles": {
@@ -15603,9 +15609,9 @@
}
},
"chalk": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz",
"integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.0.tgz",
"integrity": "sha512-Wr/w0f4o9LuE7K53cD0qmbAMM+2XNLzR29vFn5hqko4sxGlUsyy363NvmyGIyk5tpe9cjTr9SJYbysEyPkRnFw==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.1",
@@ -15614,17 +15620,31 @@
}
},
"commander": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==",
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
"dev": true
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@@ -15632,25 +15652,34 @@
"dev": true
},
"js-yaml": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
"version": "3.11.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz",
"integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"semver": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==",
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
"integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==",
"dev": true
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
@@ -15659,9 +15688,9 @@
}
},
"tsutils": {
"version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"version": "2.26.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.26.1.tgz",
"integrity": "sha512-bnm9bcjOqOr1UljleL94wVCDlpa6KjfGaTkefeLch4GRafgDkROxPizbB/FxTEdI++5JqhxczRy/Qub0syNqZA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
@@ -15710,9 +15739,9 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"typescript": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz",
"integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==",
"version": "2.8.1",
"resolved": "http://registry.npmjs.org/typescript/-/typescript-2.8.1.tgz",
"integrity": "sha512-Ao/f6d/4EPLq0YwzsQz8iXflezpTkQzqAyenTiw4kCUGr1uPiFLC3+fZ+gMZz6eeI/qdRUqvC+HxIJzUAzEFdg==",
"dev": true
},
"uglify-js": {

View File

@@ -1,25 +1,34 @@
{
"name": "nestjs",
"version": "5.4.1",
"version": "5.6.1",
"description": "Modern, fast, powerful node.js web framework",
"scripts": {
"coverage": "nyc report --reporter=text-lcov | coveralls",
"precommit": "lint-staged",
"test": "nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec --require 'node_modules/reflect-metadata/Reflect.js'",
"integration-test": "mocha integration/**/*.spec.ts --reporter spec --require ts-node/register --require 'node_modules/reflect-metadata/Reflect.js'",
"lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
"format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
"test":
"nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec --require 'node_modules/reflect-metadata/Reflect.js'",
"integration-test":
"mocha integration/**/*.spec.ts --reporter spec --require ts-node/register --require 'node_modules/reflect-metadata/Reflect.js'",
"lint":
"tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"",
"format":
"prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status",
"clean": "gulp clean:bundle",
"build": "npm run clean && gulp build",
"prebuild:dev": "rm -rf node_modules/@nestjs",
"build:dev": "gulp build --dist node_modules/@nestjs && gulp move",
"postinstall": "opencollective",
"prerelease": "gulp copy-misc && gulp build --dist node_modules/@nestjs",
"publish": "npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --force-publish --exact -m \"chore(@nestjs) publish %s release\"",
"publish:rc": "npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --npm-tag=rc -m \"chore(@nestjs) publish %s release\"",
"publish:next": "npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --npm-tag=next --skip-git -m \"chore(@nestjs) publish %s release\"",
"publish:beta": "npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(@nestjs) publish %s release\"",
"publish:test": "npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --force-publish --npm-tag=test --skip-git -m \"chore(@nestjs) publish %s release\""
"publish":
"npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --force-publish --exact -m \"chore(@nestjs) publish %s release\"",
"publish:rc":
"npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --npm-tag=rc -m \"chore(@nestjs) publish %s release\"",
"publish:next":
"npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --npm-tag=next --skip-git -m \"chore(@nestjs) publish %s release\"",
"publish:beta":
"npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --npm-tag=beta -m \"chore(@nestjs) publish %s release\"",
"publish:test":
"npm run prerelease && npm run build && ./node_modules/.bin/lerna publish --force-publish --npm-tag=test --skip-git -m \"chore(@nestjs) publish %s release\""
},
"engines": {
"node": ">= 8.9.0"
@@ -32,9 +41,9 @@
"license": "MIT",
"dependencies": {
"@grpc/proto-loader": "^0.3.0",
"@nestjs/common": "^5.5.0",
"@nestjs/common": "5.5.0",
"@nestjs/core": "^5.5.0",
"@nestjs/microservices": "5.1.0",
"@nestjs/microservices": "5.5.0",
"@nestjs/testing": "5.1.0",
"@nestjs/websockets": "5.1.0",
"@nuxtjs/opencollective": "^0.1.0",
@@ -47,16 +56,15 @@
"cli-color": "^1.1.0",
"connect": "^3.6.6",
"cors": "^2.8.4",
"deprecate": "^1.0.0",
"engine.io-client": "^3.1.1",
"express": "^4.16.2",
"fast-json-stringify": "^1.5.4",
"fast-safe-stringify": "^1.2.0",
"fastify": "^1.1.1",
"fastify-cors": "^0.2.0",
"fastify-formbody": "^2.0.0",
"fastify-multipart": "^0.4.1",
"grpc": "^1.14.1",
"http2": "^3.3.7",
"iterare": "0.0.8",
"json-socket": "^0.2.1",
"mqtt": "^2.16.0",
@@ -84,7 +92,7 @@
"@types/express": "^4.0.39",
"@types/kafka-node": "^2.0.6",
"@types/mocha": "^2.2.38",
"@types/node": "^10.12.14",
"@types/node": "^7.0.5",
"@types/redis": "^0.12.36",
"@types/reflect-metadata": "0.0.5",
"@types/sinon": "^1.16.36",
@@ -116,14 +124,14 @@
"mocha": "^3.2.0",
"nodemon": "^1.18.4",
"nyc": "^10.1.2",
"prettier": "^1.15.3",
"prettier": "^1.9.2",
"sinon": "^2.1.0",
"sinon-chai": "^2.8.0",
"socket.io-client": "^2.0.4",
"supertest": "^3.0.0",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.2.2"
"ts-node": "^6.0.0",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
},
"collective": {
"type": "opencollective",
@@ -133,18 +141,16 @@
}
},
"nyc": {
"include": [
"packages/**/*.ts"
],
"include": ["packages/**/*.ts"],
"exclude": [
"node_modules/",
"packages/**/*.spec.ts",
"packages/**/adapters/*.ts",
"packages/core/adapters/*.ts",
"packages/websockets/adapters/*.ts",
"packages/**/nest-*.ts",
"packages/core/errors/**/*",
"packages/common/exceptions/*.ts",
"packages/common/http/*.ts",
"packages/common/hooks/*.ts",
"packages/common/utils/load-package.util.ts",
"packages/microservices/exceptions/",
"packages/microservices/microservices-module.ts",
@@ -155,23 +161,13 @@
"packages/common/serializer/**/*",
"packages/common/services/logger.service.ts"
],
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"reporter": [
"text-summary",
"html"
],
"extension": [".ts"],
"require": ["ts-node/register"],
"reporter": ["text-summary", "html"],
"sourceMap": true,
"instrument": true
},
"lint-staged": {
"packages/**/*.{ts,json}": [
"npm run format",
"git add"
]
"packages/**/*.{ts,json}": ["npm run format", "git add"]
}
}

View File

@@ -1,6 +1,6 @@
(The MIT License)
Copyright (c) 2018 Kamil Myśliwiec <https://kamilmysliwiec.com>
Copyright (c) 2017 Kamil Myśliwiec <http://kamilmysliwiec.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -16,6 +16,7 @@
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#8" alt="Coverage" /></a>
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
<a href="https://discord.gg/G7Qnnhy"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
@@ -48,13 +49,10 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
<a href="https://valor-software.com/"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="320" /></a>
#### Gold Sponsors
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
#### Silver Sponsors
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a> &nbsp;
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a>
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> &nbsp; <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a> &nbsp;
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="150" /></a>
#### Sponsors

View File

@@ -1,50 +1,39 @@
import { Observable, of } from 'rxjs';
import { tap } from 'rxjs/operators';
import { Inject, Injectable, Optional } from '../../decorators';
import {
CallHandler,
ExecutionContext,
HttpServer,
NestInterceptor,
} from '../../interfaces';
import { ExecutionContext, NestInterceptor } from '../../interfaces';
import { CACHE_KEY_METADATA, CACHE_MANAGER } from '../cache.constants';
const APPLICATION_REFERENCE_HOST = 'ApplicationReferenceHost';
const REFLECTOR = 'Reflector';
export interface ApplicationHost<T extends HttpServer = any> {
applicationRef: T;
}
@Injectable()
export class CacheInterceptor implements NestInterceptor {
@Optional()
@Inject(APPLICATION_REFERENCE_HOST)
protected readonly applicationRefHost: ApplicationHost;
protected readonly applicationRefHost: any;
constructor(
@Inject(CACHE_MANAGER) protected readonly cacheManager: any,
@Inject(REFLECTOR) protected readonly reflector: any,
@Inject(REFLECTOR) protected readonly reflector,
) {}
async intercept(
context: ExecutionContext,
next: CallHandler,
call$: Observable<any>,
): Promise<Observable<any>> {
const key = this.trackBy(context);
if (!key) {
return next.handle();
return call$;
}
try {
const value = await this.cacheManager.get(key);
if (value) {
return of(value);
}
return next
.handle()
.pipe(tap(response => this.cacheManager.set(key, response)));
return call$.pipe(tap(response => this.cacheManager.set(key, response)));
} catch {
return next.handle();
return call$;
}
}

View File

@@ -1,19 +1,20 @@
export const METADATA = {
MODULES: 'modules',
IMPORTS: 'imports',
COMPONENTS: 'components',
PROVIDERS: 'providers',
CONTROLLERS: 'controllers',
EXPORTS: 'exports',
};
export const SHARED_MODULE_METADATA = '__module:shared__';
export const GLOBAL_MODULE_METADATA = '__module:global__';
export const SHARED_MODULE_METADATA = '__sharedModule__';
export const GLOBAL_MODULE_METADATA = '__globalModule__';
export const PATH_METADATA = 'path';
export const PARAMTYPES_METADATA = 'design:paramtypes';
export const SELF_DECLARED_DEPS_METADATA = 'self:paramtypes';
export const OPTIONAL_DEPS_METADATA = 'optional:paramtypes';
export const PROPERTY_DEPS_METADATA = 'self:properties_metadata';
export const OPTIONAL_PROPERTY_DEPS_METADATA = 'optional:properties_metadata';
export const SCOPE_OPTIONS_METADATA = 'scope:options';
export const METHOD_METADATA = 'method';
export const ROUTE_ARGS_METADATA = '__routeArguments__';
@@ -25,6 +26,7 @@ export const GUARDS_METADATA = '__guards__';
export const RENDER_METADATA = '__renderTemplate__';
export const INTERCEPTORS_METADATA = '__interceptors__';
export const HTTP_CODE_METADATA = '__httpCode__';
export const GATEWAY_MIDDLEWARES = '__gatewayMiddleware';
export const MODULE_PATH = '__module_path__';
export const HEADERS_METADATA = '__headers__';
export const REDIRECT_METADATA = '__redirect__';

View File

@@ -1,14 +1,10 @@
/**
* Binds parameter decorators to the method
* Binds parameters decorators to the particular method
* Useful when the language doesn't provide a 'Parameter Decorators' feature (vanilla JavaScript)
* @param {} ...decorators
*/
export function Bind(...decorators: any[]): MethodDecorator {
return <T>(
target: object,
key: string | symbol,
descriptor: TypedPropertyDescriptor<T>,
) => {
export function Bind(...decorators: any[]) {
return (target: object, key, descriptor) => {
decorators.forEach((fn, index) => fn(target, key, index));
return descriptor;
};

View File

@@ -2,7 +2,7 @@ import { FILTER_CATCH_EXCEPTIONS } from '../../constants';
import { Type } from '../../interfaces';
/**
* Defines an exception filter. Takes set of exception types as arguments which have to be caught by this filter.
* Defines the Exceptions Filter. Takes set of exception types as an argument which has to be caught by this Filter.
* The class should implement the `ExceptionFilter` interface.
*/
export function Catch(...exceptions: Type<any>[]): ClassDecorator {

View File

@@ -0,0 +1,74 @@
import * as deprecate from 'deprecate';
import * as uuid from 'uuid/v4';
/**
* Defines the injectable class. This class can inject dependencies through constructor.
* Those dependencies have to belong to the same module.
*/
export function Injectable(): ClassDecorator {
return (target: object) => {};
}
/**
* @deprecated
* Defines the Component. The component can inject dependencies through constructor.
* Those dependencies have to belong to the same module.
*/
export function Component(): ClassDecorator {
deprecate(
'The @Component() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
);
return (target: object) => {};
}
/**
* @deprecated
* Defines the Pipe. The Pipe should implement the `PipeTransform` interface.
*/
export function Pipe(): ClassDecorator {
deprecate(
'The @Pipe() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
);
return (target: object) => {};
}
/**
* @deprecated
* Defines the Guard. The Guard should implement the `CanActivate` interface.
*/
export function Guard(): ClassDecorator {
deprecate(
'The @Guard() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
);
return (target: object) => {};
}
/**
* @deprecated
* Defines the Middleware. The Middleware should implement the `NestMiddleware` interface.
*/
export function Middleware(): ClassDecorator {
deprecate(
'The @Middleware() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
);
return (target: object) => {};
}
/**
* @deprecated
* Defines the Interceptor. The Interceptor should implement `HttpInterceptor`, `RpcInterceptor` or `WsInterceptor` interface.
*/
export function Interceptor(): ClassDecorator {
deprecate(
'The @Interceptor() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
);
return (target: object) => {};
}
export function mixin(mixinClass) {
Object.defineProperty(mixinClass, 'name', {
value: uuid(),
});
Injectable()(mixinClass);
return mixinClass;
}

View File

@@ -1,8 +1,8 @@
import { PATH_METADATA } from '../../constants';
import { isUndefined } from '../../utils/shared.utils';
import { PATH_METADATA } from '../../constants';
/**
* Defines the controller. Controller can inject dependencies through constructor.
* Defines the Controller. The controller can inject dependencies through constructor.
* Those dependencies have to belong to the same module.
*/
export function Controller(prefix?: string): ClassDecorator {

View File

@@ -1,10 +1,8 @@
import { PARAMTYPES_METADATA } from '../../constants';
export function flatten<T extends any[] = any, R extends any[] = any>(
arr: T,
): R {
export function flatten(arr: any[]) {
const flat = [].concat(...arr);
return (flat.some(Array.isArray) ? flatten(flat) : flat) as R;
return flat.some(Array.isArray) ? flatten(flat) : flat;
}
export const Dependencies = (...dependencies: any[]): ClassDecorator => {

View File

@@ -5,12 +5,9 @@ import { isFunction } from '../../utils/shared.utils';
import { validateEach } from '../../utils/validate-each.util';
const defineFiltersMetadata = (...filters: (Function | ExceptionFilter)[]) => {
return (target: any, key?: string, descriptor?: any) => {
const isFilterValid = <T extends Function | Record<string, any>>(
filter: T,
) =>
filter &&
(isFunction(filter) || isFunction((filter as Record<string, any>).catch));
return (target: any, key?, descriptor?) => {
const isFilterValid = filter =>
filter && (isFunction(filter) || isFunction(filter.catch));
if (descriptor) {
validateEach(
@@ -34,12 +31,12 @@ const defineFiltersMetadata = (...filters: (Function | ExceptionFilter)[]) => {
};
/**
* Bounds exception filters to the chosen context.
* Setups exception filters to the chosen context.
* When the `@UseFilters()` is used on the controller level:
* - Exception Filter will be set up to every handler (every method)
*
* When the `@UseFilters()` is used on the handle level:
* - Exception Filter will be set up only to the specified method
* - Exception Filter will be set up only to specified method
*
* @param {ExceptionFilter[]} ...filters
*/

View File

@@ -1,10 +1,10 @@
export * from './bind.decorator';
export * from './catch.decorator';
export * from './component.decorator';
export * from './controller.decorator';
export * from './dependencies.decorator';
export * from './exception-filters.decorator';
export * from './inject.decorator';
export * from './injectable.decorator';
export * from './optional.decorator';
export * from './reflect-metadata.decorator';
export * from './use-guards.decorator';

View File

@@ -6,7 +6,7 @@ import { isFunction, isUndefined } from '../../utils/shared.utils';
/**
* Injects provider which has to be available in the current injector (module) scope.
* Providers are recognized by either types or tokens.
* Providers are recognized by types or tokens.
*/
export function Inject<T = any>(token?: T) {
return (target: Object, key: string | symbol, index?: number) => {

View File

@@ -1,24 +0,0 @@
import * as uuid from 'uuid/v4';
import { ScopeOptions } from '../../interfaces/scope-options.interface';
import { SCOPE_OPTIONS_METADATA } from './../../constants';
import { Type } from './../../interfaces/type.interface';
export interface InjectableOptions extends ScopeOptions {}
/**
* Defines the injectable class. This class can inject dependencies through constructor.
* Those dependencies have to belong to the same module.
*/
export function Injectable(options?: InjectableOptions): ClassDecorator {
return (target: object) => {
Reflect.defineMetadata(SCOPE_OPTIONS_METADATA, options, target);
};
}
export function mixin(mixinClass: Type<any>) {
Object.defineProperty(mixinClass, 'name', {
value: uuid(),
});
Injectable()(mixinClass);
return mixinClass;
}

View File

@@ -2,10 +2,11 @@
* Assigns the metadata to the class/function under specified `key`.
* This metadata can be reflected using `Reflector` class.
*/
export const ReflectMetadata = <K = any, V = any>(
metadataKey: K,
metadataValue: V,
) => (target: object, key?: any, descriptor?: any) => {
export const ReflectMetadata = <K = any, V = any>(metadataKey: K, metadataValue: V) => (
target: object,
key?,
descriptor?,
) => {
if (descriptor) {
Reflect.defineMetadata(metadataKey, metadataValue, descriptor.value);
return descriptor;

View File

@@ -1,8 +1,8 @@
import { GUARDS_METADATA } from '../../constants';
import { CanActivate } from '../../interfaces';
import { extendArrayMetadata } from '../../utils/extend-metadata.util';
import { isFunction } from '../../utils/shared.utils';
import { validateEach } from '../../utils/validate-each.util';
import { isFunction } from '../../utils/shared.utils';
import { CanActivate } from '../../interfaces';
/**
* Binds guards to the particular context.
@@ -10,16 +10,14 @@ import { validateEach } from '../../utils/validate-each.util';
* - Guard will be register to each handler (every method)
*
* When the `@UseGuards()` is used on the handler level:
* - Guard will be registered only to the specified method
* - Guard will be registered only to specified method
*
* @param {} ...guards
*/
export function UseGuards(...guards: (CanActivate | Function)[]) {
return (target: any, key?: string, descriptor?: any) => {
const isValidGuard = <T extends Function | Record<string, any>>(guard: T) =>
guard &&
(isFunction(guard) ||
isFunction((guard as Record<string, any>).canActivate));
return (target: any, key?, descriptor?) => {
const isValidGuard = guard =>
guard && (isFunction(guard) || isFunction(guard.canActivate));
if (descriptor) {
validateEach(

View File

@@ -10,20 +10,17 @@ import { validateEach } from '../../utils/validate-each.util';
* - Interceptor will be register to each handler (every method)
*
* When the `@UseInterceptors()` is used on the handle level:
* - Interceptor will be registered only to the specified method
* - Interceptor will be registered only to specified method
*
* @param {} ...interceptors
*/
export function UseInterceptors(
...interceptors: (NestInterceptor | Function)[]
) {
return (target: any, key?: string, descriptor?: any) => {
const isValidInterceptor = <T extends Function | Record<string, any>>(
interceptor: T,
) =>
return (target: any, key?, descriptor?) => {
const isValidInterceptor = interceptor =>
interceptor &&
(isFunction(interceptor) ||
isFunction((interceptor as Record<string, any>).intercept));
(isFunction(interceptor) || isFunction(interceptor.intercept));
if (descriptor) {
validateEach(

View File

@@ -1,8 +1,8 @@
import { PIPES_METADATA } from '../../constants';
import { PipeTransform } from '../../interfaces/index';
import { PIPES_METADATA } from '../../constants';
import { extendArrayMetadata } from '../../utils/extend-metadata.util';
import { isFunction } from '../../utils/shared.utils';
import { validateEach } from '../../utils/validate-each.util';
import { isFunction } from '../../utils/shared.utils';
/**
* Binds pipes to the particular context.
@@ -10,16 +10,14 @@ import { validateEach } from '../../utils/validate-each.util';
* - Pipe will be register to each handler (every method)
*
* When the `@UsePipes()` is used on the handle level:
* - Pipe will be registered only to the specified method
* - Pipe will be registered only to specified method
*
* @param {PipeTransform[]} ...pipes
*/
export function UsePipes(...pipes: (PipeTransform | Function)[]) {
return (target: any, key?: string, descriptor?: any) => {
const isPipeValid = <T extends Function | Record<string, any>>(pipe: T) =>
pipe &&
(isFunction(pipe) || isFunction((pipe as Record<string, any>).transform));
return (target: any, key?, descriptor?) => {
const isPipeValid = pipe =>
pipe && (isFunction(pipe) || isFunction(pipe.transform));
if (descriptor) {
extendArrayMetadata(PIPES_METADATA, pipes, descriptor.value);
return descriptor;

View File

@@ -1,3 +1,4 @@
import * as deprecate from 'deprecate';
import * as uuid from 'uuid/v4';
import {
CUSTOM_ROUTE_AGRS_METADATA,
@@ -46,7 +47,7 @@ export function createParamDecorator(
const args =
Reflect.getMetadata(ROUTE_ARGS_METADATA, target.constructor, key) || {};
const isPipe = (pipe: any) =>
const isPipe = pipe =>
pipe &&
((isFunction(pipe) && pipe.prototype) || isFunction(pipe.transform));
@@ -70,3 +71,20 @@ export function createParamDecorator(
enhancers.forEach(fn => fn(target, key, index));
};
}
/**
* Defines HTTP route param decorator
* @deprecated
* @param factory
*/
export function createRouteParamDecorator(
factory: CustomParamFactory,
): (
data?: any,
...pipes: (Type<PipeTransform> | PipeTransform)[]
) => ParameterDecorator {
deprecate(
'The "createRouteParamDecorator" function is deprecated and will be removed within next major release. Use "createParamDecorator" instead.',
);
return createParamDecorator(factory);
}

View File

@@ -41,7 +41,7 @@ const createRouteParamDecorator = (paramtype: RouteParamtypes) => {
};
const createPipesRouteParamDecorator = (paramtype: RouteParamtypes) => (
data?: any,
data?,
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator => (target, key, index) => {
const args =
@@ -80,54 +80,48 @@ export const Headers: (
property?: string,
) => ParameterDecorator = createRouteParamDecorator(RouteParamtypes.HEADERS);
export function Query(): ParameterDecorator;
export function Query(
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator;
export function Query();
export function Query(...pipes: (Type<PipeTransform> | PipeTransform)[]);
export function Query(
property: string,
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator;
);
export function Query(
property?: string | (Type<PipeTransform> | PipeTransform),
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator {
) {
return createPipesRouteParamDecorator(RouteParamtypes.QUERY)(
property,
...pipes,
);
}
export function Body(): ParameterDecorator;
export function Body(
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator;
export function Body();
export function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]);
export function Body(
property: string,
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator;
);
export function Body(
property?: string | (Type<PipeTransform> | PipeTransform),
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator {
) {
return createPipesRouteParamDecorator(RouteParamtypes.BODY)(
property,
...pipes,
);
}
export function Param(): ParameterDecorator;
export function Param(
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator;
export function Param();
export function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]);
export function Param(
property: string,
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator;
);
export function Param(
property?: string | (Type<PipeTransform> | PipeTransform),
...pipes: (Type<PipeTransform> | PipeTransform)[]
): ParameterDecorator {
) {
return createPipesRouteParamDecorator(RouteParamtypes.PARAM)(
property,
...pipes,

View File

@@ -1,4 +1,2 @@
export const INVALID_MODULE_CONFIG_MESSAGE = (
text: TemplateStringsArray,
property: string,
) => `Invalid property '${property}' in the @Module() decorator.`;
export const InvalidModuleConfigMessage = (property: string) =>
`Invalid property '${property}' in @Module() decorator.`;

View File

@@ -1,7 +1,7 @@
import { INVALID_MODULE_CONFIG_MESSAGE } from './constants';
import { InvalidModuleConfigMessage } from './constants';
export class InvalidModuleConfigException extends Error {
constructor(property: string) {
super(INVALID_MODULE_CONFIG_MESSAGE`${property}`);
super(InvalidModuleConfigMessage(property));
}
}

View File

@@ -1,5 +1,4 @@
import { GLOBAL_MODULE_METADATA } from '../../constants';
/**
* Makes the module global-scoped.
* Once imported will be available for all existing modules.

Some files were not shown because too many files have changed in this diff Show More