{"id":22421337,"url":"https://github.com/joelmcdaniel/stellar_exercise","last_synced_at":"2025-03-27T05:17:14.541Z","repository":{"id":121888435,"uuid":"321273146","full_name":"joelmcdaniel/stellar_exercise","owner":"joelmcdaniel","description":"Yet another interview coding challenge solution that I coded up in off hours. A $100 Amazon gift card was offered.","archived":false,"fork":false,"pushed_at":"2021-02-04T02:55:04.000Z","size":17,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-07T10:36:52.129Z","etag":null,"topics":["api","go","golang"],"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/joelmcdaniel.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":"2020-12-14T07:54:42.000Z","updated_at":"2024-06-19T09:14:53.918Z","dependencies_parsed_at":null,"dependency_job_id":"33fad93c-1964-436a-963e-f3c4ca8f58d2","html_url":"https://github.com/joelmcdaniel/stellar_exercise","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelmcdaniel%2Fstellar_exercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelmcdaniel%2Fstellar_exercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelmcdaniel%2Fstellar_exercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelmcdaniel%2Fstellar_exercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelmcdaniel","download_url":"https://codeload.github.com/joelmcdaniel/stellar_exercise/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245785811,"owners_count":20671634,"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":["api","go","golang"],"created_at":"2024-12-05T17:06:47.998Z","updated_at":"2025-03-27T05:17:14.232Z","avatar_url":"https://github.com/joelmcdaniel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stellar Exercise\n\nWhat is this? \n\nIt's yet another interview coding challenge solution that I coded up in a jiffy in off hours. Below are the requirements given and there was no communicaton channel offered to ask any questions about them. Yes the challenge was timed with a very short deadline. A $100 Amazon gift card was offered. I have no idea what the grading criteria was as there was no discussion offered for review. It's certainly not my best Golang code under the circumstances but I think it pretty much achieved \"minimum viable product\" for the requirements given and as quickly as possible. I don't think it's too bad myself. Perhaps the organization got a somewhat \"free\" solution out of it? Actually they did make good on the gift card so credit where credit is due for them for that. It's here for anyone else who thinks they might make some use of it.\n\n### This was the requirement given:\n \n\n# Stellar Coding Challenge\n\n## Summary\n\nWrite an API web server that accepts a snippet of text and makes that snippet\navailable at a URL. Each snippet should be available as text at a URL until it\nexpires. A snippet's expiry should be extended by 30 seconds each time it is accessed.\n\nThe request to store the snippet should accept this information:\n\n| Name       | Description                                      |\n|------------|--------------------------------------------------|\n| name       | Name of the snippet                              |\n| expires_in | Seconds from now until the snippet should expire |\n| snippet    | Contents of the snippet                          |\n\nThe request to store the snippet should be replied to with a response that\nincludes the URL where the snippet can be read.\n\nSnippets can be stored in memory, and do not need to be editable after storing.\nThe solution needs only to be an API, not a graphical or website user\ninterface.\n\nSnippets should be retrievable by name.\n\n## What we're looking for\n\n* An actual HTTP web server that runs and can be accessed through a URL\n* A clean, minimalistic implementation. Focus on the core functionality, and pay extra attention to API the service should serve\n* Appropriate use of web frameworks and open-source libraries as necessary. Think of this as building an MVP\n* Too little time? Your prioritization skills are also being evaluated\n* Readable and clear code, so that everyone and anyone can understand it\n\n## What we're not looking for\n\n* Don't write your own HTTP implementation. You won't get extra points for it, and this will probably take time that could be spent elsewhere\n* This is a simple problem. If your solution is complex, take a step back\n* Do not reinvent the wheel. Make use of all the tools you know and like, as well as the knowledge you've built throughout your career\n\n## Test Cases\n\nWe expect you to implement this API exactly. Please ensure your solution handles these test cases correctly.\n\n```sh\n\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"name\":\"recipe\", \"expires_in\": 30, \"snippet\":\"1 apple\"}' https://example.com/snippets\n# response 201 Created\n{\n  \"url\": \"https://example.com/snippets/recipe\",\n  \"name\": \"recipe\",\n  \"expires_at\": \"2020-02-22T20:02:02Z\",\n  \"snippet\": \"1 apple\"\n}\n\ncurl https://example.com/snippets/recipe\n# response 200 OK\n{\n  \"url\": \"https://example.com/snippets/recipe\",\n  \"name\": \"recipe\",\n  \"expires_at\": \"2020-02-22T20:02:32Z\",\n  \"snippet\": \"1 apple\"\n}\n\n# wait 60 seconds\n\ncurl https://example.com/snippets/recipe\n# response 404 Not Found\n\n```\n\n## Instructions I provided for the evaluator of this solution:\n\n### 1. Install gorilla mux package\n```bash\ngo get -u github.com/gorilla/mux\n```\n### 3. Build the project\n```bash\ngo build\n```\n### 3. Run the web server passing flags for cert and key files (you will need your own cert and key files in your own environment)\n```bash\n[sudo] ./stellar_exercise -cert=\u003cpath to cert file\u003e -key=\u003cpath to key file\u003e\n```\n### 4. Run test cases with curl\n#### Create snippet\n```bash\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"name\":\"recipe\", \"expires_in\": 30, \"snippet\":\"1 apple\"}' https://example.com/snippets\n# response 201 Created\n{\n  \"url\": \"https://example.com/snippets/recipe\",\n  \"name\": \"recipe\",\n  \"expires_at\": \"2020-12-13T20:02:02Z\",\n  \"snippet\": \"1 apple\"\n}\n```\n#### Fetch snippet\n```bash\ncurl https://example.com/snippets/recipe\n# response 200 OK\n{\n  \"url\": \"https://example.com/snippets/recipe\",\n  \"name\": \"recipe\",\n  \"expires_at\": \"2020-12-13T20:02:32Z\",\n  \"snippet\": \"1 apple\"\n}\n```\n#### Wait 60 seconds and try to fetch again\n```bash\ncurl https://example.com/snippets/recipe\n# response 404 Not Found\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelmcdaniel%2Fstellar_exercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelmcdaniel%2Fstellar_exercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelmcdaniel%2Fstellar_exercise/lists"}