{"id":21620640,"url":"https://github.com/raybb/url-shortener","last_synced_at":"2026-05-18T01:37:13.317Z","repository":{"id":95917830,"uuid":"413184248","full_name":"RayBB/url-shortener","owner":"RayBB","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-03T20:03:46.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T18:28:40.971Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/RayBB.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-10-03T20:03:08.000Z","updated_at":"2021-10-03T20:03:48.000Z","dependencies_parsed_at":"2023-05-17T14:31:30.562Z","dependency_job_id":null,"html_url":"https://github.com/RayBB/url-shortener","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RayBB/url-shortener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayBB%2Furl-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayBB%2Furl-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayBB%2Furl-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayBB%2Furl-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RayBB","download_url":"https://codeload.github.com/RayBB/url-shortener/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayBB%2Furl-shortener/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33161926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-24T23:12:14.699Z","updated_at":"2026-05-18T01:37:13.301Z","avatar_url":"https://github.com/RayBB.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"A url shortener\n\n# Getting started\n\n`npm install` - install dependencies\n\n`node index.js` - start the server\n\nIn a new terminal run: `curl -d '{\"url\":\"https://example.com\"}' -H 'Content-Type: application/json' http://localhost:3000`\n\nResponse: \n```JSON\n{\n  \"target_url\":\"https://yahoo.com\",\n  \"id\":\"cf0d7b5\",\n  \"created\":\"2021-10-03T19:26:15.415Z\",\n  \"domain\":\"yahoo.com\",\n  \"stats\":\n  {\n    \"total_visits\":0,\n    \"visits_by_day\":{}\n  }\n}\n```\nNow you can visit http://localhost:3000/cf0d7b5 and be redirected to example.com.\n\nYou can also visit http://localhost:3000/cf0d7b5/stats to see the stats for that url.\n\n# Development\n\nAutomatic restarting on code change:\n\n`npx nodemon index.js`\n\nAutomatically test when code changes:\n`npx nodemon test.js`\n\nI recommend running these in separate terminals for easy development.\n\n## Load Testing\n\nI recommend using [hey](https://github.com/rakyll/hey) for some basic load testing.\n\nOn my machine a single instance can handle about 6k requests per second.\n\nOn heroku we can handle about 600 requests per second.\n\n# Design\n\nI started trying https://github.com/swagger-api/swagger-node but got errors following the setup guide.\nThat paired with the fact that it has not been updated in a while made me decide to abandon it and stick with basics.\n\nWe use an in memory DB. This means each time your app closes all your data will be lost.\nThis can always be changed to a real document database (or relational if you desire).\n\n\n# Deployment\n\nYou can follow the [heroku guide](https://devcenter.heroku.com/articles/deploying-nodejs).\n\nBut if you already have heroku setup on your machine it's as simple as:\n\n`heroku create` - only the first time\n\n`git push heroku main` - whenever you want to deploy\n\nA demo instance is available at https://aqueous-river-19144.herokuapp.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraybb%2Furl-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraybb%2Furl-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraybb%2Furl-shortener/lists"}