{"id":18248776,"url":"https://github.com/saif-gitreps/url-shortener-backend","last_synced_at":"2026-04-10T03:57:04.560Z","repository":{"id":227279720,"uuid":"770942020","full_name":"saif-gitreps/URL-Shortener-Backend","owner":"saif-gitreps","description":"A Node.js application where users can create ShortIds for long URLs without authentication. Authenticated users can keep track of their URLs, create custom ShortIds, delete them, and monitor URL analytics.","archived":false,"fork":false,"pushed_at":"2025-01-03T15:27:44.000Z","size":3687,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T15:49:29.671Z","etag":null,"topics":["bcryptjs","csrf-protection","express-js","helmet","jwt-authentication","middelware","mongodb","nodejs","postman","redis"],"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/saif-gitreps.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":"2024-03-12T12:25:52.000Z","updated_at":"2025-01-04T07:29:39.000Z","dependencies_parsed_at":"2024-09-14T08:10:17.763Z","dependency_job_id":"ea8f41bc-e979-4b95-aaeb-b579bbec1ffb","html_url":"https://github.com/saif-gitreps/URL-Shortener-Backend","commit_stats":null,"previous_names":["saif-gitreps/url-shortener"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saif-gitreps%2FURL-Shortener-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saif-gitreps%2FURL-Shortener-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saif-gitreps%2FURL-Shortener-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saif-gitreps%2FURL-Shortener-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saif-gitreps","download_url":"https://codeload.github.com/saif-gitreps/URL-Shortener-Backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247918928,"owners_count":21018044,"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":["bcryptjs","csrf-protection","express-js","helmet","jwt-authentication","middelware","mongodb","nodejs","postman","redis"],"created_at":"2024-11-05T09:38:15.735Z","updated_at":"2025-12-30T19:04:21.562Z","avatar_url":"https://github.com/saif-gitreps.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API Server for a URL Shortener Application\n\nA Node.js application where users can create ShortIds for long URLs without authentication. Authenticated users can keep track of their URLs, create custom ShortIds, delete them, and monitor URL analytics.\n\n## Features\n\n**API Endpoints**\n\n-  **URL:**\n   -  Create (Custom and Random), delete, and get analytics.\n-  **Auth:**\n   -  Sign up, log in, refresh access token, get CSRF token, get current user, log out, and update user details.\n\n🔐 **Authentication and Security**\n\n-  Stateless JWT authentication with refresh and access tokens using secure HTTP-only cookies.\n-  CSRF protection with the **Double-submit cookie** pattern.\n-  Role-based authorization.\n\n💻 **Tech Stack and Features**\n\n-  Password **encryption** before storing in the database, with **decryption** for verification.\n-  Using the **MVC pattern** and separating authentication for microservice-like separation of concerns.\n-  **Rate limiters** for authentication routes based on different roles.\n-  Route protection from unauthenticated requests.\n-  **CSRF protection** for all POST requests.\n-  User input, URL, and ShortId validation using **express-validator** and custom sanitization.\n-  Custom logger for monitoring requests in the development terminal.\n-  **Caching** of actively used ShortIds using **Redis** to reduce database load.\n-  Schema built with **Mongoose**, along with **aggregation pipeline** queries.\n-  **Scheduled cron job** to clean up visit details data for an expired URL.\n-  Users can monitor analytics for each click in detail for every ShortId.\n\n🎁 **Additional Features**\n\n-  🔄 Highly customizable and extendable, with more features planned for future updates.\n\n\u003c!---\nyour comment goes here\nand here\n\n## Prerequisites\n\nBefore setting up the server, ensure you have the following prerequisites:\n\n- Node.js and npm installed on your system.\n- MongoDB installed and running.\n- An internet browser for testing API endpoints (e.g., Postman).\n\n## Installation\n\nTo install the backend server, follow these steps:\n\n1. Clone the repository:\n\n```\ngit clone https://github.com/yourusername/video-streaming-backend.git .\n```\n\n2. Install dependencies:\n\n```\nnpm install\n```\n\n4. Configuration\nCreate a .env file in the root directory of the project and add the following variables:\n\n```\nPORT = 8000 or 3000\nMONGO_URI = mongodb://localhost:27017 or your URI\nFRONTEND_URL= \u003ccongifure your sites\u003e\nACCESS_TOKEN_SECRET= \u003cadd an access token, example: SUPERSECRET1234\u003e\nCSRF_TOKEN_SECRET=\u003cYour any secret\u003e\nREFRESH_TOKEN_SECRET= \u003cadd a refresh token of your own\u003e\n\n```\n\n## Usage\nTo start the server, run the following command:\n\n```\nnpm start\n```\n\n## RESTful APIs\nThe backend server follows RESTful API principles, allowing the front-end to make proper calls to the server. The API Endpoint can be accessed in the routes folder.\n\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaif-gitreps%2Furl-shortener-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaif-gitreps%2Furl-shortener-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaif-gitreps%2Furl-shortener-backend/lists"}