Skip to content

Commit dbfa3a4

Browse files
committed
feature(core): allow for multiple view dirs in Express
In Express, you can set a string or an array of string as base view paths. The views are looked up in the order they occur in the array. The ExpressAdapter only allowed for a single string, now it accepts an array of strings as well. closes nestjs#1513
1 parent 93b3e0b commit dbfa3a4

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

packages/common/interfaces/http/http-server.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface HttpServer {
3838
setErrorHandler?(handler: Function);
3939
setNotFoundHandler?(handler: Function);
4040
useStaticAssets?(...args: any[]): this;
41-
setBaseViewsDir?(path: string): this;
41+
setBaseViewsDir?(path: string | string[]): this;
4242
setViewEngine?(engineOrOptions: any): this;
4343
createMiddlewareFactory(
4444
method: RequestMethod,

packages/common/interfaces/nest-express-application.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ export interface INestExpressApplication {
4343
useStaticAssets(path: string, options?: ServeStaticOptions): this;
4444

4545
/**
46-
* Sets a base directory for templates (views).
46+
* Sets one or multiple base directories for templates (views).
4747
* Example `app.setBaseViewsDir('views')`
4848
*
4949
* @returns {this}
5050
*/
51-
setBaseViewsDir(path: string): this;
51+
setBaseViewsDir(path: string | string[]): this;
5252

5353
/**
5454
* Sets a view engine for templates (views).

packages/core/adapters/express-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class ExpressAdapter implements HttpServer {
126126
return this.use(express.static(path, options));
127127
}
128128

129-
setBaseViewsDir(path: string) {
129+
setBaseViewsDir(path: string | string[]) {
130130
return this.set('views', path);
131131
}
132132

packages/core/nest-application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class NestApplication extends NestApplicationContext
363363
return this;
364364
}
365365

366-
public setBaseViewsDir(path: string): this {
366+
public setBaseViewsDir(path: string | string[]): this {
367367
this.httpAdapter.setBaseViewsDir && this.httpAdapter.setBaseViewsDir(path);
368368
return this;
369369
}

0 commit comments

Comments
 (0)