@nestjs/common 5.4.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +4 -4
- package/cache/interceptors/cache.interceptor.d.ts +3 -4
- package/cache/interceptors/cache.interceptor.js +15 -15
- package/files/interceptors/file-fields.interceptor.js +2 -2
- package/files/interceptors/file.interceptor.js +2 -2
- package/files/interceptors/files.interceptor.js +2 -2
- package/package.json +1 -1
- package/utils/shared.utils.d.ts +1 -1
package/Readme.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
|
15
15
|
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
|
16
16
|
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
|
17
|
-
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#
|
|
17
|
+
<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>
|
|
18
18
|
<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>
|
|
19
19
|
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
20
20
|
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
@@ -53,12 +53,12 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
53
53
|
<a href="http://xtremis.com/"><img src="https://nestjs.com/img/logo-xtremis.svg" width="220" /></a>
|
|
54
54
|
|
|
55
55
|
#### Silver Sponsors
|
|
56
|
-
|
|
57
|
-
<a href="
|
|
56
|
+
<a href="https://neoteric.eu/"><img src="https://nestjs.com/img/neoteric-cut.png" width="120" /></a>
|
|
57
|
+
<a href="http://gojob.com"><img src="http://nestjs.com/img/gojob-logo.png" valign="bottom" height="95" /></a> <a href="https://www.swingdev.io"><img src="https://nestjs.com/img/swingdev-logo.svg#1" width="150" /> </a>
|
|
58
58
|
|
|
59
59
|
#### Sponsors
|
|
60
60
|
|
|
61
|
-
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a>
|
|
61
|
+
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="38" /></a> <a href="http://architectnow.net/"><img src="https://nestjs.com/img/architectnow.png" height="24" /></a> <a href="https://quander.io/"><img src="https://nestjs.com/img/quander.png" height="28" /></a>
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
## Backers
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import { ExecutionContext,
|
|
2
|
+
import { ExecutionContext, NestInterceptor } from '../../interfaces';
|
|
3
3
|
export declare class CacheInterceptor implements NestInterceptor {
|
|
4
|
-
protected readonly httpServer: HttpServer;
|
|
5
4
|
protected readonly cacheManager: any;
|
|
6
5
|
protected readonly reflector: any;
|
|
7
|
-
protected readonly
|
|
8
|
-
constructor(
|
|
6
|
+
protected readonly applicationRefHost: any;
|
|
7
|
+
constructor(cacheManager: any, reflector: any);
|
|
9
8
|
intercept(context: ExecutionContext, call$: Observable<any>): Promise<Observable<any>>;
|
|
10
9
|
trackBy(context: ExecutionContext): string | undefined;
|
|
11
10
|
}
|
|
@@ -16,17 +16,12 @@ const rxjs_1 = require("rxjs");
|
|
|
16
16
|
const operators_1 = require("rxjs/operators");
|
|
17
17
|
const decorators_1 = require("../../decorators");
|
|
18
18
|
const cache_constants_1 = require("../cache.constants");
|
|
19
|
-
|
|
20
|
-
// We need to deduplicate them here due to the circular dependency
|
|
21
|
-
// between core and common packages
|
|
22
|
-
const HTTP_SERVER_REF = 'HTTP_SERVER_REF';
|
|
19
|
+
const APPLICATION_REFERENCE_HOST = 'ApplicationReferenceHost';
|
|
23
20
|
const REFLECTOR = 'Reflector';
|
|
24
21
|
let CacheInterceptor = class CacheInterceptor {
|
|
25
|
-
constructor(
|
|
26
|
-
this.httpServer = httpServer;
|
|
22
|
+
constructor(cacheManager, reflector) {
|
|
27
23
|
this.cacheManager = cacheManager;
|
|
28
24
|
this.reflector = reflector;
|
|
29
|
-
this.isHttpApp = httpServer && !!httpServer.getRequestMethod;
|
|
30
25
|
}
|
|
31
26
|
async intercept(context, call$) {
|
|
32
27
|
const key = this.trackBy(context);
|
|
@@ -45,22 +40,27 @@ let CacheInterceptor = class CacheInterceptor {
|
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
42
|
trackBy(context) {
|
|
48
|
-
|
|
43
|
+
const httpServer = this.applicationRefHost.applicationRef;
|
|
44
|
+
const isHttpApp = httpServer && !!httpServer.getRequestMethod;
|
|
45
|
+
if (!isHttpApp) {
|
|
49
46
|
return this.reflector.get(cache_constants_1.CACHE_KEY_METADATA, context.getHandler());
|
|
50
47
|
}
|
|
51
48
|
const request = context.getArgByIndex(0);
|
|
52
|
-
if (
|
|
49
|
+
if (httpServer.getRequestMethod(request) !== 'GET') {
|
|
53
50
|
return undefined;
|
|
54
51
|
}
|
|
55
|
-
return
|
|
52
|
+
return httpServer.getRequestUrl(request);
|
|
56
53
|
}
|
|
57
54
|
};
|
|
55
|
+
__decorate([
|
|
56
|
+
decorators_1.Optional(),
|
|
57
|
+
decorators_1.Inject(APPLICATION_REFERENCE_HOST),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], CacheInterceptor.prototype, "applicationRefHost", void 0);
|
|
58
60
|
CacheInterceptor = __decorate([
|
|
59
61
|
decorators_1.Injectable(),
|
|
60
|
-
__param(0, decorators_1.
|
|
61
|
-
__param(
|
|
62
|
-
|
|
63
|
-
__param(2, decorators_1.Inject(REFLECTOR)),
|
|
64
|
-
__metadata("design:paramtypes", [Object, Object, Object])
|
|
62
|
+
__param(0, decorators_1.Inject(cache_constants_1.CACHE_MANAGER)),
|
|
63
|
+
__param(1, decorators_1.Inject(REFLECTOR)),
|
|
64
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
65
65
|
], CacheInterceptor);
|
|
66
66
|
exports.CacheInterceptor = CacheInterceptor;
|
|
@@ -20,11 +20,11 @@ const multer_utils_1 = require("../multer/multer.utils");
|
|
|
20
20
|
function FileFieldsInterceptor(uploadFields, localOptions) {
|
|
21
21
|
let MixinInterceptor = class MixinInterceptor {
|
|
22
22
|
constructor(options = {}) {
|
|
23
|
-
this.
|
|
23
|
+
this.multer = multer(Object.assign({}, options, localOptions));
|
|
24
24
|
}
|
|
25
25
|
async intercept(context, call$) {
|
|
26
26
|
const ctx = context.switchToHttp();
|
|
27
|
-
await new Promise((resolve, reject) => this.
|
|
27
|
+
await new Promise((resolve, reject) => this.multer.fields(uploadFields)(ctx.getRequest(), ctx.getResponse(), err => {
|
|
28
28
|
if (err) {
|
|
29
29
|
const error = multer_utils_1.transformException(err);
|
|
30
30
|
return reject(error);
|
|
@@ -20,11 +20,11 @@ const multer_utils_1 = require("../multer/multer.utils");
|
|
|
20
20
|
function FileInterceptor(fieldName, localOptions) {
|
|
21
21
|
let MixinInterceptor = class MixinInterceptor {
|
|
22
22
|
constructor(options = {}) {
|
|
23
|
-
this.
|
|
23
|
+
this.multer = multer(Object.assign({}, options, localOptions));
|
|
24
24
|
}
|
|
25
25
|
async intercept(context, call$) {
|
|
26
26
|
const ctx = context.switchToHttp();
|
|
27
|
-
await new Promise((resolve, reject) => this.
|
|
27
|
+
await new Promise((resolve, reject) => this.multer.single(fieldName)(ctx.getRequest(), ctx.getResponse(), err => {
|
|
28
28
|
if (err) {
|
|
29
29
|
const error = multer_utils_1.transformException(err);
|
|
30
30
|
return reject(error);
|
|
@@ -20,11 +20,11 @@ const multer_utils_1 = require("../multer/multer.utils");
|
|
|
20
20
|
function FilesInterceptor(fieldName, maxCount, localOptions) {
|
|
21
21
|
let MixinInterceptor = class MixinInterceptor {
|
|
22
22
|
constructor(options = {}) {
|
|
23
|
-
this.
|
|
23
|
+
this.multer = multer(Object.assign({}, options, localOptions));
|
|
24
24
|
}
|
|
25
25
|
async intercept(context, call$) {
|
|
26
26
|
const ctx = context.switchToHttp();
|
|
27
|
-
await new Promise((resolve, reject) => this.
|
|
27
|
+
await new Promise((resolve, reject) => this.multer.array(fieldName, maxCount)(ctx.getRequest(), ctx.getResponse(), err => {
|
|
28
28
|
if (err) {
|
|
29
29
|
const error = multer_utils_1.transformException(err);
|
|
30
30
|
return reject(error);
|
package/package.json
CHANGED
package/utils/shared.utils.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export declare const isConstructor: (fn: any) => boolean;
|
|
|
6
6
|
export declare const validatePath: (path: any) => string;
|
|
7
7
|
export declare const isNil: (obj: any) => boolean;
|
|
8
8
|
export declare const isEmpty: (array: any) => boolean;
|
|
9
|
-
export declare const isSymbol: (fn: any) =>
|
|
9
|
+
export declare const isSymbol: (fn: any) => fn is symbol;
|