{"id":19248257,"url":"https://github.com/hamidbyte/instant-tiny-url-backend","last_synced_at":"2026-04-18T07:35:24.459Z","repository":{"id":214845444,"uuid":"737485395","full_name":"HamidByte/Instant-Tiny-URL-Backend","owner":"HamidByte","description":"This project provides a straightforward solution for converting lengthy URLs into concise, easy-to-share links. Enjoy user-friendly features, quick shortening, and a customizable experience. Boost efficiency and simplify your online interactions with our sleek and secure URL Shortener.","archived":false,"fork":false,"pushed_at":"2024-01-31T14:37:21.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T16:14:47.892Z","etag":null,"topics":["backend","backend-api","backend-service","bitly","mongodb","mongodb-atlas","nodejs","short-url","short-urls","shorten-url","shorten-urls","shortener","shortener-url","tiny-url","ur","url-shortener","url-shortener-api"],"latest_commit_sha":null,"homepage":"","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/HamidByte.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":"2023-12-31T08:00:05.000Z","updated_at":"2024-01-05T15:57:35.000Z","dependencies_parsed_at":"2025-01-05T05:24:59.202Z","dependency_job_id":"94b0bd3c-4a4e-4cb5-be56-d2704179bd13","html_url":"https://github.com/HamidByte/Instant-Tiny-URL-Backend","commit_stats":null,"previous_names":["mhamid49/instant-tiny-url","mhamid49/instant-tiny-url-backend","hamidbyte/instant-tiny-url-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HamidByte/Instant-Tiny-URL-Backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamidByte%2FInstant-Tiny-URL-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamidByte%2FInstant-Tiny-URL-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamidByte%2FInstant-Tiny-URL-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamidByte%2FInstant-Tiny-URL-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HamidByte","download_url":"https://codeload.github.com/HamidByte/Instant-Tiny-URL-Backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamidByte%2FInstant-Tiny-URL-Backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["backend","backend-api","backend-service","bitly","mongodb","mongodb-atlas","nodejs","short-url","short-urls","shorten-url","shorten-urls","shortener","shortener-url","tiny-url","ur","url-shortener","url-shortener-api"],"created_at":"2024-11-09T18:07:08.608Z","updated_at":"2026-04-18T07:35:24.433Z","avatar_url":"https://github.com/HamidByte.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Instant Tiny URL Backend\n\nThis project provides a straightforward solution for converting lengthy URLs into concise, easy-to-share links. Enjoy user-friendly features, quick shortening, and a customizable experience. Boost efficiency and simplify your online interactions with our sleek and secure URL Shortener.\n\n## Frontend Repository\n\nFor the corresponding frontend, visit the [Instant Tiny URL Frontend](https://github.com/HamidByte/Instant-Tiny-URL-Frontend).\n\n## Prerequisites\n\nMake sure you have the following software installed on your machine:\n\n- [Node.js](https://nodejs.org/) (version 14 or higher)\n- [npm](https://www.npmjs.com/) (comes with Node.js)\n- [MongoDB](https://www.mongodb.com/) (Install locally or use MongoDB Atlas for a cloud-based solution.)\n- [Git](https://git-scm.com/) (optional but recommended)\n\n## Getting Started\n\n1. **Clone the Repository:**\n\n   ```bash\n   git clone https://github.com/HamidByte/Instant-Tiny-URL.git\n   ```\n\n2. **Navigate to the Project Directory:**\n\n   ```bash\n   cd Instant-Tiny-URL\n   ```\n\n3. **Install Dependencies:**\n\n   ```bash\n   npm install\n   ```\n\n4. **Configure Environment Variables:**\n\n   Create a .env file in the root of the project and set the following variables:\n\n   ```env\n    HOST=http://localhost\n    PORT=3000\n    MONGO_URI_DEV=your-mongo-uri-for-development\n    MONGO_URI_PROD=your-mongo-uri-for-production\n   ```\n\n5. **Update Configurations:**\n\n   Modify the configuration files in the `config` directory according to your needs.\n\n6. **Update your scripts in `package.json` for a cross-platform solution:**\n\n   If you are working in a Windows environment and using the Command Prompt, you should use the `set` command to set environment variables.\n\n   ```json\n    \"scripts\": {\n      \"start\": \"nodemon index.js\",\n      \"dev\": \"set NODE_ENV=development \u0026\u0026 nodemon index.js\",\n      \"prod\": \"set NODE_ENV=production \u0026\u0026 nodemon index.js\",\n    }\n   ```\n\n   If you are working in a Unix-like environment (Linux or macOS), you should use the `export` command to set environment variables.\n\n   ```json\n    \"scripts\": {\n      \"start\": \"nodemon index.js\",\n      \"dev\": \"export NODE_ENV=development \u0026\u0026 nodemon index.js\",\n      \"prod\": \"export NODE_ENV=production \u0026\u0026 nodemon index.js\",\n    }\n   ```\n\n   Make sure to check your environment and use the appropriate command accordingly.\n\n7. **Run the Application:**\n\n- For development:\n\n  ```bash\n  npm start\n  ```\n\n  or\n\n  ```bash\n  npm run dev\n  ```\n\n- For production:\n\n  ```bash\n  npm run prod\n  ```\n\n8. **Open in Browser:**\n\n   Open your web browser and go to http://localhost:3000 (or your specified port).\n\n## Endpoints\n\nThe URL shortener project provides the following endpoints:\n\n### Shorten URL\n\n- **Endpoint:** `/shortener`\n- **Method:** `POST`\n- **Request Body:**\n  - `longUrl`: The long URL that you want to shorten.\n- **Response:**\n  - If the URL is valid and successfully shortened, the API will return the shortened URL details.\n  - If the generated `shortId` already exists in the database, the API will generate a new `shortId` and return the corresponding details.\n\n**Example Request:**\n\n```bash\ncurl -X POST http://localhost:3000/shortener -H \"Content-Type: application/json\" -d '{\"longUrl\": \"https://example.com/\"}'\n```\n\n**Example Response:**\n\n```json\n{\n  \"_id\": \"some-unique-id\",\n  \"longUrl\": \"https://example.com/\",\n  \"shortId\": \"abc123\",\n  \"shortUrl\": \"http://localhost:3000/abc123\",\n  \"createdAt\": \"timestamp\",\n  \"updatedAt\": \"timestamp\"\n}\n```\n\n### Redirect to Long URL\n\n- **Endpoint:** `/:shortId`\n- **Method:** `GET`\n- **Response:**\n  - If the `shortId` exists in the database, the API will redirect to the long URL.\n  - If the `shortId` does not exist, the API will return a 404 error.\n\n**Example Request:**\n\n```bash\ncurl -L http://localhost:3000/abc123\n```\n\n**Note:** Replace `abc123` in the examples with the actual `shortId` generated.\n\n### URL Stats\n\n- **Endpoint:** `/stats/:shortId`\n- **Method:** `GET`\n- **Response:**\n  - Returns JSON information for the given `shortId`, including long URL, shortId, short URL, creation date, update date, and visit count.\n\n**Example Request:**\n\n```bash\ncurl http://localhost:3000/stats/abc123\n```\n\n**Example Response:**\n\n```json\n{\n  \"_id\": \"some-unique-id\",\n  \"longUrl\": \"https://example.com/\",\n  \"shortId\": \"abc123\",\n  \"shortUrl\": \"http://localhost:3000/abc123\",\n  \"createdAt\": \"timestamp\",\n  \"updatedAt\": \"timestamp\",\n  \"visitCount\": 10\n}\n```\n\n**Note:** Replace `abc123` in the examples with the actual `shortId` generated.\n\n### Check URL Existence\n\n- **Endpoint:** `/check/:shortId`\n- **Method:** `HEAD`\n- **Description:** Checks the existence of a URL based on the provided shortId. Responds with a 204 No Content status if the URL exists or a 404 Not Found status if the URL is not found.\n- **Note:** This endpoint is useful for pre-checking whether a short URL exists before attempting to redirect.\n\n**Example Request:**\n\n```bash\ncurl -I http://localhost:3000/check/abc123\n```\n\n**Example Response:**\n\n```bash\nHTTP/1.1 204 No Content\n```\n\n```bash\nHTTP/1.1 404 Not Found\n```\n\n**Status Codes:**\n\n- **`204 No Content:`** URL exists.\n- **`404 Not Found:`** URL not found.\n- **`500 Internal Server Error:`** Internal server error during the check.\n\n**Note:** Replace `abc123` in the examples with the actual `shortId` generated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamidbyte%2Finstant-tiny-url-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhamidbyte%2Finstant-tiny-url-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamidbyte%2Finstant-tiny-url-backend/lists"}