MCPcopy
hub / github.com/nestjs/swagger / serveStatic

Method serveStatic

lib/swagger-module.ts:98–121  ·  view source on GitHub ↗
(
    finalPath: string,
    app: INestApplication,
    customStaticPath?: string
  )

Source from the content-addressed store, hash-verified

96 }
97
98 protected static serveStatic(
99 finalPath: string,
100 app: INestApplication,
101 customStaticPath?: string
102 ) {
103 const httpAdapter = app.getHttpAdapter();
104
105 // See <https://github.com/nestjs/swagger/issues/2543>
106 const swaggerAssetsPath = customStaticPath
107 ? resolvePath(customStaticPath)
108 : getSwaggerAssetsAbsoluteFSPath();
109
110 if (httpAdapter && httpAdapter.getType() === 'fastify') {
111 (app as NestFastifyApplication).useStaticAssets({
112 root: swaggerAssetsPath,
113 prefix: finalPath,
114 decorateReply: false
115 });
116 } else {
117 (app as NestExpressApplication).useStaticAssets(swaggerAssetsPath, {
118 prefix: finalPath
119 });
120 }
121 }
122
123 protected static serveDocuments(
124 finalPath: string,

Callers 1

setupMethod · 0.80

Calls 2

resolvePathFunction · 0.90

Tested by

no test coverage detected