aboutsummaryrefslogtreecommitdiff
path: root/e2e/lib/TestServer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'e2e/lib/TestServer.ts')
-rw-r--r--e2e/lib/TestServer.ts31
1 files changed, 14 insertions, 17 deletions
diff --git a/e2e/lib/TestServer.ts b/e2e/lib/TestServer.ts
index 5b9eee3..e0c711b 100644
--- a/e2e/lib/TestServer.ts
+++ b/e2e/lib/TestServer.ts
@@ -1,6 +1,6 @@
-import * as http from 'http';
-import * as net from 'net'
-import express from 'express';
+import * as http from "http";
+import * as net from "net";
+import express from "express";
type HandlerFunc = (req: express.Request, res: express.Response) => void;
@@ -9,10 +9,7 @@ export default class TestServer {
private app: express.Application;
- constructor(
- private port = 0,
- private address = '127.0.0.1',
- ){
+ constructor(private port = 0, private address = "127.0.0.1") {
this.app = express();
}
@@ -23,30 +20,30 @@ export default class TestServer {
receiveContent(path: string, content: string): TestServer {
this.app.get(path, (_req: express.Request, res: express.Response) => {
- res.status(200).send(content)
+ res.status(200).send(content);
});
return this;
}
-
- url(path = '/'): string {
+
+ url(path = "/"): string {
if (!this.http) {
- throw new Error('http server not started');
+ throw new Error("http server not started");
}
const addr = this.http.address() as net.AddressInfo;
- return `http://${addr.address}:${addr.port}${path}`
+ return `http://${addr.address}:${addr.port}${path}`;
}
- start(): Promise<void> {
+ start(): Promise<void> {
if (this.http) {
- throw new Error('http server already started');
+ throw new Error("http server already started");
}
- this.http = http.createServer(this.app)
+ this.http = http.createServer(this.app);
return new Promise((resolve) => {
this.http!!.listen(this.port, this.address, () => {
resolve();
- })
+ });
});
}
@@ -59,6 +56,6 @@ export default class TestServer {
this.http = undefined;
resolve();
});
- })
+ });
}
}