All files / packages/adapters/nestjs/src index.ts

0% Statements 0/25
100% Branches 1/1
100% Functions 1/1
0% Lines 0/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                                         
import type { ServerOptions } from '@https-enable/core'
import type { NestExpressApplication } from '@nestjs/platform-express'
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
import { HttpsAdapter } from '@https-enable/core'
 
type ExpressApp = ReturnType<ReturnType<NestExpressApplication['getHttpAdapter']>['getInstance']>
export class NestJsExpressHttpsAdapter extends HttpsAdapter<ExpressApp> {
  constructor(public nestApp: NestExpressApplication) {
    super()
  }
 
  init = async () => {
    await this.nestApp.init()
    return this.nestApp.getHttpAdapter().getInstance()
  }
 
  createMiddleware?: (options: ServerOptions) => any
  onCertRenewed?: any
}
 
type FastifyApp = ReturnType<ReturnType<NestFastifyApplication['getHttpAdapter']>['getInstance']>['routing']
export class NestJsFastifyHttpsAdapter extends HttpsAdapter<FastifyApp, any> {
  constructor(public nestApp: NestFastifyApplication) {
    super()
  }
 
  init = async () => {
    await this.nestApp.init()
    const fastifyApp = this.nestApp.getHttpAdapter().getInstance()
    await fastifyApp.ready()
    return fastifyApp.routing
  }
 
  createMiddleware?: (options: ServerOptions) => any
  onCertRenewed?: any
}