{"id":23390532,"url":"https://github.com/tty47/go-toggl","last_synced_at":"2025-04-08T14:21:06.732Z","repository":{"id":107119140,"uuid":"356591715","full_name":"tty47/go-toggl","owner":"tty47","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-12T09:07:33.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-22T03:32:41.596Z","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/tty47.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-10T13:35:37.000Z","updated_at":"2021-04-12T09:07:35.000Z","dependencies_parsed_at":"2023-06-18T23:40:59.307Z","dependency_job_id":null,"html_url":"https://github.com/tty47/go-toggl","commit_stats":null,"previous_names":["tty47/go-toggl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tty47%2Fgo-toggl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tty47%2Fgo-toggl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tty47%2Fgo-toggl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tty47%2Fgo-toggl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tty47","download_url":"https://codeload.github.com/tty47/go-toggl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856552,"owners_count":21007622,"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-12-22T03:32:00.302Z","updated_at":"2025-04-08T14:21:06.704Z","avatar_url":"https://github.com/tty47.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-toggl\n\n\n### API Requirements\n\nQuestions have a simple structure.\nEach question has a body. Then there are two or more options.\nEach option has a body as well and a boolean attribute that defines whether the option is correct. \nAt least one of the options is correct.\nBelow is a JSON representation of a sample question.\n\n```json\n{\n  \"body\": \"Where does the sun set?\",\n  \"options\": [\n    {\n      \"body\": \"East\",\n      \"correct\": false\n    },\n    {\n      \"body\": \"West\",\n      \"correct\": true\n    }\n  ]\n}\n```\n\n### Listing questions\n\nEndpoint:\n```http\nhttp://localhost:3000/q\n```\nMETHOD:\n```http\nGET\n```\n\nThe first endpoint should return a list of all questions in the database.\nThe order of questions and options inside questions should be stable, i.e. not change on every request. The whole question, including the options is returned.\n\nFor example, the response could look like this:\n\n```json5\n[\n  {\n    \"body\": \"Where does the sun set?\",\n    \"options\": [\n      {\n        \"body\": \"East\",\n        \"correct\": false\n      },\n      // other options...\n    ]\n  },\n  {\n    \"body\": \"What is the answer to the ultimate question of life, the universe, and everything?\",\n    // rest of the question...\n  },\n  {\n    \"body\": \"But what is the ultimate question?\",\n    // rest of the question...\n  }\n]\n```\n\n### Creating a new question\nEndpoint:\n```http\nhttp://localhost:3000/q\n```\nMETHOD:\n```http\nPOST\n```\n\nThe second endpoint creates a new question in the database and then returns it in the response. The request body contains the question in JSON. The order of options in the request body should be stored as well and the same order should be returned by the API from all requests.\n\nFor example, for the request containing the following JSON, the server would return the question show above, in the Questions section.\n\n```json\n{\n  \"body\": \"Where does the sun set?\",\n  \"options\": [\n    {\n      \"body\": \"East\",\n      \"correct\": false\n    },\n    {\n      \"body\": \"West\",\n      \"correct\": true\n    }\n  ]\n}\n```\n\n### Updating a question\nEndpoint:\n```http\nhttp://localhost:3000/q/{id}\n```\nMETHOD:\n```http\nPUT\n```\n\nThe third endpoint updates an existing question and returns the updated question in the response.\nThe whole question is included in the request body, including all attributes. \nThe question to be updated should be identified in the request URL. \nThe order of options in the request body should be stored the same way as explained in the create endpoint above.\n\nFor example, to change the question from before to ask about sunrise, we would send the following JSON.\n\n```json\n{\n  \"body\": \"Where does the sun rise?\",\n  \"options\": [\n    {\n      \"body\": \"East\",\n      \"correct\": true\n    },\n    {\n      \"body\": \"West\",\n      \"correct\": false\n    }\n  ]\n}\n```\n\n## Basic requirements\n\nYour solution should meet all these requirements.\n\n- [ ] Endpoint that returns a list of all questions\n- [X] Endpoint that allows to add a new question\n- [X] Endpoint that allows to update an existing question\n- [X] Question data is stored in a SQLite database with a **normalised** schema\n\n  Use **PostgreSQL** with [migrations](https://github.com/jrmanes/go-toggl/tree/main/internal/data/db/migrations)\n  Running in a [docker-compose](https://github.com/jrmanes/go-toggl/blob/main/infra/docker/docker-compose.yml)\n- [X] The order of questions and options is stable, not random\n- [X] The `PORT` environment variable is used as the port number for the server, defaulting to 3000\n\n## Bonus requirements\n\nThese requirements are not required, but feel free to complete some of them if they seem interesting, or to come up with your own :)\n\n- [X] Endpoint that allows to delete existing questions\n  Endpoint:\n```http\nhttp://localhost:3000/q/{id}\n```\nMETHOD:\n```http\nDELETE\n```\n- [ ] Pagination for the list endpoint\n\n  This can be in the form of basic offset pagination, or seek pagination. The difference is explained in [this post](https://web.archive.org/web/20210205081113/https://taylorbrazelton.com/posts/2019/03/offset-vs-seek-pagination/).\n\n- [X] JWT authentication mechanism\n\n  Clients are required to send a JSON Web Token that identifies the user in some way. The API returns only questions that belong to the authenticated user. Endpoint for generating tokens is not needed, we can generate them through [jwt.io](https://jwt.io/).\n  \n  In order to test the endpoints with authentications, use the **[secret](https://github.com/jrmanes/go-toggl/blob/main/.env#L16)**.\n\n- [ ] Use GraphQL instead of REST to implement the API\n\n  Define a schema for the API that covers the basic requirements and implement all queries and resolvers. You do not need to implement the REST API if you choose to do this.\n\n\n## Setup the project\n\n\nIn order to make it easy, there is a Makefile with different actions, to start the project, just execute:\n```Makefile\nmake setup_project\n```\n\n### Apply migrations to database\nIn order to create the **first schema** of the database, just execute:\n```Makefile\nmake migrate_up\n```\nThat command will execute the migrations against the database.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftty47%2Fgo-toggl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftty47%2Fgo-toggl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftty47%2Fgo-toggl/lists"}