Skip to content

Commit

Permalink
chore(release) publish v4.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Feb 11, 2018
1 parent 5fe7963 commit a2a00ad
Show file tree
Hide file tree
Showing 104 changed files with 1,464 additions and 187 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
## 4.6.0
- **common**: [feature] `ValidationPipe` improvements #388
- **common**: [feature] `ParseIntPipe` improvements #85
- **core***: [feature] add `app.disable()` and `app.enable()` wrappers around `express` app
- **common**: [feature] add `FileInterceptor`, `FilesInterceptor`, `@UploadedFile()` and `@UploadedFiles()` (`multer` integration)
- **common**: [feature] add `HttpModule` that exposes `HttpService` (`axios` integration)
- **core**: [feature] add `app.disable()` and `app.enable()` wrappers around `express` app
- **core**: [feature] add ability to inject `express` reference (`EXPRESS_REF` token)
- **core**: [feature] enable possibility to extend metadata (inheritance support) #228
- **core**: [feature] `NestFactory.create()` now accepts third argument `HttpsOptions`
- **core**: [feature] add `app.enableCors()` to `INestApplication` (`cors` integration)
- **core**: [feature] add `@Render()` decorator (MVC applications)
- **core**: [feature] provide `Logger.overrideLogger()` #247
- **core**: [improvement] simplify HTTPS usage
- **core**: [bugfix] custom transport strategy - thrown exceptions issue #290
- **core**: [bugfix] injector fails silently #287
- **core**: [bugfix] secure websockets (`wss://`) #384
- **core**: [bugfix] can't select/get from context when using `NestFactory.createMicroservice()` #398
- **core**: [bugfix] interceptor `$stream` observable returns another observable instead of the response object #376
- **core**: [bugfix] `Observable.throw` from controller results in unhandled rejection promise #373
- **microservices**: [feature]: add `listenAsync()` to `INestMicroservice` instance

## 4.5.10
- **core**: [bugfix] #343
Expand Down
6 changes: 5 additions & 1 deletion examples/03-microservices/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { Transport } from '@nestjs/microservices';
import { ApplicationModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.createMicroservice(ApplicationModule);
await app.listenAsync();

/** Hybrid application (HTTP + (n)Microservices)
const app = await NestFactory.create(ApplicationModule);
app.connectMicroservice({
transport: Transport.TCP,
});
await app.startAllMicroservicesAsync();
await app.listen(3001);
await app.listen(3001); */
}
bootstrap();
9 changes: 5 additions & 4 deletions examples/15-mvc/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Get, Controller, Res } from '@nestjs/common';
import { Get, Controller, Render } from '@nestjs/common';

@Controller()
export class AppController {
@Get()
root(@Res() res) {
res.render('index', { message: 'Hello world!' });
@Get()
@Render('index')
root() {
return { message: 'Hello world!' };
}
}
2 changes: 1 addition & 1 deletion examples/15-mvc/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { AppController } from './app.controller';

@Module({
modules: [],
imports: [],
controllers: [AppController],
components: [],
})
Expand Down
2 changes: 2 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ gulp.task('move', function() {
gulp.dest('examples/11-swagger/node_modules/@nestjs')
).pipe(
gulp.dest('examples/12-graphql-apollo/node_modules/@nestjs')
).pipe(
gulp.dest('examples/15-mvc/node_modules/@nestjs')
);
});
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages": [
"lib/*"
],
"version": "4.6.0"
"version": "4.5.9"
}
1 change: 1 addition & 0 deletions lib/common/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export declare const EXCEPTION_FILTERS_METADATA = "__exceptionFilters__";
export declare const FILTER_CATCH_EXCEPTIONS = "__filterCatchExceptions__";
export declare const PIPES_METADATA = "__pipes__";
export declare const GUARDS_METADATA = "__guards__";
export declare const RENDER_METADATA = "__renderTemplate__";
export declare const INTERCEPTORS_METADATA = "__interceptors__";
export declare const HTTP_CODE_METADATA = "__httpCode__";
export declare const GATEWAY_MIDDLEWARES = "__gatewayMiddlewares";
Expand Down
1 change: 1 addition & 0 deletions lib/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exports.EXCEPTION_FILTERS_METADATA = '__exceptionFilters__';
exports.FILTER_CATCH_EXCEPTIONS = '__filterCatchExceptions__';
exports.PIPES_METADATA = '__pipes__';
exports.GUARDS_METADATA = '__guards__';
exports.RENDER_METADATA = '__renderTemplate__';
exports.INTERCEPTORS_METADATA = '__interceptors__';
exports.HTTP_CODE_METADATA = '__httpCode__';
exports.GATEWAY_MIDDLEWARES = '__gatewayMiddlewares';
Expand Down
1 change: 1 addition & 0 deletions lib/common/decorators/http/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './request-mapping.decorator';
export * from './route-params.decorator';
export * from './http-code.decorator';
export * from './create-route-param-metadata.decorator';
export * from './render.decorator';
1 change: 1 addition & 0 deletions lib/common/decorators/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __export(require("./request-mapping.decorator"));
__export(require("./route-params.decorator"));
__export(require("./http-code.decorator"));
__export(require("./create-route-param-metadata.decorator"));
__export(require("./render.decorator"));
5 changes: 5 additions & 0 deletions lib/common/decorators/http/render.decorator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'reflect-metadata';
/**
* Defines a template that should be rendered by a controller.
*/
export declare function Render(template: string): MethodDecorator;
14 changes: 14 additions & 0 deletions lib/common/decorators/http/render.decorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const constants_1 = require("../../constants");
/**
* Defines a template that should be rendered by a controller.
*/
function Render(template) {
return (target, key, descriptor) => {
Reflect.defineMetadata(constants_1.RENDER_METADATA, template, descriptor.value);
return descriptor;
};
}
exports.Render = Render;
2 changes: 2 additions & 0 deletions lib/common/decorators/http/route-params.decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export declare const Request: () => ParameterDecorator;
export declare const Response: () => ParameterDecorator;
export declare const Next: () => ParameterDecorator;
export declare const Session: () => ParameterDecorator;
export declare const UploadedFile: () => ParameterDecorator;
export declare const UploadedFiles: () => ParameterDecorator;
export declare const Headers: (property?: string) => ParameterDecorator;
export declare function Query(): any;
export declare function Query(...pipes: PipeTransform<any>[]): any;
Expand Down
2 changes: 2 additions & 0 deletions lib/common/decorators/http/route-params.decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ exports.Request = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamty
exports.Response = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.RESPONSE);
exports.Next = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.NEXT);
exports.Session = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.SESSION);
exports.UploadedFile = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILE);
exports.UploadedFiles = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILES);
exports.Headers = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.HEADERS);
function Query(property, ...pipes) {
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.QUERY)(property, ...pipes);
Expand Down
1 change: 1 addition & 0 deletions lib/common/enums/http-status.enum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export declare enum HttpStatus {
UNSUPPORTED_MEDIA_TYPE = 415,
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
EXPECTATION_FAILED = 417,
I_AM_A_TEAPOT = 418,
UNPROCESSABLE_ENTITY = 422,
TOO_MANY_REQUESTS = 429,
INTERNAL_SERVER_ERROR = 500,
Expand Down
1 change: 1 addition & 0 deletions lib/common/enums/http-status.enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var HttpStatus;
HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
Expand Down
2 changes: 2 additions & 0 deletions lib/common/enums/route-paramtypes.enum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export declare enum RouteParamtypes {
PARAM = 5,
HEADERS = 6,
SESSION = 7,
FILE = 8,
FILES = 9,
}
2 changes: 2 additions & 0 deletions lib/common/enums/route-paramtypes.enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ var RouteParamtypes;
RouteParamtypes[RouteParamtypes["PARAM"] = 5] = "PARAM";
RouteParamtypes[RouteParamtypes["HEADERS"] = 6] = "HEADERS";
RouteParamtypes[RouteParamtypes["SESSION"] = 7] = "SESSION";
RouteParamtypes[RouteParamtypes["FILE"] = 8] = "FILE";
RouteParamtypes[RouteParamtypes["FILES"] = 9] = "FILES";
})(RouteParamtypes = exports.RouteParamtypes || (exports.RouteParamtypes = {}));
2 changes: 2 additions & 0 deletions lib/common/http/http.module.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare class HttpModule {
}
19 changes: 19 additions & 0 deletions lib/common/http/http.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
const module_decorator_1 = require("../decorators/modules/module.decorator");
const http_service_1 = require("./http.service");
let HttpModule = class HttpModule {
};
HttpModule = __decorate([
module_decorator_1.Module({
components: [http_service_1.HttpService],
exports: [http_service_1.HttpService],
})
], HttpModule);
exports.HttpModule = HttpModule;
12 changes: 12 additions & 0 deletions lib/common/http/http.service.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Observable } from 'rxjs/Observable';
import { AxiosRequestConfig, AxiosResponse } from './interfaces/axios.interfaces';
import 'rxjs/add/observable/fromPromise';
export declare class HttpService {
request<T = any>(config: AxiosRequestConfig): Observable<AxiosResponse<T>>;
get<T = any>(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
delete(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
head(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
post(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
put(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
patch(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
}
29 changes: 29 additions & 0 deletions lib/common/http/http.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = require("axios");
const Observable_1 = require("rxjs/Observable");
require("rxjs/add/observable/fromPromise");
class HttpService {
request(config) {
return Observable_1.Observable.fromPromise(axios_1.default.request(config));
}
get(url, config) {
return Observable_1.Observable.fromPromise(axios_1.default.get(url, config));
}
delete(url, config) {
return Observable_1.Observable.fromPromise(axios_1.default.delete(url, config));
}
head(url, config) {
return Observable_1.Observable.fromPromise(axios_1.default.head(url, config));
}
post(url, data, config) {
return Observable_1.Observable.fromPromise(axios_1.default.post(url, data, config));
}
put(url, data, config) {
return Observable_1.Observable.fromPromise(axios_1.default.post(url, data, config));
}
patch(url, data, config) {
return Observable_1.Observable.fromPromise(axios_1.default.post(url, data, config));
}
}
exports.HttpService = HttpService;
2 changes: 2 additions & 0 deletions lib/common/http/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './http.module';
export * from './http.service';
7 changes: 7 additions & 0 deletions lib/common/http/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./http.module"));
__export(require("./http.service"));
109 changes: 109 additions & 0 deletions lib/common/http/interfaces/axios.interfaces.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
export interface AxiosTransformer {
(data: any, headers?: any): any;
}
export interface AxiosAdapter {
(config: AxiosRequestConfig): AxiosPromise<any>;
}
export interface AxiosBasicCredentials {
username: string;
password: string;
}
export interface AxiosProxyConfig {
host: string;
port: number;
}
export interface AxiosRequestConfig {
url?: string;
method?: string;
baseURL?: string;
transformRequest?: AxiosTransformer | AxiosTransformer[];
transformResponse?: AxiosTransformer | AxiosTransformer[];
headers?: any;
params?: any;
paramsSerializer?: (params: any) => string;
data?: any;
timeout?: number;
withCredentials?: boolean;
adapter?: AxiosAdapter;
auth?: AxiosBasicCredentials;
responseType?: string;
xsrfCookieName?: string;
xsrfHeaderName?: string;
onUploadProgress?: (progressEvent: any) => void;
onDownloadProgress?: (progressEvent: any) => void;
maxContentLength?: number;
validateStatus?: (status: number) => boolean;
maxRedirects?: number;
httpAgent?: any;
httpsAgent?: any;
proxy?: AxiosProxyConfig;
cancelToken?: CancelToken;
}
export interface AxiosResponse<T = any> {
data: T;
status: number;
statusText: string;
headers: any;
config: AxiosRequestConfig;
request?: any;
}
export interface AxiosError extends Error {
config: AxiosRequestConfig;
code?: string;
request?: any;
response?: AxiosResponse;
}
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
}
export interface CancelStatic {
new (message?: string): Cancel;
}
export interface Cancel {
message: string;
}
export interface Canceler {
(message?: string): void;
}
export interface CancelTokenStatic {
new (executor: (cancel: Canceler) => void): CancelToken;
source(): CancelTokenSource;
}
export interface CancelToken {
promise: Promise<Cancel>;
reason?: Cancel;
throwIfRequested(): void;
}
export interface CancelTokenSource {
token: CancelToken;
cancel: Canceler;
}
export interface AxiosInterceptorManager<V> {
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
eject(id: number): void;
}
export interface AxiosInstance {
defaults: AxiosRequestConfig;
interceptors: {
request: AxiosInterceptorManager<AxiosRequestConfig>;
response: AxiosInterceptorManager<AxiosResponse>;
};
request<T = any>(config: AxiosRequestConfig): AxiosPromise<T>;
get<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>;
delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
head(url: string, config?: AxiosRequestConfig): AxiosPromise;
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
}
export interface AxiosStatic extends AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise;
(url: string, config?: AxiosRequestConfig): AxiosPromise;
create(config?: AxiosRequestConfig): AxiosInstance;
Cancel: CancelStatic;
CancelToken: CancelTokenStatic;
isCancel(value: any): boolean;
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
}
declare const Axios: AxiosStatic;
export default Axios;
3 changes: 3 additions & 0 deletions lib/common/http/interfaces/axios.interfaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Axios;
1 change: 1 addition & 0 deletions lib/common/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './decorators';
export * from './enums';
export { NestModule, INestApplication, INestMicroservice, MiddlewareConfigProxy, MiddlewareConfiguration, NestMiddleware, ExpressMiddleware, MiddlewaresConsumer, OnModuleInit, ExceptionFilter, WebSocketAdapter, PipeTransform, Paramtype, ArgumentMetadata, OnModuleDestroy, ExecutionContext, CanActivate, RpcExceptionFilter, WsExceptionFilter, NestInterceptor, DynamicModule, INestApplicationContext } from './interfaces';
export * from './interceptors';
export * from './services/logger.service';
export * from './pipes';
export * from './utils';
Expand Down
1 change: 1 addition & 0 deletions lib/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function __export(m) {
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./decorators"));
__export(require("./enums"));
__export(require("./interceptors"));
__export(require("./services/logger.service"));
__export(require("./pipes"));
__export(require("./utils"));
Expand Down
8 changes: 8 additions & 0 deletions lib/common/interceptors/file.interceptor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Observable } from 'rxjs/Observable';
import { MulterOptions } from '../interfaces/external/multer-options.interface';
export declare function FileInterceptor(fieldName: string, options?: MulterOptions): {
new (): {
readonly upload: any;
intercept(request: any, context: any, stream$: Observable<any>): Promise<Observable<any>>;
};
};
Loading

0 comments on commit a2a00ad

Please sign in to comment.