From bf45cdbdc5c6bca4df7df8f5795631cc2ed673c6 Mon Sep 17 00:00:00 2001 From: stevelw Date: Sun, 8 Dec 2024 13:27:24 +0000 Subject: [PATCH 1/7] Update endpoint documentation --- src/endpoints.json | 336 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 279 insertions(+), 57 deletions(-) diff --git a/src/endpoints.json b/src/endpoints.json index caccf2a..7a12c14 100644 --- a/src/endpoints.json +++ b/src/endpoints.json @@ -1,27 +1,24 @@ [ { - "path": "/api", - "description": "Index of API", - "method": "GET", - "authentication": "none", - "result": { - "success": true - } - }, - { - "path": "/api/endpoints", + "path": "/api/", "description": "List all endpoints", "method": "GET", "authentication": "none", - "result": { + "exampleResponse": { "success": true, "data": { - "/api": { - "description": "Index of API", - "method": "GET", - "authentication": "none", - "result": { "success": true } - } + "endpoints": [ + { + "path": "/api/devices/create", + "description": "Register a new device", + "method": "POST", + "authentication": "username", + "body": {}, + "exampleResponse": { + "success": true + } + } + ] } } }, @@ -31,28 +28,49 @@ "method": "POST", "authentication": "username", "body": {}, - "result": { - "success": true + "exampleResponse": { + "success": true, + "data": { + "id": "cm4ep553p0001rkiz9s1mgb64", + "name": "GPS Device", + "uuid": "c12b3b4e-125f-4f8e-a3cd-bba33b63ae1a", + "owner_id": "cm3op7iwu0000jrcqa60tc9kv", + "last_pulse_at": null, + "last_location": {}, + "location_history": [], + "updated_at": "2024-12-07T21:38:16.213Z", + "created_at": "2024-12-07T21:38:16.213Z" + } } }, { "path": "/api/devices/update", "description": "Update information ", - "method": "PATCH", - "authentication": "device-uuid", + "method": "POST", + "authentication": "none", "body": { "id": "string", "lat": "number", "lon": "number" }, - "result": {} + "exampleResponse": "204 - No Content" + }, + { + "path": "/api/devices/delete", + "description": "Delete a device", + "method": "DELETE", + "authentication": "username", + "body": { + "device_uuid": "5804f943-4aaf-432f-83d8-62028827ac57" + }, + "exampleResponse": "204 - No Content" }, { "path": "/api/users/:id/devices", "description": "List all of a users devices", "method": "GET", "authentication": "none", - "result": { + "exampleResponse": { "success": true, "data": [ { @@ -70,25 +88,89 @@ } }, { - "path": "/api/devices/delete", - "description": "Delete a device", - "method": "DELETE", - "authentication": "username", - "result": {} + "path": "/api/users/", + "description": "Fetch all users", + "method": "GET", + "authentication": "none", + "exampleResponse": { + "success": true, + "data": [ + { + "username": "user2", + "requested_privacy": "PUBLIC", + "devices": [ + { + "id": "cm4a07hsl0003wnalvfrzrczj", + "name": "A Collar", + "uuid": "36932d18-78a2-4ceb-b979-64a5ed441551", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "last_pulse_at": "2024-11-25T16:22:11.108Z", + "last_location": { + "lat": 53.8035, + "lon": -1.447 + }, + "location_history": [ + { + "lat": 53.804, + "lon": -1.4485, + "timestamp": "2024-11-25T16:15:11.108Z" + }, + { + "lat": 53.8045, + "lon": -1.449, + "timestamp": "2024-11-25T16:08:11.108Z" + }, + { + "lat": 53.805, + "lon": -1.45, + "timestamp": "2024-11-25T16:01:11.108Z" + }, + { + "lat": 53.806201, + "lon": -1.451106, + "timestamp": "2024-11-25T15:54:11.108Z" + } + ], + "updated_at": "2024-12-06T18:28:29.815Z", + "created_at": "2024-12-04T14:49:10.869Z" + } + ], + "cats": [ + { + "id": "cm3pz1t0v000308jka8bl7x25", + "name": "Daisy, Eater of Worlds", + "description": null, + "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", + "device_id": "cm4a07hsl0003wnalvfrzrczj", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "updated_at": "2024-12-06T18:31:06.913Z", + "created_at": "2024-12-04T14:49:10.883Z", + "battleProfileId": null + } + ], + "created_at": "2024-12-04T14:49:10.858Z" + } + ], + "count": 3 + } }, { - "path": "/api/cats/create", - "description": "Register a new cat", + "path": "/api/users/", + "description": "Create a new user", "method": "POST", - "authentication": "username", + "authentication": "none", "body": { - "name": "string, optional", - "description": "string, optional", - "picture_url": "string, optional" + "username": "John Smith 123" }, - "result": { + "exampleResponse": { "success": true, - "data": {} + "data": { + "id": "cm4epu1a30002rkizmhrbi1ff", + "username": "John Smith 123", + "requested_privacy": "PUBLIC", + "updated_at": "2024-12-07T21:57:37.634Z", + "created_at": "2024-12-07T21:57:37.634Z" + } } }, { @@ -96,47 +178,187 @@ "description": "List all of a users cats", "method": "GET", "authentication": "none", - "result": { + "exampleResponse": { "success": true, "data": [ { - "id": "cm3ptn1mf0005flja3l1pl70b", - "name": "Cat", - "description": "Meow meow. Meow meow? Meow!", - "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", + "id": "cm3pr1rkb000008l8fs7icr9g", + "name": "Mr Tiddles", + "description": null, + "picture_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRWGpMwXI5hOZhVNL9Z1YZfhSgjjY1qEBRJgQ&s", "device_id": null, "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "updated_at": "2024-11-20T11:49:55.576Z", - "created_at": "2024-11-20T11:49:55.576Z", - "deleted_at": null + "updated_at": "2024-12-04T14:49:10.877Z", + "created_at": "2024-12-04T14:49:10.877Z", + "battleProfileId": null, + "battle_profile": { + "id": "cm3yd7wfc000108i6ef3w8hrl", + "level": 815, + "xp": 820, + "wins": 0, + "losses": 0, + "cat_id": "cm3pr1rkb000008l8fs7icr9g" + } } ] } }, + { + "path": "/api/users/settings", + "description": "Fetch a user's settings", + "method": "GET", + "authentication": "username", + "exampleResponse": { + "sucess": true, + "data": { + "id": "cm3op7iwu0000jrcqa60tc9kv", + "username": "user1", + "requested_privacy": "PRIVATE", + "updated_at": "2024-12-07T21:50:47.568Z", + "created_at": "2024-12-04T14:49:10.848Z" + } + } + }, + { + "path": "/api/users/settings", + "description": "Update a user's settings", + "method": "PATCH", + "authentication": "username", + "body": { + "requested_privacy": "PRIVATE" + }, + "exampleResponse": { + "sucess": true, + "data": { + "id": "cm3op7iwu0000jrcqa60tc9kv", + "username": "user1", + "requested_privacy": "PRIVATE", + "updated_at": "2024-12-07T21:50:47.568Z", + "created_at": "2024-12-04T14:49:10.848Z" + } + } + }, + { + "path": "/api/cats/create", + "description": "Register a new cat", + "method": "POST", + "authentication": "username", + "body": { + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg" + }, + "exampleResponse": { + "success": true, + "data": { + "id": "cm4fjesok0001xntyd0rsa616", + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg", + "device_id": null, + "owner_id": "cm3op7iwu0000jrcqa60tc9kv", + "updated_at": "2024-12-08T11:45:35.154Z", + "created_at": "2024-12-08T11:45:35.154Z", + "battleProfileId": null + } + } + }, { "path": "/api/cats/update", "description": "Update a cats social information", "method": "PATCH", "authentication": "username", "body": { - "cat_id": "string", - "name": "string, optional", - "description": "string, optional", - "picture_url": "string, optional" + "cat_id": "cm4fjesok0001xntyd0rsa616", + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg" }, - "result": { + "exampleResponse": { "success": true, "data": { - "id": "cm3pz1t0v000308jka8bl7x25", - "name": "Daisy, Eater of Worlds", - "description": "Meow meow. Meow meow? Meow!", - "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", - "device_id": "cm3pz39ec0003110jpvg6mya6", + "id": "cm4fjesok0001xntyd0rsa616", + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg", + "device_id": null, "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "updated_at": "2024-11-20T14:31:14.136Z", - "created_at": "2024-11-20T14:22:30.232Z", - "deleted_at": null + "updated_at": "2024-12-08T11:47:42.125Z", + "created_at": "2024-12-08T11:45:35.154Z", + "battleProfileId": null } } + }, + { + "path": "/api/cats/leaderboard/:range", + "description": "Fetch the leadboard for a time range.", + "method": "GET", + "authentication": "username", + "validParameters": { + "range": ["daily", "weekly", "monthly", "yearly", "all_time"] + }, + "exampleResponse": { + "success": true, + "data": [ + { + "id": "cm4a07hsl0003wnalvfrzrczj", + "name": "A Collar", + "uuid": "36932d18-78a2-4ceb-b979-64a5ed441551", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "last_pulse_at": "2024-11-25T16:22:11.108Z", + "last_location": { + "lat": 53.8035, + "lon": -1.447 + }, + "location_history": [ + { + "lat": 53.804, + "lon": -1.4485, + "timestamp": "2024-11-25T16:15:11.108Z" + }, + { + "lat": 53.8045, + "lon": -1.449, + "timestamp": "2024-11-25T16:08:11.108Z" + }, + { + "lat": 53.805, + "lon": -1.45, + "timestamp": "2024-11-25T16:01:11.108Z" + }, + { + "lat": 53.806201, + "lon": -1.451106, + "timestamp": "2024-11-25T15:54:11.108Z" + } + ], + "updated_at": "2024-12-06T18:28:29.815Z", + "created_at": "2024-12-04T14:49:10.869Z", + "cat": { + "id": "cm3pz1t0v000308jka8bl7x25", + "name": "Daisy, Eater of Worlds", + "description": null, + "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", + "device_id": "cm4a07hsl0003wnalvfrzrczj", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "updated_at": "2024-12-06T18:31:06.913Z", + "created_at": "2024-12-04T14:49:10.883Z", + "battleProfileId": null + }, + "score": 0 + } + ], + "range": "weekly" + } + }, + { + "path": "/api/cats/nearby/:id/:distance", + "description": "Fetch all cats within a certain distance of a cat.", + "method": "GET", + "authentication": "username", + "validParameters": { + "distance": "Number" + }, + "exampleResponse": "TBD" } ] From bda56bfbc160757f25e21c569a0da4494cc97c64 Mon Sep 17 00:00:00 2001 From: stevelw Date: Thu, 13 Feb 2025 11:48:50 +0000 Subject: [PATCH 2/7] fix example api response --- src/endpoints.json | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/endpoints.json b/src/endpoints.json index 55cb46d..23bbfed 100644 --- a/src/endpoints.json +++ b/src/endpoints.json @@ -6,18 +6,15 @@ "exampleResponse": { "success": true, "data": { - "endpoints": [ - { - "path": "/api/devices/create", - "description": "Register a new device", - "method": "POST", - "authentication": "username", - "body": {}, - "exampleResponse": { - "success": true - } + "/api/devices/create": { + "description": "Register a new device", + "method": "POST", + "authentication": "username", + "body": {}, + "exampleResponse": { + "success": true } - ] + } } } }, From 12bf8c00affd559e4799c83fe39f8144a8e4cca3 Mon Sep 17 00:00:00 2001 From: stevelw Date: Thu, 13 Feb 2025 12:07:54 +0000 Subject: [PATCH 3/7] Revert "fix example api response" This reverts commit bda56bfbc160757f25e21c569a0da4494cc97c64. --- src/endpoints.json | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/endpoints.json b/src/endpoints.json index 23bbfed..55cb46d 100644 --- a/src/endpoints.json +++ b/src/endpoints.json @@ -6,15 +6,18 @@ "exampleResponse": { "success": true, "data": { - "/api/devices/create": { - "description": "Register a new device", - "method": "POST", - "authentication": "username", - "body": {}, - "exampleResponse": { - "success": true + "endpoints": [ + { + "path": "/api/devices/create", + "description": "Register a new device", + "method": "POST", + "authentication": "username", + "body": {}, + "exampleResponse": { + "success": true + } } - } + ] } } }, From 17eb13d18ce9ed2065b11616a8f82d16de68b29f Mon Sep 17 00:00:00 2001 From: stevelw Date: Thu, 13 Feb 2025 12:11:01 +0000 Subject: [PATCH 4/7] Revert "Merge `main` into `CL-141-Endpoints-documentation-out-of-date`" This reverts commit 0d781b2a2853a8318b61a1b95371ae274d8456cc, reversing changes made to 283d757d324decae6d3e13c7281d0581233fd373. --- src/endpoints.json | 377 +++++++++------------------------------------ 1 file changed, 76 insertions(+), 301 deletions(-) diff --git a/src/endpoints.json b/src/endpoints.json index 55cb46d..1177f5f 100644 --- a/src/endpoints.json +++ b/src/endpoints.json @@ -3,348 +3,123 @@ "description": "List all endpoints", "method": "GET", "authentication": "none", - "exampleResponse": { + "result": { "success": true, "data": { - "endpoints": [ - { - "path": "/api/devices/create", - "description": "Register a new device", - "method": "POST", - "authentication": "username", - "body": {}, - "exampleResponse": { - "success": true - } - } - ] + "/api": { + "description": "Index of API", + "method": "GET", + "authentication": "none", + "result": { "success": true } + } } } }, - "/api/devices/create": { - "description": "Register a new device", + "/api/cats/create": { + "description": "Register a new cat", "method": "POST", "authentication": "username", - "body": {}, - "exampleResponse": { + "body": { + "name": "string, optional", + "description": "string, optional", + "picture_url": "string, optional" + }, + "result": { + "success": true, + "data": {} + } + }, + "/api/cats/update": { + "description": "Update a cats social information", + "method": "PATCH", + "authentication": "username", + "body": { + "cat_id": "string", + "name": "string, optional", + "description": "string, optional", + "picture_url": "string, optional" + }, + "result": { "success": true, "data": { - "id": "cm4ep553p0001rkiz9s1mgb64", - "name": "GPS Device", - "uuid": "c12b3b4e-125f-4f8e-a3cd-bba33b63ae1a", + "id": "cm3pz1t0v000308jka8bl7x25", + "name": "Daisy, Eater of Worlds", + "description": "Meow meow. Meow meow? Meow!", + "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", + "device_id": "cm3pz39ec0003110jpvg6mya6", "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "last_pulse_at": null, - "last_location": {}, - "location_history": [], - "updated_at": "2024-12-07T21:38:16.213Z", - "created_at": "2024-12-07T21:38:16.213Z" + "updated_at": "2024-11-20T14:31:14.136Z", + "created_at": "2024-11-20T14:22:30.232Z", + "deleted_at": null } } }, - "/api/devices/update": { - "description": "Update information ", + "/api/devices/create": { + "description": "Register a new device", "method": "POST", - "authentication": "none", - "body": { - "id": "string", - "lat": "number", - "lon": "number" - }, - "exampleResponse": "204 - No Content" + "authentication": "username", + "body": {}, + "result": { + "success": true + } }, "/api/devices/delete": { "description": "Delete a device", "method": "DELETE", "authentication": "username", - "body": { - "device_uuid": "5804f943-4aaf-432f-83d8-62028827ac57" - }, - "exampleResponse": "204 - No Content" + "result": {} }, - "/api/users/:id/devices": { - "description": "List all of a users devices", - "method": "GET", - "authentication": "none", - "exampleResponse": { - "success": true, - "data": [ - { - "id": "cm3owzqrd0001z4qlshsse6re", - "name": "GPS Device", - "uuid": "31ee122b-0bc3-446f-bf67-ea945cef4c1c", - "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "last_pulse_at": null, - "last_location": {}, - "location_history": [], - "updated_at": "2024-11-19T20:36:00.698Z", - "created_at": "2024-11-19T20:36:00.698Z" - } - ] - } - }, - "/api/users/": { - "description": "Fetch all users", - "method": "GET", - "authentication": "none", - "exampleResponse": { - "success": true, - "data": [ - { - "username": "user2", - "requested_privacy": "PUBLIC", - "devices": [ - { - "id": "cm4a07hsl0003wnalvfrzrczj", - "name": "A Collar", - "uuid": "36932d18-78a2-4ceb-b979-64a5ed441551", - "owner_id": "cm3op7iww0001jrcqpq3qxx6i", - "last_pulse_at": "2024-11-25T16:22:11.108Z", - "last_location": { - "lat": 53.8035, - "lon": -1.447 - }, - "location_history": [ - { - "lat": 53.804, - "lon": -1.4485, - "timestamp": "2024-11-25T16:15:11.108Z" - }, - { - "lat": 53.8045, - "lon": -1.449, - "timestamp": "2024-11-25T16:08:11.108Z" - }, - { - "lat": 53.805, - "lon": -1.45, - "timestamp": "2024-11-25T16:01:11.108Z" - }, - { - "lat": 53.806201, - "lon": -1.451106, - "timestamp": "2024-11-25T15:54:11.108Z" - } - ], - "updated_at": "2024-12-06T18:28:29.815Z", - "created_at": "2024-12-04T14:49:10.869Z" - } - ], - "cats": [ - { - "id": "cm3pz1t0v000308jka8bl7x25", - "name": "Daisy, Eater of Worlds", - "description": null, - "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", - "device_id": "cm4a07hsl0003wnalvfrzrczj", - "owner_id": "cm3op7iww0001jrcqpq3qxx6i", - "updated_at": "2024-12-06T18:31:06.913Z", - "created_at": "2024-12-04T14:49:10.883Z", - "battleProfileId": null - } - ], - "created_at": "2024-12-04T14:49:10.858Z" - } - ], - "count": 3 - } - }, - "/api/users/": { - "description": "Create a new user", - "method": "POST", - "authentication": "none", + "/api/devices/update": { + "description": "Update information ", + "method": "PATCH", + "authentication": "device-uuid", "body": { - "username": "John Smith 123" + "id": "string", + "lat": "number", + "lon": "number" }, - "exampleResponse": { - "success": true, - "data": { - "id": "cm4epu1a30002rkizmhrbi1ff", - "username": "John Smith 123", - "requested_privacy": "PUBLIC", - "updated_at": "2024-12-07T21:57:37.634Z", - "created_at": "2024-12-07T21:57:37.634Z" - } - } + "result": {} }, "/api/users/:id/cats": { "description": "List all of a users cats", "method": "GET", "authentication": "none", - "exampleResponse": { + "result": { "success": true, "data": [ { - "id": "cm3pr1rkb000008l8fs7icr9g", - "name": "Mr Tiddles", - "description": null, - "picture_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRWGpMwXI5hOZhVNL9Z1YZfhSgjjY1qEBRJgQ&s", + "id": "cm3ptn1mf0005flja3l1pl70b", + "name": "Cat", + "description": "Meow meow. Meow meow? Meow!", + "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", "device_id": null, "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "updated_at": "2024-12-04T14:49:10.877Z", - "created_at": "2024-12-04T14:49:10.877Z", - "battleProfileId": null, - "battle_profile": { - "id": "cm3yd7wfc000108i6ef3w8hrl", - "level": 815, - "xp": 820, - "wins": 0, - "losses": 0, - "cat_id": "cm3pr1rkb000008l8fs7icr9g" - } + "updated_at": "2024-11-20T11:49:55.576Z", + "created_at": "2024-11-20T11:49:55.576Z", + "deleted_at": null } ] } }, - "/api/users/settings": { - "description": "Fetch a user's settings", - "method": "GET", - "authentication": "username", - "exampleResponse": { - "sucess": true, - "data": { - "id": "cm3op7iwu0000jrcqa60tc9kv", - "username": "user1", - "requested_privacy": "PRIVATE", - "updated_at": "2024-12-07T21:50:47.568Z", - "created_at": "2024-12-04T14:49:10.848Z" - } - } - }, - "/api/users/settings": { - "description": "Update a user's settings", - "method": "PATCH", - "authentication": "username", - "body": { - "requested_privacy": "PRIVATE" - }, - "exampleResponse": { - "sucess": true, - "data": { - "id": "cm3op7iwu0000jrcqa60tc9kv", - "username": "user1", - "requested_privacy": "PRIVATE", - "updated_at": "2024-12-07T21:50:47.568Z", - "created_at": "2024-12-04T14:49:10.848Z" - } - } - }, - "/api/cats/create": { - "description": "Register a new cat", - "method": "POST", - "authentication": "username", - "body": { - "name": "Catty Cat McCatFace", - "description": "A good kitty.", - "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg" - }, - "exampleResponse": { - "success": true, - "data": { - "id": "cm4fjesok0001xntyd0rsa616", - "name": "Catty Cat McCatFace", - "description": "A good kitty.", - "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg", - "device_id": null, - "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "updated_at": "2024-12-08T11:45:35.154Z", - "created_at": "2024-12-08T11:45:35.154Z", - "battleProfileId": null - } - } - }, - "/api/cats/update": { - "description": "Update a cats social information", - "method": "PATCH", - "authentication": "username", - "body": { - "cat_id": "cm4fjesok0001xntyd0rsa616", - "name": "Catty Cat McCatFace", - "description": "A good kitty.", - "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg" - }, - "exampleResponse": { - "success": true, - "data": { - "id": "cm4fjesok0001xntyd0rsa616", - "name": "Catty Cat McCatFace", - "description": "A good kitty.", - "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg", - "device_id": null, - "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "updated_at": "2024-12-08T11:47:42.125Z", - "created_at": "2024-12-08T11:45:35.154Z", - "battleProfileId": null - } - } - }, - "/api/cats/leaderboard/:range": { - "description": "Fetch the leadboard for a time range.", + "/api/users/:id/devices": { + "description": "List all of a users devices", "method": "GET", - "authentication": "username", - "validParameters": { - "range": ["daily", "weekly", "monthly", "yearly", "all_time"] - }, - "exampleResponse": { + "authentication": "none", + "result": { "success": true, "data": [ { - "id": "cm4a07hsl0003wnalvfrzrczj", - "name": "A Collar", - "uuid": "36932d18-78a2-4ceb-b979-64a5ed441551", - "owner_id": "cm3op7iww0001jrcqpq3qxx6i", - "last_pulse_at": "2024-11-25T16:22:11.108Z", - "last_location": { - "lat": 53.8035, - "lon": -1.447 - }, - "location_history": [ - { - "lat": 53.804, - "lon": -1.4485, - "timestamp": "2024-11-25T16:15:11.108Z" - }, - { - "lat": 53.8045, - "lon": -1.449, - "timestamp": "2024-11-25T16:08:11.108Z" - }, - { - "lat": 53.805, - "lon": -1.45, - "timestamp": "2024-11-25T16:01:11.108Z" - }, - { - "lat": 53.806201, - "lon": -1.451106, - "timestamp": "2024-11-25T15:54:11.108Z" - } - ], - "updated_at": "2024-12-06T18:28:29.815Z", - "created_at": "2024-12-04T14:49:10.869Z", - "cat": { - "id": "cm3pz1t0v000308jka8bl7x25", - "name": "Daisy, Eater of Worlds", - "description": null, - "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", - "device_id": "cm4a07hsl0003wnalvfrzrczj", - "owner_id": "cm3op7iww0001jrcqpq3qxx6i", - "updated_at": "2024-12-06T18:31:06.913Z", - "created_at": "2024-12-04T14:49:10.883Z", - "battleProfileId": null - }, - "score": 0 + "id": "cm3owzqrd0001z4qlshsse6re", + "name": "GPS Device", + "uuid": "31ee122b-0bc3-446f-bf67-ea945cef4c1c", + "owner_id": "cm3op7iwu0000jrcqa60tc9kv", + "last_pulse_at": null, + "last_location": {}, + "location_history": [], + "updated_at": "2024-11-19T20:36:00.698Z", + "created_at": "2024-11-19T20:36:00.698Z" } - ], - "range": "weekly" + ] } - }, - "/api/cats/nearby/:id/:distance": { - "description": "Fetch all cats within a certain distance of a cat.", - "method": "GET", - "authentication": "username", - "validParameters": { - "distance": "Number" - }, - "exampleResponse": "TBD" } } From 6ecf2402b4963977e206b0448e675095b87aa5c5 Mon Sep 17 00:00:00 2001 From: stevelw Date: Thu, 13 Feb 2025 12:32:56 +0000 Subject: [PATCH 5/7] Merge `main` into `CL-141-Endpoints-documentation-out-of-date` --- src/endpoints.json | 456 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 356 insertions(+), 100 deletions(-) diff --git a/src/endpoints.json b/src/endpoints.json index 1177f5f..4bfef50 100644 --- a/src/endpoints.json +++ b/src/endpoints.json @@ -1,125 +1,381 @@ { - "/api": { - "description": "List all endpoints", - "method": "GET", - "authentication": "none", - "result": { - "success": true, - "data": { - "/api": { - "description": "Index of API", - "method": "GET", - "authentication": "none", - "result": { "success": true } + "/api/": { + "GET": { + "description": "List all endpoints", + "authentication": "none", + "exampleResponse": { + "success": true, + "data": { + "/api/devices/create": { + "POST": { + "description": "Register a new device", + "authentication": "username", + "body": {}, + "exampleResponse": { + "success": true, + "data": { + "id": "cm4ep553p0001rkiz9s1mgb64", + "name": "GPS Device", + "uuid": "c12b3b4e-125f-4f8e-a3cd-bba33b63ae1a", + "owner_id": "cm3op7iwu0000jrcqa60tc9kv", + "last_pulse_at": null, + "last_location": {}, + "location_history": [], + "updated_at": "2024-12-07T21:38:16.213Z", + "created_at": "2024-12-07T21:38:16.213Z" + } + } + } + }, + "/api/devices/update": { + "POST": { + "description": "Update information ", + "authentication": "none", + "body": { + "id": "string", + "lat": "number", + "lon": "number" + }, + "exampleResponse": "204 - No Content" + } + } } } } }, - "/api/cats/create": { - "description": "Register a new cat", - "method": "POST", - "authentication": "username", - "body": { - "name": "string, optional", - "description": "string, optional", - "picture_url": "string, optional" - }, - "result": { - "success": true, - "data": {} - } - }, - "/api/cats/update": { - "description": "Update a cats social information", - "method": "PATCH", - "authentication": "username", - "body": { - "cat_id": "string", - "name": "string, optional", - "description": "string, optional", - "picture_url": "string, optional" - }, - "result": { - "success": true, - "data": { - "id": "cm3pz1t0v000308jka8bl7x25", - "name": "Daisy, Eater of Worlds", - "description": "Meow meow. Meow meow? Meow!", - "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", - "device_id": "cm3pz39ec0003110jpvg6mya6", - "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "updated_at": "2024-11-20T14:31:14.136Z", - "created_at": "2024-11-20T14:22:30.232Z", - "deleted_at": null + "/api/devices/create": { + "POST": { + "description": "Register a new device", + "authentication": "username", + "body": {}, + "exampleResponse": { + "success": true, + "data": { + "id": "cm4ep553p0001rkiz9s1mgb64", + "name": "GPS Device", + "uuid": "c12b3b4e-125f-4f8e-a3cd-bba33b63ae1a", + "owner_id": "cm3op7iwu0000jrcqa60tc9kv", + "last_pulse_at": null, + "last_location": {}, + "location_history": [], + "updated_at": "2024-12-07T21:38:16.213Z", + "created_at": "2024-12-07T21:38:16.213Z" + } } } }, - "/api/devices/create": { - "description": "Register a new device", - "method": "POST", - "authentication": "username", - "body": {}, - "result": { - "success": true + "/api/devices/update": { + "POST": { + "description": "Update information ", + "authentication": "none", + "body": { + "id": "string", + "lat": "number", + "lon": "number" + }, + "exampleResponse": "204 - No Content" } }, "/api/devices/delete": { - "description": "Delete a device", - "method": "DELETE", - "authentication": "username", - "result": {} + "DELETE": { + "description": "Delete a device", + "authentication": "username", + "body": { + "device_uuid": "5804f943-4aaf-432f-83d8-62028827ac57" + }, + "exampleResponse": "204 - No Content" + } }, - "/api/devices/update": { - "description": "Update information ", - "method": "PATCH", - "authentication": "device-uuid", - "body": { - "id": "string", - "lat": "number", - "lon": "number" + "/api/users/:id/devices": { + "GET": { + "description": "List all of a users devices", + "authentication": "none", + "exampleResponse": { + "success": true, + "data": [ + { + "id": "cm3owzqrd0001z4qlshsse6re", + "name": "GPS Device", + "uuid": "31ee122b-0bc3-446f-bf67-ea945cef4c1c", + "owner_id": "cm3op7iwu0000jrcqa60tc9kv", + "last_pulse_at": null, + "last_location": {}, + "location_history": [], + "updated_at": "2024-11-19T20:36:00.698Z", + "created_at": "2024-11-19T20:36:00.698Z" + } + ] + } + } + }, + "/api/users/": { + "GET": { + "description": "Fetch all users", + "authentication": "none", + "exampleResponse": { + "success": true, + "data": [ + { + "username": "user2", + "requested_privacy": "PUBLIC", + "devices": [ + { + "id": "cm4a07hsl0003wnalvfrzrczj", + "name": "A Collar", + "uuid": "36932d18-78a2-4ceb-b979-64a5ed441551", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "last_pulse_at": "2024-11-25T16:22:11.108Z", + "last_location": { + "lat": 53.8035, + "lon": -1.447 + }, + "location_history": [ + { + "lat": 53.804, + "lon": -1.4485, + "timestamp": "2024-11-25T16:15:11.108Z" + }, + { + "lat": 53.8045, + "lon": -1.449, + "timestamp": "2024-11-25T16:08:11.108Z" + }, + { + "lat": 53.805, + "lon": -1.45, + "timestamp": "2024-11-25T16:01:11.108Z" + }, + { + "lat": 53.806201, + "lon": -1.451106, + "timestamp": "2024-11-25T15:54:11.108Z" + } + ], + "updated_at": "2024-12-06T18:28:29.815Z", + "created_at": "2024-12-04T14:49:10.869Z" + } + ], + "cats": [ + { + "id": "cm3pz1t0v000308jka8bl7x25", + "name": "Daisy, Eater of Worlds", + "description": null, + "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", + "device_id": "cm4a07hsl0003wnalvfrzrczj", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "updated_at": "2024-12-06T18:31:06.913Z", + "created_at": "2024-12-04T14:49:10.883Z", + "battleProfileId": null + } + ], + "created_at": "2024-12-04T14:49:10.858Z" + } + ], + "count": 3 + } }, - "result": {} + "POST": { + "description": "Create a new user", + "authentication": "none", + "body": { + "username": "John Smith 123" + }, + "exampleResponse": { + "success": true, + "data": { + "id": "cm4epu1a30002rkizmhrbi1ff", + "username": "John Smith 123", + "requested_privacy": "PUBLIC", + "updated_at": "2024-12-07T21:57:37.634Z", + "created_at": "2024-12-07T21:57:37.634Z" + } + } + } }, "/api/users/:id/cats": { - "description": "List all of a users cats", - "method": "GET", - "authentication": "none", - "result": { - "success": true, - "data": [ - { - "id": "cm3ptn1mf0005flja3l1pl70b", - "name": "Cat", - "description": "Meow meow. Meow meow? Meow!", - "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", + "GET": { + "description": "List all of a users cats", + "authentication": "none", + "exampleResponse": { + "success": true, + "data": [ + { + "id": "cm3pr1rkb000008l8fs7icr9g", + "name": "Mr Tiddles", + "description": null, + "picture_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRWGpMwXI5hOZhVNL9Z1YZfhSgjjY1qEBRJgQ&s", + "device_id": null, + "owner_id": "cm3op7iwu0000jrcqa60tc9kv", + "updated_at": "2024-12-04T14:49:10.877Z", + "created_at": "2024-12-04T14:49:10.877Z", + "battleProfileId": null, + "battle_profile": { + "id": "cm3yd7wfc000108i6ef3w8hrl", + "level": 815, + "xp": 820, + "wins": 0, + "losses": 0, + "cat_id": "cm3pr1rkb000008l8fs7icr9g" + } + } + ] + } + } + }, + "/api/users/settings": { + "GET": { + "description": "Fetch a user's settings", + "authentication": "username", + "exampleResponse": { + "sucess": true, + "data": { + "id": "cm3op7iwu0000jrcqa60tc9kv", + "username": "user1", + "requested_privacy": "PRIVATE", + "updated_at": "2024-12-07T21:50:47.568Z", + "created_at": "2024-12-04T14:49:10.848Z" + } + } + }, + "PATCH": { + "description": "Update a user's settings", + "authentication": "username", + "body": { + "requested_privacy": "PRIVATE" + }, + "exampleResponse": { + "sucess": true, + "data": { + "id": "cm3op7iwu0000jrcqa60tc9kv", + "username": "user1", + "requested_privacy": "PRIVATE", + "updated_at": "2024-12-07T21:50:47.568Z", + "created_at": "2024-12-04T14:49:10.848Z" + } + } + } + }, + "/api/cats/create": { + "POST": { + "description": "Register a new cat", + "authentication": "username", + "body": { + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg" + }, + "exampleResponse": { + "success": true, + "data": { + "id": "cm4fjesok0001xntyd0rsa616", + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg", "device_id": null, "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "updated_at": "2024-11-20T11:49:55.576Z", - "created_at": "2024-11-20T11:49:55.576Z", - "deleted_at": null + "updated_at": "2024-12-08T11:45:35.154Z", + "created_at": "2024-12-08T11:45:35.154Z", + "battleProfileId": null } - ] + } } }, - "/api/users/:id/devices": { - "description": "List all of a users devices", - "method": "GET", - "authentication": "none", - "result": { - "success": true, - "data": [ - { - "id": "cm3owzqrd0001z4qlshsse6re", - "name": "GPS Device", - "uuid": "31ee122b-0bc3-446f-bf67-ea945cef4c1c", + "/api/cats/update": { + "PATCH": { + "description": "Update a cats social information", + "authentication": "username", + "body": { + "cat_id": "cm4fjesok0001xntyd0rsa616", + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg" + }, + "exampleResponse": { + "success": true, + "data": { + "id": "cm4fjesok0001xntyd0rsa616", + "name": "Catty Cat McCatFace", + "description": "A good kitty.", + "picture_url": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Placeholder_view_vector.svg", + "device_id": null, "owner_id": "cm3op7iwu0000jrcqa60tc9kv", - "last_pulse_at": null, - "last_location": {}, - "location_history": [], - "updated_at": "2024-11-19T20:36:00.698Z", - "created_at": "2024-11-19T20:36:00.698Z" + "updated_at": "2024-12-08T11:47:42.125Z", + "created_at": "2024-12-08T11:45:35.154Z", + "battleProfileId": null } - ] + } + } + }, + "/api/cats/leaderboard/:range": { + "GET": { + "description": "Fetch the leadboard for a time range.", + "authentication": "username", + "validParameters": { + "range": ["daily", "weekly", "monthly", "yearly", "all_time"] + }, + "exampleResponse": { + "success": true, + "data": [ + { + "id": "cm4a07hsl0003wnalvfrzrczj", + "name": "A Collar", + "uuid": "36932d18-78a2-4ceb-b979-64a5ed441551", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "last_pulse_at": "2024-11-25T16:22:11.108Z", + "last_location": { + "lat": 53.8035, + "lon": -1.447 + }, + "location_history": [ + { + "lat": 53.804, + "lon": -1.4485, + "timestamp": "2024-11-25T16:15:11.108Z" + }, + { + "lat": 53.8045, + "lon": -1.449, + "timestamp": "2024-11-25T16:08:11.108Z" + }, + { + "lat": 53.805, + "lon": -1.45, + "timestamp": "2024-11-25T16:01:11.108Z" + }, + { + "lat": 53.806201, + "lon": -1.451106, + "timestamp": "2024-11-25T15:54:11.108Z" + } + ], + "updated_at": "2024-12-06T18:28:29.815Z", + "created_at": "2024-12-04T14:49:10.869Z", + "cat": { + "id": "cm3pz1t0v000308jka8bl7x25", + "name": "Daisy, Eater of Worlds", + "description": null, + "picture_url": "https://c8.alamy.com/comp/DBTJAD/a-closeup-picture-of-a-cats-face-on-a-white-background-DBTJAD.jpg", + "device_id": "cm4a07hsl0003wnalvfrzrczj", + "owner_id": "cm3op7iww0001jrcqpq3qxx6i", + "updated_at": "2024-12-06T18:31:06.913Z", + "created_at": "2024-12-04T14:49:10.883Z", + "battleProfileId": null + }, + "score": 0 + } + ], + "range": "weekly" + } + } + }, + "/api/cats/nearby/:id/:distance": { + "GET": { + "description": "Fetch all cats within a certain distance of a cat.", + "authentication": "username", + "validParameters": { + "distance": "Number" + }, + "exampleResponse": "TBD" } } } From 85ef554ec5a1318fea756f50d189f0fd09bc07a6 Mon Sep 17 00:00:00 2001 From: stevelw Date: Thu, 13 Feb 2025 12:44:00 +0000 Subject: [PATCH 6/7] update api endpoint testing --- __tests__/app.test.ts | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/__tests__/app.test.ts b/__tests__/app.test.ts index 16f49a9..001bc2e 100644 --- a/__tests__/app.test.ts +++ b/__tests__/app.test.ts @@ -18,40 +18,16 @@ afterAll(() => { }); describe('🧪 Express Application', () => { - describe('Root', () => { - describe('GET /api', () => { - it('200: should return a successful response', () => { - return request(app) - .get('/api') - .expect(200) - .then(({ body }) => { - expect(body).toEqual({ - success: true, - }); + describe('GET /api', () => { + it('200: should return a successful response', () => { + return request(app) + .get('/api') + .expect(200) + .then(({ body }) => { + expect(body).toEqual({ + success: true, }); - }); - }); - - describe('GET /api/endpoints', () => { - const expectedData = {}; - endpointsJson.forEach((endpoint) => { - const copy = JSON.parse(JSON.stringify(endpoint)); - delete copy.path; - Object.assign(expectedData, { - [endpoint.path]: { - ...copy, - }, }); - }); - it('200: should return a successful response', () => { - return request(app) - .get('/api/endpoints') - .expect(200) - .then(({ body: { success, data } }) => { - expect(success).toBe(true); - expect(data).toEqual(expectedData); - }); - }); }); }); From 90ce00d68559f5be5da902780c22f5171f047f79 Mon Sep 17 00:00:00 2001 From: stevelw Date: Thu, 13 Feb 2025 12:47:11 +0000 Subject: [PATCH 7/7] fix test expected object --- __tests__/app.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/__tests__/app.test.ts b/__tests__/app.test.ts index 001bc2e..2b55aab 100644 --- a/__tests__/app.test.ts +++ b/__tests__/app.test.ts @@ -26,6 +26,7 @@ describe('🧪 Express Application', () => { .then(({ body }) => { expect(body).toEqual({ success: true, + data: expect.any(Object), }); }); });