{"id":23003291,"url":"https://github.com/pr4j3sh/shorten","last_synced_at":"2026-04-11T18:03:14.598Z","repository":{"id":261321510,"uuid":"883961520","full_name":"pr4j3sh/shorten","owner":"pr4j3sh","description":"URL shortener API","archived":false,"fork":false,"pushed_at":"2025-01-13T03:30:11.000Z","size":55,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T05:27:10.307Z","etag":null,"topics":["api","docker","express","kubernetes","nginx","nodejs","url-shortener"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/pr4j3sh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-11-05T22:12:25.000Z","updated_at":"2025-01-13T03:30:14.000Z","dependencies_parsed_at":"2024-11-05T23:22:59.912Z","dependency_job_id":"d4cf1f90-9451-491b-abc9-2a9ed607741e","html_url":"https://github.com/pr4j3sh/shorten","commit_stats":null,"previous_names":["pr4j3sh/url-shortener","pr4j3sh/shorten"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr4j3sh%2Fshorten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr4j3sh%2Fshorten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr4j3sh%2Fshorten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pr4j3sh%2Fshorten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pr4j3sh","download_url":"https://codeload.github.com/pr4j3sh/shorten/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246829135,"owners_count":20840578,"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","docker","express","kubernetes","nginx","nodejs","url-shortener"],"created_at":"2024-12-15T07:13:51.452Z","updated_at":"2026-04-11T18:03:09.567Z","avatar_url":"https://github.com/pr4j3sh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shorten\n\nThis is an express js server API for shortening URL.\n\n## Features\n\n- Auto Scaling\n- Load Balancing\n\n## API Endpoints\n\n- Upload url, returns code\n\n```\nPOST /api/shorten\n```\n\n```json\n{\n  \"url\": \"https://github.com/pr4j3sh/shorten\"\n}\n```\n\n- Redirect to original url\n\n```\nGET /api/:code\n```\n\n- Delete an url\n\n```\nDELETE /api/:code\n```\n\n### Pre-requisites\n\n- [Node.js](https://nodejs.org/en)\n- [PostgreSQL](https://www.postgresql.org/)\n- [Redis](https://redis.io/)\n- [Docker](https://www.docker.com/)\n- [Kubernetes](https://kubernetes.io/)\n- [Minikube](https://minikube.sigs.k8s.io/docs/)\n- [Aiven PostgreSQL Database](https://aiven.io/)\n- [Upstash Redis Database](https://upstash.com/)\n\n## Installation\n\n```bash\ngit clone https://github/pr4j3sh/shorten.git\ncd shorten\n```\n\n- Setup environment variables\n\n```bash\nmv .env.example .env\n```\n\n- Edit the contents\n\n```.env\nENV=\"pro\"\nPORT=5000\nHOSTNAME=0.0.0.0\nORIGINS=\"http://${HOSTNAME}:${PORT}\"\nPOSTGRES_URI=\u003cpostgres_uri\u003e\nREDIS_URI=\u003credis_uri\u003e\nPOSTGRES_CERT_PATH=./certs/ca.pem\n```\n\n\u003e Sign up and get URIs from [Aiven](https://aiven.io/)(PostgreSQL) along with SSL certificate and [Upstash](https://upstash.com/)(Redis)\n\n- Setup databases\n\n```bash\npsql \u003cPOSTGRES_URI\u003e\n```\n\n```sql\nCREATE TABLE urls (\nid SERIAL PRIMARY KEY,\nurl VARCHAR(100),\ncode VARCHAR(6)\n);\n```\n\n```bash\nredis-cli --tls -u \u003cREDIS_URI\u003e\n```\n\n## Usage\n\n### via Source\n\n- Run using `dev`\n\n```bash\nnpm run dev\n```\n\n### via Kubernetes\n\n```bash\nminikube start\n```\n\n```bash\nhelm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx\nhelm repo update\n```\n\n```bash\nhelm install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx --create-namespace\n```\n\n```bash\nminikube addons enable ingress\n```\n\n- download `ca.pem` from Aiven PostgreSQL Database and place in the root of project directory\n\n```bash\nkubectl create secret generic postgres-cert --from-file=ca.pem\n```\n\n```bash\nkubectl create configmap shorten --from-env-file=.env\n```\n\n- start kubernetes metrics-server\n\n```bash\nkubectl apply -f components.yaml\n```\n\n- check metrics-server running\n\n```bash\nkubectl top nodes\n```\n\n- Deploy shorten\n\n```bash\nkubectl apply -f deployment.yaml\n```\n\n- Expose shorten\n\n```bash\nkubectl apply -f loadbalancer.yaml\n```\n\n- Get minikube ip address\n\n```bash\nminikube ip\n```\n\n```bash\nsudo nvim /etc/hosts\n```\n\n```hosts\n\u003cminikube_ip\u003e   shorten.eleven.me\n```\n\n\u003e save and close file\n\n- Now use curl to check server status\n\n```bash\ncurl http://shorten.eleven.me/api/check\n```\n\n- Delete deployments\n\n```bash\nkubectl delete -f loadbalancer.yaml \u0026\u0026 kubectl delete -f deployment.yaml \u0026\u0026 kubectl delete configmap shorten kubectl delete secret postgres-cert \u0026\u0026 kubectl delete -f components.yaml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr4j3sh%2Fshorten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpr4j3sh%2Fshorten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr4j3sh%2Fshorten/lists"}