Skip to content

Commit

Permalink
feat(platform-express): Add documentation for public API
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbiundo authored and BrunnerLivio committed Aug 26, 2019
1 parent 479eb2c commit e9ecb5e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,59 +1,76 @@
import { INestApplication } from '@nestjs/common';
import { ServeStaticOptions } from './serve-static-options.interface';

/**
* Interface describing methods on NestExpressApplication.
*
* @see [Platform](https://docs.nestjs.com/first-steps#platform)
*
* @publicApi
*/
export interface NestExpressApplication extends INestApplication {
/**
* A wrapper function around native `express.set()` method.
* Example `app.set('trust proxy', 'loopback')`
*
* @example
* app.set('trust proxy', 'loopback')
*
* @returns {this}
*/
set(...args: any[]): this;

/**
* A wrapper function around native `express.engine()` method.
* Example `app.engine('mustache', mustacheExpress())`
* @example
* app.engine('mustache', mustacheExpress())
*
* @returns {this}
*/
engine(...args: any[]): this;

/**
* A wrapper function around native `express.enable()` method.
* Example `app.enable('x-powered-by')`
* @example
* app.enable('x-powered-by')
*
* @returns {this}
*/
enable(...args: any[]): this;

/**
* A wrapper function around native `express.disable()` method.
* Example `app.disable('x-powered-by')`
*
* @example
* app.disable('x-powered-by')
*
* @returns {this}
*/
disable(...args: any[]): this;

useStaticAssets(options: ServeStaticOptions): this;
/**
* Sets a base directory for public assets.
* Example `app.useStaticAssets('public')
* @example
* app.useStaticAssets('public')
*
* @returns {this}
*/
useStaticAssets(options: ServeStaticOptions): this;
useStaticAssets(path: string, options?: ServeStaticOptions): this;

/**
* Sets one or multiple base directories for templates (views).
* Example `app.setBaseViewsDir('views')`
*
* @example
* app.setBaseViewsDir('views')
*
* @returns {this}
*/
setBaseViewsDir(path: string | string[]): this;

/**
* Sets a view engine for templates (views).
* Example `app.setViewEngine('pug')`
* @example
* app.setViewEngine('pug')
*
* @returns {this}
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/**
* @see https://www.npmjs.com/package/@types/serve-static
* Interface describing options for serving static assets.
*
* @see [Serving static files in Express](https://expressjs.com/en/starter/static-files.html)
* @see [Model-View-Controller](https://docs.nestjs.com/techniques/mvc)
*
* @publicApi
*/
export interface ServeStaticOptions {
/**
Expand Down Expand Up @@ -60,10 +65,10 @@ export interface ServeStaticOptions {

/**
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
* The function is called as fn(res, path, stat), where the arguments are:
* res the response object
* path the file path that is being sent
* stat the stat object of the file that is being sent
* The function is called as `fn(res, path, stat)`, where the arguments are:
* `res` - the response object
* `path` - the file path that is being sent
* `stat` - the stat object of the file that is being sent
*/
setHeaders?: (res: any, path: string, stat: any) => any;

Expand Down

0 comments on commit e9ecb5e

Please sign in to comment.