{"id":17125364,"url":"https://github.com/danielblagy/blog-webapp-server","last_synced_at":"2025-03-24T03:32:31.605Z","repository":{"id":184866040,"uuid":"480003802","full_name":"danielblagy/blog-webapp-server","owner":"danielblagy","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-19T08:23:21.000Z","size":100,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T09:45:06.294Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielblagy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-04-10T11:59:01.000Z","updated_at":"2022-12-04T05:32:34.000Z","dependencies_parsed_at":"2023-07-30T17:43:14.459Z","dependency_job_id":null,"html_url":"https://github.com/danielblagy/blog-webapp-server","commit_stats":null,"previous_names":["danielblagy/blog-webapp-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielblagy%2Fblog-webapp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielblagy%2Fblog-webapp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielblagy%2Fblog-webapp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielblagy%2Fblog-webapp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielblagy","download_url":"https://codeload.github.com/danielblagy/blog-webapp-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245204955,"owners_count":20577449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T18:44:46.295Z","updated_at":"2025-03-24T03:32:31.588Z","avatar_url":"https://github.com/danielblagy.png","language":"Go","readme":"# REST API Documentation\n\n## Contents\n* [Data Structures](#data-structures)\n\t* [User](#user)\n\t* [Article](#article)\n* [/users endpoint](#users)\n\t* [Get all users](#get-all-users)\n\t* [Get user by id](#get-user-by-id)\n\t* [Sign up user](#sign-up-user)\n\t* [Sign in user](#sign-in-user)\n\t* [Refresh User Tokens](#refresh-user-tokens)\n\t* [Get my data](#get-my-data)\n\t* [Update my data](#update-my-data)\n\t* [Delete my data](#delete-my-data)\n* [/articles endpoint](#articles)\n\t* [Get all articles](#get-all-articles)\n\t* [Get article by id](#get-article-by-id)\n\t* [Create article](#create-article)\n\t* [Update article](#update-article)\n\t* [Delete article](#delete-article)\n\n## Data structures\n\n### User\n\n| Name | Type | Description |\n| --- | --- | --- |\n| id | int | Primary key. |\n| login | string | Each user has a unique login, max length is 100 characters. |\n| fullname | string | First and last name of the user, max length is 300 characters. |\n| articles | []Article | An array of articles written by the user. |\n| followers | int | Followers count. |\n| following | int | Following count. |\n\nJSON Example of User object\n\n```json\n{\n    \"id\": 10,\n    \"login\": \"danielblagy\",\n    \"fullname\": \"Daniel Blagy\",\n    \"articles\": [\n        {\n            \"id\": 1,\n            \"author_id\": 10,\n            \"title\": \"New Title\",\n            \"content\": \"Updated content.\",\n            \"published\": true,\n            \"created_at\": \"2022-05-25T16:45:55.881063+03:00\",\n            \"updated_at\": \"2022-05-25T16:45:55.881063+03:00\",\n            \"author\": {\n                \"id\": 10,\n                \"login\": \"danielblagy\",\n                \"fullname\": \"Daniel Blagy\",\n                \"articles\": null,\n                \"followers\": 0,\n                \"following\": 0\n            },\n            \"saves\": 0\n        }\n    ],\n    \"followers\": 2,\n    \"following\": 0\n}\n```\n\n### Article\n\n| Name | Type | Description |\n| --- | --- | --- |\n| id | int | Primary key. |\n| author_id | int | ID of the user who owns the article. |\n| title | string | Title must be unique relative to other articles of the user, max length is 300 characters. |\n| content | string | The content of the article. |\n| published | boolean | If true, it's public and can be read by other users, it's private otherwise. |\n| created_at | timestamp | When the article was created. |\n| updated_at | timestamp | When the article was last updated (edited). |\n| author | Author | The author of the article. |\n| saves | int | Saves count (how many people have favorited the article). |\n\nJSON Example of Article object\n\n```json\n{\n    \"id\": 10,\n    \"author_id\": 12,\n    \"title\": \"Green Leopards\",\n    \"content\": \"Have u seen them?\",\n    \"published\": true,\n    \"created_at\": \"2022-05-25T16:57:06.772498+03:00\",\n    \"updated_at\": \"2022-05-25T16:58:14.365631+03:00\",\n    \"author\": {\n        \"id\": 12,\n        \"login\": \"sergey\",\n        \"fullname\": \"Sergey Urtugov\",\n        \"articles\": null,\n        \"followers\": 0,\n        \"following\": 0\n    },\n    \"saves\": 0\n}\n```\n\n## users/\n\n### *Get all users*\n### GET users/\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | An array named 'users' of User objects |\n| Failure | `404 Not Found` | `{ \"message\": [error message] }` |\n\n#### Example\n\nResponse on successful retrieval (`200 OK`)\n```json\n{\n    \"users\": [\n        {\n            \"id\": 8,\n            \"login\": \"jazz_oogie\",\n            \"fullname\": \"Jamie Dunkin\",\n            \"articles\": null\n        },\n        {\n            \"id\": 10,\n            \"login\": \"danielblagy\",\n            \"fullname\": \"Daniel Blagy\",\n            \"articles\": null\n        },\n        {\n            \"id\": 11,\n            \"login\": \"tomalberto\",\n            \"fullname\": \"Thomas Alberto\",\n            \"articles\": null\n        },\n        {\n            \"id\": 12,\n            \"login\": \"sergey\",\n            \"fullname\": \"Sergey Urtugov\",\n            \"articles\": null\n        },\n        {\n            \"id\": 13,\n            \"login\": \"tomsanders\",\n            \"fullname\": \"Tom Sanders\",\n            \"articles\": null\n        }\n    ]\n}\n```\n\n### *Get user by id*\n### GET users/:id\n\n#### Request\n\n`id` must correspond to user id.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | User object |\n| Failure | `404 Not Found` | `{ \"message\": \"record not found\" }` |\n\n#### Example\n\nRequest GET users/8\n\nResponse on success (`200 OK`)\n```json\n{\n    \"id\": 8,\n    \"login\": \"jazz_oogie\",\n    \"fullname\": \"Jamie Dunkin\",\n    \"articles\": [\n        {\n            \"id\": 5,\n            \"author_id\": 8,\n            \"title\": \"my article\",\n            \"content\": \"hello :)\",\n            \"published\": true\n        }\n    ]\n}\n```\n\n### *Sign up user*\n### POST users/signup\n\n#### Request\n\nRequest body structure (example)\n\n```json\n{\n    \"login\": \"danielblagy\",\n    \"fullname\": \"Daniel Blagy\",\n    \"password\": \"danielblagypassword\"\n}\n```\n\nlogin, fullname, and password must not be empty strings.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `201 Created` | User object of newly created user. |\n| Not all required fields provided | `400 Bad Request` | `{ \"message\": \"invalid user data\" }` |\n| Login is taken | `409 Conflict` | `{ \"message\": \"this login is taken\" }` |\n| Server Error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest POST users/signup\n\nRequest body\n```json\n{\n    \"login\": \"johnpeterson\",\n    \"fullname\": \"John Peterson\",\n    \"password\": \"johnp\"\n}\n```\n\nResponse on success (`201 Created`)\n```json\n{\n    \"id\": 14,\n    \"login\": \"johnpeterson\",\n    \"fullname\": \"John Peterson\",\n    \"articles\": null\n}\n```\n\n### *Sign in user*\n### POST users/signin\n\n#### Request\n\nRequest body structure (example)\n\n```json\n{\n    \"login\": \"danielblagy\",\n    \"password\": \"danielblagypassword\"\n}\n```\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | `{ \"access_token\": [], \"refresh_token\": [] }` |\n| Request body is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| No user with login | `404 Not Found` | `{ \"message\": \"user with this login doesn't exist\" }` |\n| Incorrect password | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| Server error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest POST users/signin\n\nRequest body\n```json\n{\n    \"login\": \"johnpeterson\",\n    \"password\": \"johnp\"\n}\n```\n\nResponse on success (`200 OK`)\n```json\n{\n    \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTMzODQ5ODEsImp0aSI6IjE0In0.UPMVXrXya9McDhECCE1OrnPayya6UQFvqtU67MdIJBE\",\n    \"refresh_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTUxOTg0ODEsImp0aSI6IjE0In0.le7yayzG8U-JHm0Vd2O8uR1doWaCKbCV899_8qQZih8\"\n}\n```\n\n### *Refresh User Tokens*\n### POST users/refresh\n\nUser must be signed in.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | `{ \"access_token\": [], \"refresh_token\": [] }` |\n| Refresh Token cookie doesn't exist | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Not logged it / Refresh Token has expired | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| Server error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest POST users/refresh\n\nResponse on success (`200 OK`)\n```json\n{\n    \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTMzODUyMjksImp0aSI6IjE0In0._RHg0S8TyWzNcXM5FjWzR6gHOA14Bq9YQexnw4uYfck\",\n    \"refresh_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTUxOTg3MjksImp0aSI6IjE0In0.p4AaMdA7EA6jsCRqWTkhBzY-_ZqKfFSE8reBLj72ylY\"\n}\n```\n\n### *Get my data*\n### GET users/me\n\nUser must be signed in.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | User object |\n| Access Token is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Couldn't get user by id / User doesn't exist | `404 Not Found` | `{ \"message\": [error message] }` |\n| Not logged it / Access Token has expired | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| Server error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest GET users/me\n\nResponse on success (`200 OK`)\n```json\n{\n    \"id\": 14,\n    \"login\": \"johnpeterson\",\n    \"fullname\": \"John Peterson\",\n    \"articles\": []\n}\n```\n\n### *Update my data*\n### PUT users/\n\nUser must be signed in.\n\n#### Request\n\nRequest body structure (example)\n\n```json\n{\n    \"fullname\": \"Daniel Updated Blagy\",\n    \"password\": \"myupdatedpassword\"\n}\n```\n\nOnly `fullname` and `password` fields of User object can be updated.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | User object |\n| Request body is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Access Token is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Not logged it / Access Token has expired | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| Couldn't get user with id / User doesn't exist | `404 Not Found` | `{ \"message\": [error message] }` |\n| Server error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest PUT users/\n\nRequest body\n```json\n{\n    \"fullname\": \"John Derek Peterson\",\n    \"password\": \"johnp2\"\n}\n```\n\nResponse on success (`200 OK`)\n```json\n{\n    \"id\": 14,\n    \"login\": \"johnpeterson\",\n    \"fullname\": \"John Derek Peterson\",\n    \"articles\": null\n}\n```\n\n### *Delete my data*\n### DELETE users/\n\nUser must be signed in.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | User object |\n| Request body is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Access Token is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Not logged it / Access Token has expired | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| Couldn't get user with id / User doesn't exist | `404 Not Found` | `{ \"message\": [error message] }` |\n| Server error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest DELETE users/\n\nResponse on success (`200 OK`)\n```json\n{\n    \"id\": 14,\n    \"login\": \"johnpeterson\",\n    \"fullname\": \"John Derek Peterson\",\n    \"articles\": []\n}\n```\n\n## /articles\n\n### *Get all articles*\n### GET articles/\n\nGet all published articles.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | An array of Article objects. |\n| Failure | `404 Not Found` | `{ \"message\": [error message] }` |\n\n#### Example\n\nRequest GET articles/\n\nResponse on success (`200 OK`)\n```json\n[\n    {\n        \"id\": 5,\n        \"author_id\": 8,\n        \"title\": \"my article\",\n        \"content\": \"hello :)\",\n        \"published\": true\n    },\n    {\n        \"id\": 1,\n        \"author_id\": 10,\n        \"title\": \"New Title\",\n        \"content\": \"Updated content.\",\n        \"published\": true\n    }\n]\n```\n\n### *Get article by id*\n### GET article/:id\n\nIf the user is authorized, they can access their private articles.\n\n#### Request\n\n`id` must correspond to article id.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | Article object |\n| Failure / Accessing private article while unauthorized | `404 Not Found` | `{ \"message\": \"record not found\" }` |\n| No access to a private article when authorized | `401 Unauthorized` | `{ \"message\": \"article is private\" }` |\n\n#### Example\n\nRequest GET articles/5\n\nResponse on success (`200 OK`)\n```json\n{\n    \"id\": 5,\n    \"author_id\": 8,\n    \"title\": \"my article\",\n    \"content\": \"hello :)\",\n    \"published\": true\n}\n```\n\n### *Create article*\n### POST articles/\n\nUser must be signed in.\n\n#### Request\n\nRequest body structure (example)\n\n```json\n{\n    \"title\": \"Green Leopards\",\n    \"content\": \"Have u seen them?\",\n    \"published\": false\n}\n```\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `201 Created` | Article object of newly created article. |\n| Request body is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Access Token is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Not logged it / Access Token has expired | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| User already has article with that title | `409 Conflict` | `{ \"message\": \"user already has article with this title\" }` |\n| Server Error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest POST articles/\n\nRequest body\n```json\n{\n    \"title\": \"Green Leopards\",\n    \"content\": \"Have u seen them?\",\n    \"published\": false\n}\n```\n\nResponse on success (`201 Created`)\n```json\n{\n    \"id\": 8,\n    \"author_id\": 12,\n    \"title\": \"Green Leopards\",\n    \"content\": \"Have u seen them?\",\n    \"published\": false\n}\n```\n\n### *Update article*\n### PUT articles/:id\n\nUser must be signed in.\n\n`id` must correspond to article id.\n\n#### Request\n\nRequest body structure (example)\n\n```json\n{\n    \"title\": \"Title updated\",\n    \"content\": \"Content updated\",\n    \"published\": true\n}\n```\n\nOnly `title`, `content`, and `published` fields of Article object can be updated.\n\n`title` field is optional (don't supply if you don't want it updated).\n\nIf `content` field is not provided, content will be updated to an empty string.\nIf you don't want `content` changed, provide the old value.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | Article object |\n| Request body is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Access Token is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Not logged it / Access Token has expired | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| User doesn't own the article | `401 Unauthorized` | `{ \"message\": \"access denied\" }` |\n| Couldn't get article with id / Article doesn't exist / Failure | `404 Not Found` | `{ \"message\": [error message] }` |\n| Server error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest PUT articles/8\n\nRequest body\n```json\n{\n    \"content\": \"Have u seen them? I bet you haven't.\",\n    \"published\": true\n}\n```\n\nResponse on success (`200 OK`)\n```json\n{\n    \"id\": 8,\n    \"author_id\": 12,\n    \"title\": \"Green Leopards\",\n    \"content\": \"Have u seen them? I bet you haven't.\",\n    \"published\": true\n}\n```\n\n### *Delete article*\n### DELETE articles/:id\n\nUser must be signed in.\n\n`id` must correspond to article id.\n\n#### Response\n\n| Case | Status | Body |\n| --- | --- | --- |\n| Success | `200 OK` | User object |\n| Request body is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Access Token is invalid | `400 Bad Request` | `{ \"message\": [error message] }` |\n| Not logged it / Access Token has expired | `401 Unauthorized` | `{ \"message\": [error message] }` |\n| User doesn't own the article | `401 Unauthorized` | `{ \"message\": \"access denied\" }` |\n| Couldn't get article with id / Article doesn't exist / Failure | `404 Not Found` | `{ \"message\": [error message] }` |\n| Server error | `500 Internal Server Error` | `{ \"message\": [server error] }` |\n\n#### Example\n\nRequest DELETE articles/8\n\nResponse on success (`200 OK`)\n```json\n{\n    \"id\": 8,\n    \"author_id\": 12,\n    \"title\": \"Green Leopards\",\n    \"content\": \"Have u seen them? I bet you haven't.\",\n    \"published\": true\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielblagy%2Fblog-webapp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielblagy%2Fblog-webapp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielblagy%2Fblog-webapp-server/lists"}