@nestjs/common#RequestMethod TypeScript Examples

The following examples show how to use @nestjs/common#RequestMethod. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: mikro-orm-core.module.ts    From nestjs with MIT License 6 votes vote down vote up
configure(consumer: MiddlewareConsumer): void {
    if (this.options.registerRequestContext === false) {
      return;
    }

    consumer
      .apply(MikroOrmMiddleware) // register request context automatically
      .forRoutes({ path: forRoutesPath(this.options, consumer), method: RequestMethod.ALL });
  }
Example #2
Source File: auth.module.ts    From relate with GNU General Public License v3.0 6 votes vote down vote up
configure(consumer: MiddlewareConsumer) {
        consumer.apply(cookieParser()).forRoutes('*');

        consumer
            .apply(ApiTokenMiddleware, AuthTokenMiddleware)
            .exclude(
                {
                    path: '/graphql',
                    method: RequestMethod.GET,
                },
                {
                    path: '/api-docs',
                    method: RequestMethod.GET,
                },
            )
            .forRoutes('*');
    }
Example #3
Source File: app.imports.ts    From api with GNU Affero General Public License v3.0 6 votes vote down vote up
LoggerConfig: LoggerModuleParams = {
  pinoHttp: {
    level: process.env.CLI ? 'warn' : process.env.NODE_ENV !== 'production' ? 'debug' : 'info',
    serializers: {
      error: serializeError,
    },
    transport: process.env.NODE_ENV !== 'production' || process.env.CLI  ? {
      options: {
        ignore: 'req,res,pid,hostname',
        translateTime: true,
      },
      target: 'pino-pretty',
    } : undefined,
  },
  exclude: [
    {
      method: RequestMethod.ALL,
      path: '_health',
    },
    {
      method: RequestMethod.ALL,
      path: 'favicon.ico',
    },
  ],
}
Example #4
Source File: app.module.ts    From nest-js-quiz-manager with MIT License 5 votes vote down vote up
configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(ApiTokenCheckMiddleware)
      .forRoutes({ path: '/', method: RequestMethod.ALL });
  }
Example #5
Source File: http-adapter.d.ts    From nest-jaeger with MIT License 5 votes vote down vote up
abstract createMiddlewareFactory(requestMethod: RequestMethod): (path: string, callback: Function) => any;
Example #6
Source File: router-execution-context.d.ts    From nest-jaeger with MIT License 5 votes vote down vote up
create(instance: Controller, callback: (...args: any[]) => unknown, methodName: string, moduleKey: string, requestMethod: RequestMethod, contextId?: import("..").ContextId, inquirerId?: string): <TRequest, TResponse>(req: TRequest, res: TResponse, next: Function) => Promise<void>;
Example #7
Source File: router-execution-context.d.ts    From nest-jaeger with MIT License 5 votes vote down vote up
getMetadata<TContext extends ContextType = ContextType>(instance: Controller, callback: (...args: any[]) => any, methodName: string, moduleKey: string, requestMethod: RequestMethod, contextType: TContext): HandlerMetadata;
Example #8
Source File: router-response-controller.d.ts    From nest-jaeger with MIT License 5 votes vote down vote up
getStatusByMethod(requestMethod: RequestMethod): number;
Example #9
Source File: app.module.ts    From edu-server with MIT License 5 votes vote down vote up
configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(PreauthMiddleware)
      .exclude(
        {
          path: 'course/(.*)',
          method: RequestMethod.GET,
        },
        {
          path: 'user/gamification',
          method: RequestMethod.GET,
        },
        {
          path: 'Doubt/(.*)',
          method: RequestMethod.GET,
        },
        {
          path: 'Doubt',
          method: RequestMethod.GET,
        },
        {
          path: 'Announcement/(.*)',
          method: RequestMethod.GET,
        },
        {
          path: 'Announcement',
          method: RequestMethod.GET,
        },
        {
          path: 'Mentor/(.*)',
          method: RequestMethod.GET,
        },
        {
          path: 'Mentor',
          method: RequestMethod.GET,
        },
      )
      .forRoutes({
        path: '*',
        method: RequestMethod.ALL,
      });
  }
Example #10
Source File: app.module.ts    From life-helper-backend with MIT License 5 votes vote down vote up
configure(consumer: MiddlewareConsumer): MiddlewareConsumer | void {
    /** 中间件列表 */
    const middlewares = [AuthMiddleware]

    consumer.apply(...middlewares).forRoutes({ path: '*', method: RequestMethod.ALL })
  }
Example #11
Source File: app.module.ts    From ironfish-api with Mozilla Public License 2.0 5 votes vote down vote up
configure(consumer: MiddlewareConsumer): void {
    consumer
      .apply(RequireSslMiddleware, ContextMiddleware)
      .forRoutes({ path: '*', method: RequestMethod.ALL });
  }
Example #12
Source File: sessions.module.ts    From coronatest with GNU Affero General Public License v3.0 5 votes vote down vote up
@Module({
    imports: [
        SessionModule.forRootAsync({
            inject: [ConfigService],
            useFactory: async (configService: ConfigService): Promise<NestSessionOptions> => {
                let SequelizeStore = ConnectSessionSequelize(session.Store);
                let sequelize = new Sequelize({
                    dialect: 'postgres',
                    host: configService.get<string>('postgres.host'),
                    port: +configService.get('postgres.port'),
                    username: configService.get<string>('postgres.username'),
                    password: configService.get<string>('postgres.password'),
                    database: configService.get<string>('postgres.database'),
                    logging: false,
                    define: {
                        paranoid: true,
                        underscored: true
                    }
                });
                let store = new SequelizeStore({
                    db: sequelize,
                    tableName: 'sessions',
                    expiration: 2592000000
                });
                store.sync();
                return {
                    session: {
                        store,
                        secret: configService.get('sessionSecret'),
                        cookie: {
                            maxAge: 2592000000,
                            httpOnly: true
                        }
                    },
                    forRoutes: [
                        { path: 'submissions', method: RequestMethod.POST }
                    ]
                };
            }
        })
    ],
    controllers: [SessionsController]
})
export class SessionsModule {}
Example #13
Source File: mikro-orm-middleware.module.ts    From nestjs with MIT License 5 votes vote down vote up
configure(consumer: MiddlewareConsumer): void {
    consumer
      .apply(MultipleMikroOrmMiddleware)
      .forRoutes({ path: forRoutesPath(this.options, consumer), method: RequestMethod.ALL });
  }