{"id":28441169,"url":"https://github.com/allisson/go-url-shortener","last_synced_at":"2025-07-09T23:37:37.436Z","repository":{"id":57501558,"uuid":"204168014","full_name":"allisson/go-url-shortener","owner":"allisson","description":"Golang url shortener using clean code","archived":false,"fork":false,"pushed_at":"2019-08-27T15:55:30.000Z","size":20,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-06T04:09:03.238Z","etag":null,"topics":["clean-architecture","clean-code","golang","hexagonal-architecture"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allisson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-24T14:25:58.000Z","updated_at":"2023-06-25T16:07:46.000Z","dependencies_parsed_at":"2022-09-19T14:50:31.809Z","dependency_job_id":null,"html_url":"https://github.com/allisson/go-url-shortener","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allisson/go-url-shortener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fgo-url-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fgo-url-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fgo-url-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fgo-url-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allisson","download_url":"https://codeload.github.com/allisson/go-url-shortener/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fgo-url-shortener/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264505340,"owners_count":23618926,"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":["clean-architecture","clean-code","golang","hexagonal-architecture"],"created_at":"2025-06-06T04:09:03.198Z","updated_at":"2025-07-09T23:37:37.429Z","avatar_url":"https://github.com/allisson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-url-shortener\n[![Build Status](https://travis-ci.org/allisson/go-url-shortener.svg)](https://travis-ci.org/allisson/go-url-shortener) [![Go Report Card](https://goreportcard.com/badge/github.com/allisson/go-url-shortener)](https://goreportcard.com/report/github.com/allisson/go-url-shortener)\n\nGolang url shortener using clean code.\n\nFeatures:\n\n* Multiple storage engine: Redis and MongoDB.\n* Multiple message format: JSON and Msgpack.\n\n## Run Tests\n\n1. Set envvars\n\n```bash\nexport MONGODB_URL=mongodb://localhost/shortener\nexport MONGODB_TIMEOUT=30\nexport MONGODB_DATABASE=shortener\nexport REDIS_URL=redis://localhost:6379\n```\n\n2. Run tests\n\n```bash\nmake test\n```\n\n## Run the server\n\n1. Set envvars\n\nFor redis storage:\n\n```bash\nexport PORT=3000\nexport STORAGE_ENGINE=redis\nexport REDIS_URL=redis://localhost:6379\n```\n\nFor mongo storage:\n\n```bash\nexport PORT=3000\nexport STORAGE_ENGINE=mongo\nexport MONGODB_URL=mongodb://localhost/shortener\nexport MONGODB_TIMEOUT=30\nexport MONGODB_DATABASE=shortener\n```\n\n2. Run the server\n\nWith binary:\n\n```bash\nmake build\n./shortener\n```\n\nWithout binary:\n\n```bash\nmake run\n```\n\n## How to use\n\nCreate new short url:\n\n```bash\ncurl -X POST http://localhost:3000 \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n\t\"url\": \"https://github.com/allisson\"\n}'\n```\n\nThe response:\n\n```json\n{\n    \"code\": \"YzaFuvFWg\",\n    \"url\": \"https://github.com/allisson\",\n    \"created_at\": 1566827456\n}\n```\n\nGet redirected:\n\n```bash\ncurl -X GET http://localhost:3000/YzaFuvFWg\n```\n\nThe response:\n\n```bash\n\u003ca href=\"https://github.com/allisson\"\u003eMoved Permanently\u003c/a\u003e.\n```\n\nIf you want to use msgpack format, change `Content-Type` header to `application/x-msgpack`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallisson%2Fgo-url-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallisson%2Fgo-url-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallisson%2Fgo-url-shortener/lists"}