New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nestjs/serve-static

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/serve-static

Nest - modern, fast, powerful node.js web framework (@serve-static)

  • 2.2.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @nestjs/serve-static?

@nestjs/serve-static is a package for the NestJS framework that allows you to serve static assets such as HTML, CSS, JavaScript, and image files. It integrates seamlessly with NestJS applications, making it easy to serve static content alongside your API endpoints.

What are @nestjs/serve-static's main functionalities?

Serve Static Files

This feature allows you to serve static files from a specified directory. In this example, the static files are served from the 'public' directory.

const { Module } = require('@nestjs/common');
const { ServeStaticModule } = require('@nestjs/serve-static');
const { join } = require('path');

@Module({
  imports: [
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'public'), // path to the static files
    }),
  ],
})
export class AppModule {}

Serve Multiple Static Directories

This feature allows you to serve static files from multiple directories. In this example, static files are served from both the 'public' and 'assets' directories.

const { Module } = require('@nestjs/common');
const { ServeStaticModule } = require('@nestjs/serve-static');
const { join } = require('path');

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

Serve Static Files with Custom Route

This feature allows you to serve static files with a custom route. In this example, the static files in the 'public' directory are served under the '/static' route.

const { Module } = require('@nestjs/common');
const { ServeStaticModule } = require('@nestjs/serve-static');
const { join } = require('path');

@Module({
  imports: [
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'public'),
      serveRoot: '/static', // custom route
    }),
  ],
})
export class AppModule {}

Other packages similar to @nestjs/serve-static

FAQs

Package last updated on 07 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc