{"id":25171479,"url":"https://github.com/basemax/mylinkshortenergraphqlts","last_synced_at":"2026-05-03T17:34:23.754Z","repository":{"id":176982450,"uuid":"657122858","full_name":"BaseMax/MyLinkShortenerGraphQLTS","owner":"BaseMax","description":"This project is a back-end GraphQL-based API, implemented in TypeScript, for a link shortener site. The API allows users to shorten long URLs and manage their shortened links. It provides features such as instant link shortening, link expiration, monitoring and tracking of visits and requests, link editing, and account registration/login.","archived":false,"fork":false,"pushed_at":"2026-04-10T04:37:21.000Z","size":259,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-10T06:30:26.108Z","etag":null,"topics":["graphql","graphql-typescript","javascript","nodejs","ts","typescript","typescript-graphql"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-22T11:17:30.000Z","updated_at":"2026-04-10T04:37:21.000Z","dependencies_parsed_at":"2024-11-26T11:40:46.672Z","dependency_job_id":null,"html_url":"https://github.com/BaseMax/MyLinkShortenerGraphQLTS","commit_stats":null,"previous_names":["basemax/mylinkshortenergraphqlts"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BaseMax/MyLinkShortenerGraphQLTS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMyLinkShortenerGraphQLTS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMyLinkShortenerGraphQLTS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMyLinkShortenerGraphQLTS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMyLinkShortenerGraphQLTS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/MyLinkShortenerGraphQLTS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FMyLinkShortenerGraphQLTS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32578787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"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":["graphql","graphql-typescript","javascript","nodejs","ts","typescript","typescript-graphql"],"created_at":"2025-02-09T09:20:36.901Z","updated_at":"2026-05-03T17:34:23.737Z","avatar_url":"https://github.com/BaseMax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Link Shortener - Back-end GraphQL API (TypeScript)\n\nThis project is a back-end GraphQL-based API, implemented in TypeScript, for a link shortener site. The API allows users to shorten long URLs and manage their shortened links. It provides features such as instant link shortening, link expiration, monitoring and tracking of visits and requests, link editing, and account registration/login.\n\n## Features\n\n- **Instant Link Shortening:** Users can shorten long URLs quickly within 3 seconds.\n- **Link Expiration:** Users can specify the desired lifespan of their shortened links, including options such as one day, one week, one month, six months, or indefinite duration. They can also set a specific date/time for link expiration, considering the UTC time zone.\n- **Account Registration/Login:** Users can create an account or log in to their existing account. This allows them to access additional features and view a list of their created links.\n- **Forgot Password:** Users can request a password reset if they forget their password. The \"Forgot Password\" page allows them to initiate the password recovery process.\n- **Management Panel:** Authenticated users have access to a management panel where they can view statistics and charts related to their links. They can also see a list of all their created links, with options to edit or delete each link. Deleting a link prompts a modal confirmation dialog, while editing a link opens a modal with options to update the expiration date/time or change the destination URL.\n\n## Technologies Used\n\nThe back-end API is built using the following technologies:\n\nNode.js: A JavaScript runtime environment for executing server-side code.\nTypeScript: A statically-typed superset of JavaScript that compiles to plain JavaScript code.\nGraphQL: A query language for APIs that enables efficient data retrieval and manipulation.\nExpress: A web application framework for Node.js that simplifies API development.\nMongoDB: A NoSQL database used to store user accounts, links, and related data.\nJWT: JSON Web Tokens are used for authentication and authorization purposes.\nApollo Server: A GraphQL server implementation that integrates with Express and provides essential features for handling GraphQL requests and responses.\n\n## Installation\n\nTo set up the project locally, follow these steps:\n\n- Clone the repository: `git clone https://github.com/BaseMax/MyLinkShortenerGraphQLTS`\n- Install the dependencies: `npm install`\n- Set up the environment variables (database connection details, JWT secret, etc.) by creating a `.env` file.\n- Start the development server: `npm run dev`\n- The API will be available at `http://localhost:3000`.\n- Feel free to customize the project according to your specific requirements and design preferences.\n\n## Models\n\n```typescript\n// User model\ninterface User {\n  id: string;\n  email: string;\n  password: string;\n  name: string;\n  avatar: string;\n  createdAt: Date;\n}\n\n// Link model\ninterface Link {\n  id: string;\n  userId: string;\n  alias: string;\n  destinationUrl: string;\n  shortUrl: string;\n  expirationDate: Date | null;\n  createdAt: Date;\n}\n\n// Visit model\ninterface Visit {\n  id: string;\n  linkId: string;\n  referrer: string;\n  userAgent: string;\n  ipAddress: string;\n  timestamp: Date;\n}\n\n// Search query input\ninterface SearchInput {\n  query: string;\n}\n\n// GetPopularLinks query input\ninterface GetPopularLinksInput {\n  limit: number;\n}\n\n// GetTopReferrers query input\ninterface GetTopReferrersInput {\n  linkId: string;\n  limit: number;\n}\n\n// UpdateLinkAlias mutation input\ninterface UpdateLinkAliasInput {\n  id: string;\n  newAlias: string;\n}\n\n// ToggleLinkActivation mutation input\ninterface ToggleLinkActivationInput {\n  id: string;\n  active: boolean;\n}\n\n// UpdateUserProfile mutation input\ninterface UpdateUserProfileInput {\n  name: string;\n  avatar: string;\n}\n\n// GenerateQRCode mutation input\ninterface GenerateQRCodeInput {\n  id: string;\n}\n\n// GetLinkByShortenedUrl query input\ninterface GetLinkByShortenedUrlInput {\n  shortUrl: string;\n}\n\n// GetVisitsByLink query input\ninterface GetVisitsByLinkInput {\n  id: string;\n}\n\n// UpdateLinkDestinationUrl mutation input\ninterface UpdateLinkDestinationUrlInput {\n  id: string;\n  newUrl: string;\n}\n\n// CreateCustomShortenedLink mutation input\ninterface CreateCustomShortenedLinkInput {\n  url: string;\n  alias: string;\n  expirationDate?: Date;\n}\n\n// EditLinkExpiration mutation input\ninterface EditLinkExpirationInput {\n  id: string;\n  expirationDate: Date;\n}\n\n// TrackLinkVisit mutation input\ninterface TrackLinkVisitInput {\n  id: string;\n  referrer: string;\n  userAgent: string;\n  ipAddress: string;\n}\n\n// DeleteUserAccount mutation input\ninterface DeleteUserAccountInput {\n  // No additional input required\n}\n```\n\n## Queries\n\n**Get All Links**\n\n- Description: Retrieve a list of all shortened links created by the authenticated user.\n- Arguments: None\n- Response: List of shortened links\n\n**Get Link by ID**\n\n- Description: Retrieve a specific shortened link by its ID.\n- Arguments: id (Link ID)\n- Response: Shortened link details\n\n**Get Link Stats**\n\n- Description: Retrieve statistics and visit data for a specific shortened link.\n- Arguments: id (Link ID)\n- Response: Link statistics and visit data\n\n**Get Link by Shortened URL**\n\n- Description: Retrieve a specific shortened link by its shortened URL.\n- Arguments: shortUrl (Shortened URL)\n- Response: Shortened link details\n\n**Get User Links**\n\n- Description: Retrieve a list of shortened links created by the authenticated user.\n- Arguments: None\n- Response: List of shortened links created by the user\n\n**Get Link Visits**\n\n- Description: Retrieve the visit history for a specific shortened link.\n- Arguments: id (Link ID)\n-Response: List of visits and their details for the link\n\n**Search Links**\n\n- Description: Search for shortened links based on specific criteria, such as keywords in the destination URL or link alias.\n- Arguments: query (Search query)\n- Response: List of matching shortened links\n\n**Get Popular Links**\n\n- Description: Retrieve a list of popular or most visited shortened links.\n- Arguments: limit (Number of links to retrieve)\n- Response: List of popular shortened links\n\n**Get Top Referrers**\n\n- Description: Retrieve the top referrers for a specific shortened link, indicating the sources from which the link was accessed.\n- Arguments: id (Link ID), limit (Number of top referrers to retrieve)\n- Response: List of top referrers for the link\n\n## Mutations\n\n**Register User**\n\n- Description: Create a new user account.\n- Arguments: email, password\n- Response: User details and authentication token\n\n**Login**\n\n- Description: Log in to an existing user account.\n- Arguments: email, password\n- Response: User details and authentication token\n\n**Forgot Password**\n\n- Description: Initiate the password recovery process by sending a password reset email to the user.\n- Arguments: email\n- Response: Success message\n\n**Reset Password**\n\n- Description: Reset the user's password with a new password after following the password reset link.\n- Arguments: resetToken, newPassword\n- Response: Success message\n\n**Shorten Link**\n\n- Description: Create a shortened link.\n- Arguments: url, expirationDate (optional)\n- Response: Shortened link details\n\n**Update Link**\n\n- Description: Update the expiration date of a shortened link.\n- Arguments: id (Link ID), expirationDate\n- Response: Updated shortened link details\n\n**Delete Link**\n\n- Description: Delete a shortened link.\n- Arguments: id (Link ID)\n- Response: Success message\n\n**Update Link Destination URL**\n\n- Description: Update the destination URL of a shortened link.\n- Arguments: id (Link ID), newUrl (New destination URL)\n- Response: Updated shortened link details\n\n**Create Custom Shortened Link**\n\n- Description: Create a shortened link with a custom alias.\n- Arguments: url, alias (Custom alias), expirationDate (optional)\n- Response: Shortened link details\n\n**Edit Link Expiration**\n\n- Description: Edit the expiration settings of a shortened link.\n- Arguments: id (Link ID), expirationDate (New expiration date)\n- Response: Updated shortened link details\n\n**Track Link Visit**\n\n- Description: Track a visit to a shortened link.\n- Arguments: id (Link ID), referrer (Referring URL), userAgent (User agent string), ipAddress (IP address)\n- Response: Visit details\n\n**Delete User Account**\n\n- Description: Delete the authenticated user's account.\n- Arguments: None\n- Response: Success message\n\n**Update Link Alias**\n\n- Description: Update the alias of a shortened link.\n- Arguments: id (Link ID), newAlias (New alias)\n- Response: Updated shortened link details\n\n**Toggle Link Activation**\n\n- Description: Activate or deactivate a shortened link to make it accessible or temporarily unavailable.\n- Arguments: id (Link ID), active (Boolean indicating activation status)\n- Response: Updated shortened link details\n\n**Update User Profile**\n\n- Description: Update the user's profile information, such as name, avatar, or any other relevant details.\n- Arguments: name (User's name), avatar (URL of the user's avatar)\n- Response: Updated user profile details\n\n**Generate QR Code**\n\n- Description: Generate a QR code for a specific shortened link, allowing users to easily scan and access the link using their mobile devices.\n- Arguments: id (Link ID)\n- Response: Generated QR code image data or URL\n\n**Get User Profile**\n\n- Description: Retrieve the profile information of the authenticated user.\n- Arguments: None\n- Response: User profile details\n\nThese queries and mutations should cover the basic functionality required for a link shortener API. Feel free to modify or expand upon them according to your specific project requirements.\n\n## GraphQL Examples\n\n**Get All Links**\n\n```graphql\nquery {\n  getAllLinks {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Get Link by ID**\n\n```graphql\nquery {\n  getLink(id: \"your-link-id\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Get Link Stats**\n\n```graphql\nquery {\n  getLinkStats(id: \"your-link-id\") {\n    link {\n      id\n      alias\n      destinationUrl\n      shortUrl\n      expirationDate\n      createdAt\n    }\n    visits {\n      id\n      referrer\n      userAgent\n      ipAddress\n      timestamp\n    }\n    totalVisits\n  }\n}\n```\n\n**Get Link by Shortened URL**\n\n```graphql\nquery {\n  getLinkByShortenedUrl(shortUrl: \"your-shortened-url\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Get User Links**\n\n```graphql\nquery {\n  getUserLinks {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Get Link Visits**\n\n```graphql\nquery {\n  getLinkVisits(id: \"your-link-id\") {\n    id\n    referrer\n    userAgent\n    ipAddress\n    timestamp\n  }\n}\n```\n\n**Search Links**\n```graphql\nquery {\n  searchLinks(query: \"your-search-query\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Get Popular Links**\n\n```graphql\nquery {\n  getPopularLinks(limit: 10) {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Get Top Referrers**\n\n```graphql\nquery {\n  getTopReferrers(id: \"your-link-id\", limit: 5) {\n    referrer\n    visitCount\n  }\n}\n```\n\n**Register User**\n\n```graphql\nmutation {\n  registerUser(email: \"example@email.com\", password: \"password\") {\n    id\n    email\n    token\n  }\n}\n```\n\n**Login**\n\n```graphql\nmutation {\n  login(email: \"example@email.com\", password: \"password\") {\n    id\n    email\n    token\n  }\n}\n```\n\n**Forgot Password**\n\n```graphql\nmutation {\n  forgotPassword(email: \"example@email.com\") {\n    message\n  }\n}\n```\n\n**Reset Password**\n\n```graphql\nmutation {\n  resetPassword(resetToken: \"your-reset-token\", newPassword: \"newpassword\") {\n    message\n  }\n}\n```\n\n**Shorten Link**\n\n```graphql\nmutation {\n  shortenLink(url: \"https://example.com\", expirationDate: \"2023-12-31T23:59:59Z\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Update Link**\n\n```graphql\nmutation {\n  updateLink(id: \"your-link-id\", expirationDate: \"2023-12-31T23:59:59Z\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Delete Link**\n\n```graphql\nmutation {\n  deleteLink(id: \"your-link-id\") {\n    message\n  }\n}\n```\n\n**Update Link Destination URL**\n\n```graphql\nmutation {\n  updateLinkDestinationUrl(id: \"your-link-id\", newUrl: \"https://newexample.com\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Create Custom Shortened Link**\n\n```graphql\nmutation {\n  createCustomShortenedLink(url: \"https://example.com\", alias: \"custom-alias\", expirationDate: \"2023-12-31T23:59:59Z\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Edit Link Expiration**\n\n```graphql\nmutation {\n  editLinkExpiration(id: \"your-link-id\", expirationDate: \"2023-12-31T23:59:59Z\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Track Link Visit**\n```graphql\nmutation {\n  trackLinkVisit(id: \"your-link-id\", referrer: \"https://referrer.com\", userAgent: \"Mozilla/5.0\", ipAddress: \"127.0.0.1\") {\n    id\n    referrer\n    userAgent\n    ipAddress\n    timestamp\n  }\n}\n```\n\n**Delete User Account**\n\n```graphql\nmutation {\n  deleteUserAccount {\n    message\n  }\n}\n```\n\n**Update Link Alias**\n\n```graphql\nmutation {\n  updateLinkAlias(id: \"your-link-id\", newAlias: \"new-alias\") {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n  }\n}\n```\n\n**Toggle Link Activation**\n\n```graphql\nmutation {\n  toggleLinkActivation(id: \"your-link-id\", active: true) {\n    id\n    alias\n    destinationUrl\n    shortUrl\n    expirationDate\n    createdAt\n    active\n  }\n}\n```\n\n**Update User Profile**\n\n```graphql\nmutation {\n  updateUserProfile(name: \"John Doe\", avatar: \"https://example.com/avatar.png\") {\n    id\n    email\n    name\n    avatar\n  }\n}\n```\n\n**Generate QR Code**\n\n```graphql\nmutation {\n  generateQRCode(id: \"your-link-id\") {\n    qrCodeImageURL\n  }\n}\n```\n\n**Get User Profile**\n\n```graphql\nquery {\n  getUserProfile {\n    id\n    email\n    name\n    avatar\n  }\n}\n```\n\nPlease note that you may need to adjust the input values or fields based on your application's requirements.\n\nCopyright 2023, Max Base\n\n-------------\n\nاولین پروژه: سیستم و سایت کوتاه کننده لینک\n\nچندین صفحه مختلف میتونه داشته باشه اینکار\nزبان پروژه: انگلیسی\nسبک: سلیقه طراح و بین المللی\n\nصفحه ها:\nصفحه اصلی (امکان ساخت لینک کوتاه حتی برای مهمان وجود داره) در هنگام ساخت لینک از کاربر میشه پرسید  لینک تا چند وقت میخواهید زنده باشه؟ یک روز؟ یک هفته؟ یک ماه؟ شش ماه؟ بی نهایت؟ یا یک تاریخ/ساعت دقیق مشخص که مثلا در 1 شهریور ساعت 9 صبح باطل بشه البته باید شفاف کنیم ساعت به چه تایم زونی هست بهتره به تایم زون UTC باشه اگه نمیدونید utc یا gmt چیه جستجو کنید.\nصفحه ورود/ثبت نام (ایمیل و رمز) + بهمراه حالت فوکوس فیلد ها و حالت هایی که مشخص هست مشخصات غلط بوده یا درست بوده و بزودی به پنل هدایت میشی\nصفحه فراموشی رمز\nصفحه پنل مدیریت با امکان مشاهده نمودار و دیدن لییست کل لینک های کاربر. این رو میشه صفحه مجزا هم زد بستگی داره ولی بنظرم اونقدر چارت و نمودار نداریم که کل صفحه رو پر کنیم. میتونیم بالا رو نمودار پر کنیم و زیر اش لیست لینک ها و برای هر لینک بشه روی ویرایش یا حذف کرد. و وقتی روی حذف میزنیم مودال پرسیدن مطمئن هستید بیاد و روی ویرایش زدند مودال صفحه ویرایش بیاد که بشه تاریخ منقضی شدن رو هم تعیین کرد و همینطور اینکه یک روز/یک هفته/یک ماه/6 ماه/بی نهایت رو تغییر بدیم\n\nمزایا و خاصیت ها:\nساخت لینک کوتاه فوری در 3 ثانیه\nامکان مانیتور و ترک کردن تعداد بازدید و درخواست روی لینک های کوتاه\nامکان باطل کردن لینک های کوتاه در هر زمان در پنل\nامکان تغییر دادن یا ارجاع یک لینک کوتاه به یک لینک جدید در هر زمان (امکان ویرایش لینک)\n\nچرا نیاز به ساخت حساب کاربری یا ورود باشه؟\nبخاطر اینکه وقتی حساب کاربری داشته باشی و لینک بسازی همه لینک هایی که میسازی داخل پنل برات لیست و نشون داده میشه\nو میتونی ببینی چند تا لینک کلا داره و هر کدوم چقدر بازدید خوردند\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fmylinkshortenergraphqlts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fmylinkshortenergraphqlts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fmylinkshortenergraphqlts/lists"}