diff --git a/index.js b/index.js index ace51f7..7856c72 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ var net = require('net'); var http = require('http'); class HttpRequest { - constructor({...attrs}) { + constructor({attrs}) { this.type = attrs.type; this.headers = attrs.headers; this.body = attrs.body; @@ -31,6 +31,7 @@ function parseHttpRequest(bytes) { httpRequestAttrs["type"] = typeInfo[0]; httpRequestAttrs["path"] = typeInfo[1]; httpRequestAttrs["httpVersion"] = typeInfo[2]; + } else { console.log(row); } @@ -64,4 +65,6 @@ server.on("listening", (c) => { server.listen(8124, () => { console.log("Server bound."); -}) \ No newline at end of file +}) + +module.exports = [parseHttpRequest]; \ No newline at end of file diff --git a/index.test.js b/index.test.js new file mode 100644 index 0000000..461db5d --- /dev/null +++ b/index.test.js @@ -0,0 +1,5 @@ +const index = require('./index.js'); + +test('parses first line', () => { + expect(true).toBe(true); +}) diff --git a/package.json b/package.json index 790a345..f146f9f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A proxy built using NodeJS", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "jest", "run": "node index.js" }, "author": "jaketothepast",