{"id":26636026,"url":"https://github.com/sunjay-dev/url-shortner-using-mongodb","last_synced_at":"2025-03-24T16:16:30.375Z","repository":{"id":281248373,"uuid":"944607260","full_name":"sunjay-dev/URL-Shortner-Using-Mongodb","owner":"sunjay-dev","description":"A URL Shortner created using Mongodb","archived":false,"fork":false,"pushed_at":"2025-03-15T17:13:14.000Z","size":331,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T16:16:21.678Z","etag":null,"topics":["mongodb","mongoose","nodejs","url","url-redirect","url-shortener"],"latest_commit_sha":null,"homepage":"https://i.sunjay.xyz/","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/sunjay-dev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-07T16:41:21.000Z","updated_at":"2025-03-15T17:13:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"55a2e2d2-0e70-4ad9-a179-b8a5ba866ba1","html_url":"https://github.com/sunjay-dev/URL-Shortner-Using-Mongodb","commit_stats":null,"previous_names":["sunjay-dev/url-shortner-using-mongodb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunjay-dev%2FURL-Shortner-Using-Mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunjay-dev%2FURL-Shortner-Using-Mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunjay-dev%2FURL-Shortner-Using-Mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunjay-dev%2FURL-Shortner-Using-Mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunjay-dev","download_url":"https://codeload.github.com/sunjay-dev/URL-Shortner-Using-Mongodb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304872,"owners_count":20593626,"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":["mongodb","mongoose","nodejs","url","url-redirect","url-shortener"],"created_at":"2025-03-24T16:16:29.603Z","updated_at":"2025-03-24T16:16:30.346Z","avatar_url":"https://github.com/sunjay-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL Shortener Using Mongodb\n\nA simple URL shortener built with Node.js and Express.js that stores shortened URLs in MongoDB. This project allows users to create short URLs and redirect to the original URLs.\n\n## Features\n\n- Shorten long URLs and access them using a shorter link.\n- Store and manage URL mappings in MongoDB.\n- Track click statistics and visit history.\n- Enhanced Error handling.\n\n## Technologies Used\n![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge\u0026logo=node.js\u0026logoColor=white) \n![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge\u0026logo=express\u0026logoColor=%2361DAFB) \n![EJS](https://img.shields.io/badge/ejs-%23B4CA65.svg?style=for-the-badge\u0026logo=ejs\u0026logoColor=black) \n![TailwindCSS](https://img.shields.io/badge/tailwindcss-%2338B2AC.svg?style=for-the-badge\u0026logo=tailwind-css\u0026logoColor=white) \n![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white) \n![Render](https://img.shields.io/badge/Render-%46E3B7.svg?style=for-the-badge\u0026logo=render\u0026logoColor=white)\n- Express + Node.js\n- shortid (For creating short id for url)\n- Mongoose (For Storage)\n- Ejs (For Frontend)\n\n## Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/sunjay-dev/URL-Shortner-Using-Mongodb\n   cd URL-Shortner-Using-Mongodb\n   npm install\n\n2. Set up environment variables in a `.env` file (see below).\n3. Run the server:\n   ```bash\n   npm start\n   ```\n\n## Environment Variables\nCreate a `.env` file in the root directory and add the following:\n```env\nPORT=9000\nJWT_SECRET=JWT_SECRET\nmongoUri=MONGODB_URL\nGITHUB_CLIENT_ID=GITHUB_CLIENT_ID\nGITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET\nGITHUB_CALLBACK_URL=http://localhost:9000/user/auth/github/callback\nGOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID\nGOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET\nGOOGLE_CALLBACK_URL=http://localhost:9000/user/auth/google/callback\n```\n\n## Routes\n\nThe application provides the following routes:\n\n### GET `/shortid`\n- **Description**: Handles requests to the shortened URL and redirects to the original URL.\n- **Parameters**:\n  - `shortId`: The short ID of the URL to redirect.\n- **Response**:\n  - On success, redirects to the original URL.\n  - If the short ID does not exist, returns a 404 error.\n  \n### POST `/`\n- **Description**: Creates a new shortened URL.\n- **Request Body**:\n  - `url`: The original URL to be shortened.\n- **Response**:\n  - Returns a JSON object containing the shortened URL.\n\n### POST `/custom`\n- **Description**: Creates a new shortened URL with a custom alias.\n- **Request Body**:\n  - `url`: The original URL to be shortened.\n  - `custom`: The custom alias for the shortened URL.\n- **Response**:\n  - Returns a JSON object containing the shortened URL with the custom alias.\n  - If the custom alias is already in use, returns an 409 error message.\n\n### GET `/api/details?url=shortId`\n- **Description**: Provides details about shortened url.\n- **Parameters**:\n  - `shortId`: The short ID of the URL to retrieve.\n- **Response**:\n  - On success, returns a JSON object containing number of click, original url, and array of lastOpened times.\n  - If the short ID does not exist, returns a 404 error.\n\n\n\n\n## Contributing\nFeel free to submit issues or pull requests if you have suggestions for improvements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunjay-dev%2Furl-shortner-using-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunjay-dev%2Furl-shortner-using-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunjay-dev%2Furl-shortner-using-mongodb/lists"}