@nestjs/platform-express

  • Version 9.3.12
  • Published
  • 61.9 kB
  • 5 dependencies
  • MIT license

Install

npm i @nestjs/platform-express
yarn add @nestjs/platform-express
pnpm add @nestjs/platform-express

Overview

Nest - modern, fast, powerful node.js web framework (@platform-express)

Index

Functions

function AnyFilesInterceptor

AnyFilesInterceptor: (localOptions?: MulterOptions) => Type<NestInterceptor>;

    function FileFieldsInterceptor

    FileFieldsInterceptor: (
    uploadFields: MulterField[],
    localOptions?: MulterOptions
    ) => Type<NestInterceptor>;

      function FileInterceptor

      FileInterceptor: (
      fieldName: string,
      localOptions?: MulterOptions
      ) => Type<NestInterceptor>;

        function FilesInterceptor

        FilesInterceptor: (
        fieldName: string,
        maxCount?: number,
        localOptions?: MulterOptions
        ) => Type<NestInterceptor>;

          Classes

          class ExpressAdapter

          class ExpressAdapter extends AbstractHttpAdapter {}

          constructor

          constructor(instance?: any);

            method applyVersionFilter

            applyVersionFilter: (
            handler: Function,
            version: VersionValue,
            versioningOptions: VersioningOptions
            ) => VersionedRoute;

              method close

              close: () => Promise<unknown>;

                method createMiddlewareFactory

                createMiddlewareFactory: (
                requestMethod: RequestMethod
                ) => (path: string, callback: Function) => any;

                  method disable

                  disable: (...args: any[]) => any;

                    method enable

                    enable: (...args: any[]) => any;

                      method enableCors

                      enableCors: (options: CorsOptions | CorsOptionsDelegate<any>) => any;

                        method end

                        end: (response: any, message?: string) => any;

                          method engine

                          engine: (...args: any[]) => any;

                            method getRequestHostname

                            getRequestHostname: (request: any) => string;

                              method getRequestMethod

                              getRequestMethod: (request: any) => string;

                                method getRequestUrl

                                getRequestUrl: (request: any) => string;

                                  method getType

                                  getType: () => string;

                                    method initHttpServer

                                    initHttpServer: (options: NestApplicationOptions) => void;

                                      method isHeadersSent

                                      isHeadersSent: (response: any) => boolean;

                                        method listen

                                        listen: {
                                        (port: string | number, callback?: () => void): Server;
                                        (port: string | number, hostname: string, callback?: () => void): Server;
                                        };

                                          method redirect

                                          redirect: (response: any, statusCode: number, url: string) => any;

                                            method registerParserMiddleware

                                            registerParserMiddleware: (prefix?: string, rawBody?: boolean) => void;

                                              method render

                                              render: (response: any, view: string, options: any) => any;

                                                method reply

                                                reply: (response: any, body: any, statusCode?: number) => any;

                                                  method set

                                                  set: (...args: any[]) => any;

                                                    method setBaseViewsDir

                                                    setBaseViewsDir: (path: string | string[]) => any;

                                                      method setErrorHandler

                                                      setErrorHandler: (handler: Function, prefix?: string) => any;

                                                        method setHeader

                                                        setHeader: (response: any, name: string, value: string) => any;

                                                          method setLocal

                                                          setLocal: (key: string, value: any) => this;

                                                            method setNotFoundHandler

                                                            setNotFoundHandler: (handler: Function, prefix?: string) => any;

                                                              method setViewEngine

                                                              setViewEngine: (engine: string) => any;

                                                                method status

                                                                status: (response: any, statusCode: number) => any;

                                                                  method useBodyParser

                                                                  useBodyParser: <Options extends bodyparser.Options = bodyparser.Options>(
                                                                  type: keyof bodyparser.BodyParser,
                                                                  rawBody: boolean,
                                                                  options?: NestExpressBodyParserOptions<Options>
                                                                  ) => this;

                                                                    method useStaticAssets

                                                                    useStaticAssets: (path: string, options: ServeStaticOptions) => any;

                                                                      class MulterModule

                                                                      class MulterModule {}

                                                                        method register

                                                                        static register: (options?: MulterModuleOptions) => DynamicModule;

                                                                          method registerAsync

                                                                          static registerAsync: (options: MulterModuleAsyncOptions) => DynamicModule;

                                                                            Interfaces

                                                                            interface MulterModuleAsyncOptions

                                                                            interface MulterModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {}

                                                                              property inject

                                                                              inject?: any[];

                                                                                property useClass

                                                                                useClass?: Type<MulterOptionsFactory>;

                                                                                  property useExisting

                                                                                  useExisting?: Type<MulterOptionsFactory>;

                                                                                    property useFactory

                                                                                    useFactory?: (
                                                                                    ...args: any[]
                                                                                    ) => Promise<MulterModuleOptions> | MulterModuleOptions;

                                                                                      interface MulterOptionsFactory

                                                                                      interface MulterOptionsFactory {}

                                                                                        method createMulterOptions

                                                                                        createMulterOptions: () => Promise<MulterModuleOptions> | MulterModuleOptions;

                                                                                          interface NestExpressApplication

                                                                                          interface NestExpressApplication extends INestApplication {}
                                                                                          • Interface describing methods on NestExpressApplication.

                                                                                            See Also

                                                                                            • [Platform](https://docs.nestjs.com/first-steps#platform)

                                                                                          method disable

                                                                                          disable: (...args: any[]) => this;
                                                                                          • A wrapper function around native express.disable() method.

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.disable('x-powered-by')

                                                                                          method enable

                                                                                          enable: (...args: any[]) => this;
                                                                                          • A wrapper function around native express.enable() method.

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.enable('x-powered-by')

                                                                                          method engine

                                                                                          engine: (...args: any[]) => this;
                                                                                          • A wrapper function around native express.engine() method.

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.engine('mustache', mustacheExpress())

                                                                                          method listen

                                                                                          listen: {
                                                                                          (port: number | string, callback?: () => void): Promise<Server>;
                                                                                          (
                                                                                          port: string | number,
                                                                                          hostname: string,
                                                                                          callback?: () => void
                                                                                          ): Promise<Server>;
                                                                                          };
                                                                                          • Starts the application.

                                                                                            Parameter port

                                                                                            Parameter hostname

                                                                                            Parameter callback

                                                                                            Optional callback

                                                                                            Returns

                                                                                            {Promise} A Promise that, when resolved, is a reference to the underlying HttpServer.

                                                                                          method set

                                                                                          set: (...args: any[]) => this;
                                                                                          • A wrapper function around native express.set() method.

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.set('trust proxy', 'loopback')

                                                                                          method setBaseViewsDir

                                                                                          setBaseViewsDir: (path: string | string[]) => this;
                                                                                          • Sets one or multiple base directories for templates (views).

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.setBaseViewsDir('views')

                                                                                          method setLocal

                                                                                          setLocal: (key: string, value: any) => this;
                                                                                          • Sets app-level globals for view templates.

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.setLocal('title', 'My Site')

                                                                                            See Also

                                                                                            • https://expressjs.com/en/4x/api.html#app.locals

                                                                                          method setViewEngine

                                                                                          setViewEngine: (engine: string) => this;
                                                                                          • Sets a view engine for templates (views).

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.setViewEngine('pug')

                                                                                          method useBodyParser

                                                                                          useBodyParser: <Options extends bodyparser.Options = bodyparser.Options>(
                                                                                          parser: keyof bodyparser.BodyParser,
                                                                                          options?: NestExpressBodyParserOptions<Options>
                                                                                          ) => this;
                                                                                          • Register Express body parsers on the fly. Will respect the application's rawBody option.

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            const app = await NestFactory.create( AppModule, { rawBody: true } ); app.useBodyParser('json', { limit: '50mb' });

                                                                                          method useStaticAssets

                                                                                          useStaticAssets: {
                                                                                          (options: ServeStaticOptions): this;
                                                                                          (path: string, options?: ServeStaticOptions): this;
                                                                                          };
                                                                                          • Sets a base directory for public assets.

                                                                                            Returns

                                                                                            {this}

                                                                                            Example 1

                                                                                            app.useStaticAssets('public')

                                                                                          Type Aliases

                                                                                          type MulterModuleOptions

                                                                                          type MulterModuleOptions = MulterOptions;

                                                                                            type NestExpressBodyParserOptions

                                                                                            type NestExpressBodyParserOptions<T extends Options = Options> = Omit<T, 'verify'>;

                                                                                              Package Files (10)

                                                                                              Dependencies (5)

                                                                                              Dev Dependencies (2)

                                                                                              Peer Dependencies (2)

                                                                                              Badge

                                                                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@nestjs/platform-express.

                                                                                              • Markdown
                                                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@nestjs/platform-express)
                                                                                              • HTML
                                                                                                <a href="https://www.jsdocs.io/package/@nestjs/platform-express"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>