MCPcopy
hub / github.com/nestjs/nest / AppModule

Class AppModule

integration/nest-application/global-prefix/src/app.module.ts:10–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 controllers: [AppController],
9})
10export class AppModule {
11 private count = 0;
12 configure(consumer: MiddlewareConsumer) {
13 consumer
14 .apply((req, res, next) => res.end(MIDDLEWARE_VALUE))
15 .forRoutes({ path: MIDDLEWARE_VALUE, method: RequestMethod.GET })
16 .apply((req, res, next) => res.status(201).end(MIDDLEWARE_VALUE))
17 .forRoutes({ path: MIDDLEWARE_VALUE, method: RequestMethod.POST })
18 .apply((req, res, next) => res.end(MIDDLEWARE_PARAM_VALUE))
19 .forRoutes({
20 path: MIDDLEWARE_VALUE + '/*path',
21 method: RequestMethod.GET,
22 })
23 .apply((req, res, next) => res.status(201).end(MIDDLEWARE_PARAM_VALUE))
24 .forRoutes({
25 path: MIDDLEWARE_VALUE + '/*path',
26 method: RequestMethod.POST,
27 })
28 .apply((req, res, next) => {
29 req.extras = { data: 'Data attached in middleware' };
30 next();
31 })
32 .forRoutes({ path: '*path', method: RequestMethod.GET })
33 .apply((req, res, next) => {
34 req.middlewareParams = req.params;
35 next();
36 })
37 .forRoutes({ path: '*path', method: RequestMethod.GET })
38 .apply((req, res, next) => {
39 this.count += 1;
40 req.count = this.count;
41 next();
42 })
43 .forRoutes('*path');
44 }
45}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected