How to use @nestjs/serve-static - 4 common examples

To help you get started, we’ve selected a few @nestjs/serve-static examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CatsMiaow / node-nestjs-structure / src / app.module.ts View on Github external
}),
    // Database
    // https://docs.nestjs.com/techniques/database
    TypeOrmModule.forRootAsync({
      useFactory: async (config: ConfigService) => ({
        entities: [`${__dirname}/entity/**/*.{js,ts}`],
        subscribers: [`${__dirname}/subscriber/**/*.{js,ts}`],
        migrations: [`${__dirname}/migration/**/*.{js,ts}`],
        ...config.get('db')
      }),
      inject: [ConfigService]
    }),
    // Static Folder
    // https://docs.nestjs.com/recipes/serve-static
    // https://docs.nestjs.com/techniques/mvc
    ServeStaticModule.forRoot({
      rootPath: `${__dirname}/../public`,
      renderPath: '/'
    }),
    // Module Router
    // https://github.com/nestjsx/nest-router
    RouterModule.forRoutes([{
      path: 'aws',
      module: AWSModule
    }, {
      path: 'test',
      module: SampleModule
    }]),
    // Service Modules
    CommonModule, // Global
    BaseModule,
    AWSModule,
github mythal / boluo / server / src / app.module.ts View on Github external
autoSchemaFile: '../schema.graphql',
    // GraphQL Subscriptions authentication https://github.com/nestjs/docs.nestjs.com/issues/394
    context: ({ req, connection }) => (connection ? { req: { headers: connection.context } } : { req }),
    installSubscriptionHandlers: true,
    debug: DEBUG,
  }),
  TypeOrmModule.forFeature([Message, User, Channel, Member, Invitation, Media]),
  JwtModule.register({
    secret: JWT_SECRET,
    signOptions: { expiresIn: JWT_EXPIRES_IN },
  }),
];

if (DEBUG) {
  const rootPath = join(__dirname, '../../web/dist');
  imports.unshift(ServeStaticModule.forRoot({ rootPath }));
}

@Module({
  imports,
  controllers: [MediaController],
  providers: [
    DateScalar,
    RedisService,
    UserService,
    MediaService,
    MessageService,
    MediaResolver,
    ChannelResolver,
    ChannelService,
    MessageResolver,
    UserResolver,
github nestjs / nest / sample / 24-serve-static / src / app.module.ts View on Github external
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 AppModule {}
github nestjs / serve-static / schematics / install / files / root / server / app.module.ts View on Github external
import { Module } from '@nestjs/common';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';

@Module({
  imports: [
    ServeStaticModule.forRoot({
      rootPath: '',
      viewsPath: join(process.cwd(), '<%= getBrowserDistDirectory() %>'),
      bundle: require('../server/main'),
      liveReload: true
    })
  ]
})
export class ApplicationModule {}

@nestjs/serve-static

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

MIT
Latest version published 8 months ago

Package Health Score

76 / 100
Full package analysis

Popular @nestjs/serve-static functions

Similar packages