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 | 44x 52x 52x 51x 44x 48x 48x 48x | import { Application } from 'express'; import { ListenOptions } from 'net'; import http from 'http'; export const listenPromise = ( serverLike: http.Server | Application, listenOptions: ListenOptions = {} ): Promise<http.Server> => new Promise((resolve, reject) => { const server = serverLike.listen(listenOptions, () => resolve(server)) as http.Server; server.on('error', reject); }); export const serverClosePromise = (server: http.Server): Promise<void> => new Promise((resolve, reject) => { server.once('close', resolve); server.close((error) => (error ? reject(error) : null)); }); |