{"id":24127121,"url":"https://github.com/codefta/go-mini-kraicklist","last_synced_at":"2025-06-11T22:09:11.966Z","repository":{"id":51130880,"uuid":"366251356","full_name":"codefta/go-mini-kraicklist","owner":"codefta","description":"Practicing go with building the mini restful API","archived":false,"fork":false,"pushed_at":"2021-07-25T14:15:34.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-04T12:37:20.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/codefta.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}},"created_at":"2021-05-11T04:08:34.000Z","updated_at":"2022-08-03T02:55:31.000Z","dependencies_parsed_at":"2022-08-23T17:00:44.975Z","dependency_job_id":null,"html_url":"https://github.com/codefta/go-mini-kraicklist","commit_stats":null,"previous_names":["fathisiddiqi/go-mini-kraicklist"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codefta/go-mini-kraicklist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codefta%2Fgo-mini-kraicklist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codefta%2Fgo-mini-kraicklist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codefta%2Fgo-mini-kraicklist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codefta%2Fgo-mini-kraicklist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codefta","download_url":"https://codeload.github.com/codefta/go-mini-kraicklist/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codefta%2Fgo-mini-kraicklist/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259353144,"owners_count":22844749,"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":"2025-01-11T17:39:23.554Z","updated_at":"2025-06-11T22:09:11.943Z","avatar_url":"https://github.com/codefta.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mini Kraicklist\n\nIn this exercise we will learn how to create simple REST API using Go.\n\nWe are trying to create API for imaginary classified ads website called Kraicklist (pun of Craigslist). The idea is user could post new ads \u0026 get latest ads from it.\n\nPlease check upcoming sections for details of API design.\n\nYour tasks:\n\n1. Implement the server API using Go \u0026 MySQL\n2. Containerize your server API using Docker\n3. Create deployment template using Docker Compose which include the deployment script for your server \u0026 MySQL server\n4. Separate components in your code to packages (e.g `Storage` should be on `storage` package not `main`)\n5. Create test files for each components\n\n---\n\n## Post New Ad\n\nPOST: `/ads`\n\nThis API is used for posting new ad.\n\n**Request Body:**\n\n- `title`, String =\u003e title of the ad\n- `body`, String =\u003e body of the ad contains descriptions\n- `tags`, Array of String, _optional_ =\u003e related tags for the ad if any\n\n**Sample Request:**\n\n```json\n{\n  \"title\": \"Porsche Carrera GT 2016 for Sale\",\n  \"body\": \"Clean body \u0026 great engine!\",\n  \"tags\": [\"car\", \"porsche\", \"porsche 2016\"]\n}\n```\n\n**Success Response:**\n\n```json\nHTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n    \"success\": true,\n    \"data\": {\n        \"id\": 1282323,\n        \"title\": \"Porsche Carrera GT 2016 for Sale\",\n        \"body\": \"Clean body \u0026 great engine!\",\n        \"tags\": [\n            \"car\",\n            \"porsche\",\n            \"porsche 2016\"\n        ],\n        \"created_at\": 1581931121\n    }\n}\n```\n\n**Error Responses:**\n\n- Bad Request\n\n  ```json\n  HTTP/1.1 400 Bad Request\n  Content-Type: application/json\n\n  {\n      \"success\": false,\n      \"err\": \"ERR_BAD_REQUEST\",\n      \"message\": \"field `title` cannot be empty\"\n  }\n  ```\n\n[Back to Top](#mini-kraicklist)\n\n---\n\n## Get Latest Ads\n\nGET: `/ads?limit=\u003climit\u003e`\n\nThis API is used for getting latest ads from database.\n\nIf `limit` value is not specified, by default the value is `5`.\n\n**Sample Request:**\n\n```json\nGET: /ads?limit=10\n```\n\n**Success Response:**\n\n```json\nHTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n    \"success\": true,\n    \"data\": {\n        \"ads\": [\n            {\n                \"id\": 1282323,\n                \"title\": \"Porsche Carrera GT 2016 for Sale\",\n                \"body\": \"Clean body \u0026 great engine!\",\n                \"tags\": [\n                    \"car\",\n                    \"porsche\",\n                    \"porsche 2016\"\n                ],\n                \"created_at\": 1581931121,\n                \"updated_at\": 1581931121\n            }\n        ]\n    }\n}\n```\n\n**Error Responses:**\n\nNo specific error responses\n\n[Back to Top](#mini-kraicklist-extended)\n\n---\n\n## Update Ad\n\nPUT: `/ads/\u003cad_id\u003e`\n\nThis API is used for updating ad.\n\n**Request Body:**\n\n- `title`, String, _optional_ =\u003e updated title of the ad\n- `body`, String, _optional_ =\u003e updated body of the ad\n- `tags`, Array of String, _optional_ =\u003e updated related tags for the ad\n\n**Sample Request:**\n\n```json\nPUT: /ads/1282323\nContent-Type: application/json\n\n{\n    \"title\": \"Porsche Carrera GT 2016 \u0026 2017 for Sale!\",\n    \"body\": \"Both of them have clean body \u0026 great engine!\",\n    \"tags\": [\n        \"car\",\n        \"porsche\",\n        \"porsche 2016\",\n        \"porsche 2017\"\n    ]\n}\n```\n\n**Success Response:**\n\n```json\nHTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n    \"success\": true,\n    \"data\": {\n        \"id\": 1282323,\n        \"title\": \"Porsche Carrera GT 2016 \u0026 2017 for Sale!\",\n        \"body\": \"Both of them have clean body \u0026 great engine!\",\n        \"tags\": [\n            \"car\",\n            \"porsche\",\n            \"porsche 2016\",\n            \"porsche 2017\"\n        ],\n        \"updated_at\": 1582000607\n    }\n}\n```\n\n**Error Responses:**\n\n- Bad Request\n\n  ```json\n  HTTP/1.1 400 Bad Request\n  Content-Type: application/json\n\n  {\n      \"success\": false,\n      \"err\": \"ERR_BAD_REQUEST\",\n      \"message\": \"at least one parameter must be specified\"\n  }\n  ```\n\n- Not Found\n\n  ```json\n  HTTP/1.1 404 Not Found\n  Content-Type: application/json\n\n  {\n      \"success\": false,\n      \"err\": \"ERR_NOT_FOUND\",\n      \"message\": \"data is not found\"\n  }\n  ```\n\n[Back to Top](#mini-kraicklist-extended)\n\n---\n\n## Delete Ad\n\nDELETE: `/ads/\u003cad_id\u003e`\n\nThis API is used for deleting ad. The ad will be literally deleted from database.\n\n**Sample Request:**\n\n```json\nDELETE /ads/1282323\n```\n\n**Success Response:**\n\n```json\nHTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n    \"success\": true,\n    \"data\": {\n        \"id\": 1282323\n    }\n}\n```\n\n**Error Responses:**\n\n- Not Found\n\n  ```json\n  HTTP/1.1 404 Not Found\n  Content-Type: application/json\n\n  {\n      \"success\": true,\n      \"err\": \"ERR_NOT_FOUND\",\n      \"message\": \"data is not found\"\n  }\n  ```\n\n[Back to Top](#mini-kraicklist-extended)\n\n---\n\n## Get Ad Statistics\n\nGET: `/stats`\n\nThis API is used for fetching ads statistic. Currently we will only show total ads in statistic.\n\n**Sample Request:**\n\n```json\nGET /stats\n```\n\n**Success Response:**\n\n```json\nHTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n    \"success\": true,\n    \"data\": {\n        \"stats\": {\n            \"total_ads\": 1\n        }\n    }\n}\n```\n\n**Error Responses:**\n\nNo specific error response\n\n[Back to Top](#mini-kraicklist-extended)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodefta%2Fgo-mini-kraicklist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodefta%2Fgo-mini-kraicklist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodefta%2Fgo-mini-kraicklist/lists"}