mirror of https://github.com/Chocobozzz/PeerTube
25 lines
523 B
TypeScript
25 lines
523 B
TypeScript
import { createServer, Server } from 'http'
|
|
import { createProxy } from 'proxy'
|
|
import { getPort, terminateServer } from './shared'
|
|
|
|
class MockProxy {
|
|
private server: Server
|
|
|
|
initialize () {
|
|
return new Promise<number>(res => {
|
|
this.server = createProxy(createServer())
|
|
this.server.listen(0, () => res(getPort(this.server)))
|
|
})
|
|
}
|
|
|
|
terminate () {
|
|
return terminateServer(this.server)
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export {
|
|
MockProxy
|
|
}
|