4.0.2 • Published 29 days ago

@nestjs/serve-static v4.0.2

Weekly downloads
35,857
License
MIT
Repository
github
Last release
29 days ago

Description

@nestjs/serve-static package for Nest, useful to serve static content like Single Page Applications (SPA). However, if you are building MVC application or want to serve assets files (images, docs), use the useStaticAssets() method (read more here) instead.

Installation

$ npm i --save @nestjs/serve-static

Example

See full example here.

Usage

Simply import ServeStaticModule in your Nest application.

import { Module } from '@nestjs/common';
import { join } from 'path';
import { ServeStaticModule } from '@nestjs/serve-static';

@Module({
  imports: [
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'client')
    })
  ]
})
export class ApplicationModule {}

API Spec

The forRoot() method takes an options object with a few useful properties.

PropertyTypeDescription
rootPathstringStatic files root directory. Default: "client"
serveRootstringRoot path under which static app will be served. Default: ""
renderPathstring / RegExpPath to render static app (concatenated with the serveRoot value). Default: * (wildcard - all paths). Note: RegExp is not supported by the @nestjs/platform-fastify.
excludestring[]Paths to exclude when serving the static app. WARNING! Not supported by fastify. If you use fastify, you can exclude routes using regexp (set the renderPath to a regular expression) instead.
serveStaticOptionsObjectServe static options (static files)

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

@harrydang/swagger-api-docsgoheadline-cocowfj-serviceapi-doublestub-server-with-uilat_trust_app_new_enrollment@mechsoft/consolemyid-backmaccha.servergeoportal-server1coldenvhorizon-pro-api@infinitebrahmanuniverse/nolb-_nesactguide-apinestjs-dependency-graphtf-dynamic-websitefake-server-testnocodb-daily@everything-registry/sub-chunk-641tpak.wwtp.home.controllertrn-stack-kongukjae-for-training@boldare/source@nulven/nodeplotlib@no-npm/nonpmibizplayer@puzzle-js/sentryhomebridge-ambient-hue@sqrt.app/sqrt@steplix/nestjs-microservice@stryker-mutator/dashboard-backend@subql/indexer-coordinatornestcoursenestjs-monitoringnestjs-remixnestjs-remix-newnestjs-servernestjs-sequelize-crudnest-spa-serveapi-types-testnextjs-starter-server@cabinetjs/servermy-base-nest-web3@ballerine/workflows-servicemock-responses@xpr/vault@vaimee/zion@vize/cgi@zalastax/nolb-_neslucentsdblucentsdb-daily@conspireagency/nestm-shopify@comodinx/mschat-stream@audrysbut/astrea-nest@applegamer22/scr-webmos-player-cli@archsense/orakul-startermagic-proxy-clinode-signal-processingbull-react-ui@content-branch/equilibrium-generator@zmaj-js/full@utechzo-erp/coreangular-t9nangular-nest-starter@surgio/gatewayanimesyncnocodbnocodb-wooterplmt-constructor-devtoolsplayer-cli-testpluzchat-corecode-extensionotus-localizationd42paas_ideserverprincopure-file-uploaderpiximind-backcrushbar-admin-servercomic-commandercomic-commander-simple@dcupl/clidovejsdicomweb-archiveptnl-constructor-devtoolsdq-surgio-gatewayserendip-nestscrapoxy@carlosm02/nest-tempaltebotmatewhistle.modifytheta-datatihutibantruthy-api@examen-media/jsmodf-tools@foxitsoftware/web-collab-servervideo-skipperfeling87-nodejs-libs@hodfords/nestjs-swagger-helperfirefly-service@elias.schaut/webstacklib
4.0.2

29 days ago

4.0.1

3 months ago

4.0.0

11 months ago

3.0.1

1 year ago

3.0.0

2 years ago

2.2.2

3 years ago

2.1.4

3 years ago

2.1.3

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

2.0.0-next.2

4 years ago

2.0.0-next.1

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago