aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/tests/shared/mock-servers/mock-http.ts
blob: b7a019e0770d47434308c99993cb74354da3f6c8 (plain) (tree)






















                                                                                                
import express from 'express'
import { Server } from 'http'
import { getPort, randomListen, terminateServer } from './shared'

export class MockHTTP {
  private server: Server

  async initialize () {
    const app = express()

    app.get('/*', (req: express.Request, res: express.Response, next: express.NextFunction) => {
      return res.sendStatus(200)
    })

    this.server = await randomListen(app)

    return getPort(this.server)
  }

  terminate () {
    return terminateServer(this.server)
  }
}