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

Function use

packages/platform-fastify/adapters/middie/fastify-middie.ts:64–95  ·  view source on GitHub ↗
(
    this: unknown,
    url:
      | string
      | null
      | MiddlewareFn<Req, Res, Ctx>
      | MiddlewareFn<Req, Res, Ctx>[],
    f?: MiddlewareFn<Req, Res, Ctx> | MiddlewareFn<Req, Res, Ctx>[],
  )

Source from the content-addressed store, hash-verified

62 };
63
64 function use(
65 this: unknown,
66 url:
67 | string
68 | null
69 | MiddlewareFn<Req, Res, Ctx>
70 | MiddlewareFn<Req, Res, Ctx>[],
71 f?: MiddlewareFn<Req, Res, Ctx> | MiddlewareFn<Req, Res, Ctx>[],
72 ) {
73 if (f === undefined) {
74 f = url as MiddlewareFn<Req, Res, Ctx> | MiddlewareFn<Req, Res, Ctx>[];
75 url = null;
76 }
77
78 let regexp: RegExp | undefined;
79 if (typeof url === 'string') {
80 const pathRegExp = pathToRegexp(sanitizePrefixUrl(url) as Path, {
81 end: false,
82 });
83 regexp = pathRegExp.regexp;
84 }
85
86 if (Array.isArray(f)) {
87 for (const val of f) {
88 middlewares.push({ regexp, fn: val });
89 }
90 } else {
91 middlewares.push({ regexp, fn: f });
92 }
93
94 return this;
95 }
96
97 function run(
98 req: Req,

Callers

nothing calls this directly

Calls 2

sanitizePrefixUrlFunction · 0.85
useMethod · 0.65

Tested by

no test coverage detected