PeerTube/server/tests/shared/mock-servers/mock-http.ts

24 lines
509 B
TypeScript
Raw Normal View History

2022-07-05 08:43:21 -05:00
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)
}
}