diff --git a/api_collections/Auth Collection.postman_collection.json b/api_collections/Auth Collection.postman_collection.json new file mode 100644 index 0000000..0ac159b --- /dev/null +++ b/api_collections/Auth Collection.postman_collection.json @@ -0,0 +1,103 @@ +{ + "info": { + "_postman_id": "0b09db69-1448-4d54-83e7-5fb632f9204a", + "name": "Auth Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "38366651" + }, + "item": [ + { + "name": "Signup", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"test@example.com\",\n \"username\": \"testuser\",\n \"password\": \"password123\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/auth/signup", + "host": ["{{baseUrl}}"], + "path": ["auth", "signup"] + } + }, + "response": [] + }, + { + "name": "Signin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const res = pm.response.json();", + "pm.environment.set(\"token\", res.token);", + "pm.environment.set(\"userId\", res.user._id);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"test@example.com\",\n \"password\": \"password123\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/auth/login", + "host": ["{{baseUrl}}"], + "path": ["auth", "login"] + } + }, + "response": [] + }, + { + "name": "Get Profile", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + } + ], + "url": { + "raw": "{{baseUrl}}/auth/me", + "host": ["{{baseUrl}}"], + "path": ["auth", "me"] + } + }, + "response": [] + }, + { + "name": "Logout", + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{token}}" + } + ], + "url": { + "raw": "{{baseUrl}}/auth/logout", + "host": ["{{baseUrl}}"], + "path": ["auth", "logout"] + } + }, + "response": [] + } + ] +} diff --git a/api_collections/Comments Collection.postman_collection.json b/api_collections/Comments Collection.postman_collection.json new file mode 100644 index 0000000..e659698 --- /dev/null +++ b/api_collections/Comments Collection.postman_collection.json @@ -0,0 +1,36 @@ +{ + "info": { + "_postman_id": "173cf7c0-45ca-4771-9a6d-84203dcf9ee2", + "name": "Comments Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "38366651" + }, + "item": [ + { + "name": "Get Comments", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/comments/{{movieId}}", + "host": ["{{baseUrl}}"], + "path": ["comments", "{{movieId}}"] + } + }, + "response": [] + }, + { + "name": "Add Comments", + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{baseUrl}}/comments/{{movieId}}", + "host": ["{{baseUrl}}"], + "path": ["comments", "{{movieId}}"] + } + }, + "response": [] + } + ] +} diff --git a/api_collections/Messages Collection.postman_collection.json b/api_collections/Messages Collection.postman_collection.json new file mode 100644 index 0000000..999b8cf --- /dev/null +++ b/api_collections/Messages Collection.postman_collection.json @@ -0,0 +1,173 @@ +{ + "info": { + "_postman_id": "3c9fe6d9-c266-4276-89c4-6868d0401882", + "name": "Messages Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "38366651" + }, + "item": [ + { + "name": "Get Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "pm.test(\"Response is an array\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData).to.be.an('array');", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/", + "host": ["{{baseUrl}}"], + "path": ["messages", ""] + } + }, + "response": [] + }, + { + "name": "Get Message By Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "pm.test(\"Message has name and user\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property(\"name\");", + " pm.expect(jsonData).to.have.property(\"user\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/{{messageId}}", + "host": ["{{baseUrl}}"], + "path": ["messages", "{{messageId}}"] + } + }, + "response": [] + }, + { + "name": "Add Messages", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "pm.test(\"Message is returned with ID\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property(\"_id\");", + " pm.environment.set(\"messageId\", jsonData._id);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/add/message", + "host": ["{{baseUrl}}"], + "path": ["messages", "add", "message"] + } + }, + "response": [] + }, + { + "name": "Edit Message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "PUT", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/edit/{{messageId}}", + "host": ["{{baseUrl}}"], + "path": ["messages", "edit", "{{messageId}}"] + } + }, + "response": [] + }, + { + "name": "Delete Message", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "pm.test(\"Deletion confirmation message\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData.message).to.eql(\"Message deleted\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/delete/{{messageId}}", + "host": ["{{baseUrl}}"], + "path": ["messages", "delete", "{{messageId}}"] + } + }, + "response": [] + } + ] +} diff --git a/api_collections/Movie Collection.postman_collection.json b/api_collections/Movie Collection.postman_collection.json new file mode 100644 index 0000000..c9ffe13 --- /dev/null +++ b/api_collections/Movie Collection.postman_collection.json @@ -0,0 +1,129 @@ +{ + "info": { + "_postman_id": "6e7c4699-9296-460f-983b-7fc087aaee34", + "name": "Movie Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "38366651" + }, + "item": [ + { + "name": "Get Movies", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/movies/", + "host": ["{{baseUrl}}"], + "path": ["movies", ""] + } + }, + "response": [] + }, + { + "name": "Get Top Movies", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "pm.test(\"Response is an array\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData).to.be.an(\"array\");", + "});", + "", + "pm.test(\"Movies are sorted by rating descending\", function () {", + " const jsonData = pm.response.json();", + " for (let i = 1; i < jsonData.length; i++) {", + " pm.expect(jsonData[i - 1].rating).to.be.at.least(jsonData[i].rating);", + " }", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/movies/top", + "host": ["{{baseUrl}}"], + "path": ["movies", "top"] + } + }, + "response": [] + }, + { + "name": "Get Seen Movie", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 401\", function () {", + " pm.expect([200, 401]).to.include(pm.response.code);", + "});", + "", + "if (pm.response.code === 200) {", + " const data = pm.response.json();", + " ", + " pm.test(\"Response is array\", function () {", + " pm.expect(data).to.be.an(\"array\");", + " });", + "", + " pm.test(\"Each item has required movie fields\", function () {", + " if (data.length > 0) {", + " const movie = data[0];", + " pm.expect(movie).to.have.property(\"id\");", + " pm.expect(movie).to.have.property(\"title\");", + " pm.expect(movie).to.have.property(\"description\");", + " }", + " });", + "} else if (pm.response.code === 401) {", + " pm.test(\"Unauthorized error message\", function () {", + " const err = pm.response.json();", + " pm.expect(err).to.have.property(\"error\");", + " pm.expect(err.error).to.equal(\"User not authenticated\");", + " });", + "}", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/movies/me", + "host": ["{{baseUrl}}"], + "path": ["movies", "me"] + } + }, + "response": [] + } + ] +} diff --git a/api_collections/Profile Collection.postman_collection.json b/api_collections/Profile Collection.postman_collection.json new file mode 100644 index 0000000..f970f63 --- /dev/null +++ b/api_collections/Profile Collection.postman_collection.json @@ -0,0 +1,84 @@ +{ + "info": { + "_postman_id": "7da23f1b-276a-4be1-a8fa-4a35725572f0", + "name": "Profile Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "38366651" + }, + "item": [ + { + "name": "Edit Password", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status is 200 or 400\", function () {", + " pm.expect([200, 400]).to.include(pm.response.code);", + "});", + "", + "if (pm.response.code === 200) {", + " pm.test(\"Password updated message\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"Password updated\");", + " });", + "} else if (pm.response.code === 400) {", + " const json = pm.response.json();", + " pm.test(\"Proper error message returned\", function () {", + " pm.expect(json).to.have.property(\"message\");", + " pm.expect(json.message.length).to.be.above(0);", + " });", + "}", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "PUT", + "header": [], + "url": { + "raw": "{{baseUrl}}/profile/", + "host": ["{{baseUrl}}"], + "path": ["profile", ""] + } + }, + "response": [] + }, + { + "name": "Logout", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Check status code\", function () {", + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "pm.test(\"Message is 'Disconnected'\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"Disconnected\");", + "});", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{baseUrl}}/profile/", + "host": ["{{baseUrl}}"], + "path": ["profile", ""] + } + }, + "response": [] + } + ] +} diff --git a/api_collections/Rating Collection.postman_collection.json b/api_collections/Rating Collection.postman_collection.json new file mode 100644 index 0000000..0d59bee --- /dev/null +++ b/api_collections/Rating Collection.postman_collection.json @@ -0,0 +1,53 @@ +{ + "info": { + "_postman_id": "001a8e3d-4f14-4af5-9b8c-e89284f6821a", + "name": "Rating Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "38366651" + }, + "item": [ + { + "name": "Add Rating", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status is 200, 400, or 404\", function () {", + " pm.expect([200, 400, 404]).to.include(pm.response.code);", + "});", + "", + "if (pm.response.code === 200) {", + " pm.test(\"Rating added successfully\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"Rating added successfully\");", + " });", + "}", + "", + "if (pm.response.code === 400 || pm.response.code === 404) {", + " const json = pm.response.json();", + " pm.test(\"Proper error message exists\", function () {", + " pm.expect(json).to.have.property(\"error\");", + " pm.expect(json.error.length).to.be.above(0);", + " });", + "}", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{baseUrl}}/ratings/{{movieId}}", + "host": ["{{baseUrl}}"], + "path": ["ratings", "{{movieId}}"] + } + }, + "response": [] + } + ] +} diff --git a/api_collections/Users Collection.postman_collection.json b/api_collections/Users Collection.postman_collection.json new file mode 100644 index 0000000..255bc80 --- /dev/null +++ b/api_collections/Users Collection.postman_collection.json @@ -0,0 +1,116 @@ +{ + "info": { + "_postman_id": "dc349fd3-0f69-472a-b807-bd8f77dc06ea", + "name": "Users Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "38366651" + }, + "item": [ + { + "name": "Register", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status is 200 or 400 or 409\", function () {", + " pm.expect([200, 400, 409]).to.include(pm.response.code);", + "});", + "", + "if (pm.response.code === 200) {", + " pm.test(\"User created\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"User created\");", + " });", + "}", + "", + "if (pm.response.code === 409) {", + " pm.test(\"User already exists message\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"User already has an account\");", + " });", + "}", + "", + "if (pm.response.code === 400) {", + " pm.test(\"Missing parameter message\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"Missing parameters\");", + " });", + "}" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{baseUrl}}/users/register", + "host": ["{{baseUrl}}"], + "path": ["users", "register"] + } + }, + "response": [] + }, + { + "name": "Login", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status is 200 or 400 or 404\", function () {", + " pm.expect([200, 400, 404]).to.include(pm.response.code);", + "});", + "", + "if (pm.response.code === 200) {", + " const json = pm.response.json();", + "", + " pm.test(\"Token exists\", function () {", + " pm.expect(json).to.have.property(\"token\");", + " pm.expect(json.token.length).to.be.above(0);", + " });", + "", + " pm.test(\"Username exists\", function () {", + " pm.expect(json).to.have.property(\"username\");", + " });", + "", + " // Save token for other requests", + " pm.environment.set(\"jwtToken\", json.token);", + "}", + "", + "if (pm.response.code === 404) {", + " pm.test(\"Wrong credentials message\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"Incorrect email/password\");", + " });", + "}", + "", + "if (pm.response.code === 400) {", + " pm.test(\"Missing parameter message\", function () {", + " const json = pm.response.json();", + " pm.expect(json.message).to.eql(\"Missing parameters\");", + " });", + "}", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{baseUrl}}/users/login", + "host": ["{{baseUrl}}"], + "path": ["users", "login"] + } + }, + "response": [] + } + ] +} diff --git a/src/temp.ts b/src/temp.ts deleted file mode 100644 index 92765d1..0000000 --- a/src/temp.ts +++ /dev/null @@ -1 +0,0 @@ -// delete this file after changing everything into typescript