{"id":28387787,"url":"https://github.com/whispernet/ticket-common","last_synced_at":"2026-07-27T18:31:07.746Z","repository":{"id":292469635,"uuid":"979958165","full_name":"WhisperNet/ticket-common","owner":"WhisperNet","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-25T17:26:13.000Z","size":91,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T07:07:45.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/WhisperNet.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-08T10:39:08.000Z","updated_at":"2025-05-25T17:26:17.000Z","dependencies_parsed_at":"2025-05-10T07:28:14.078Z","dependency_job_id":"2c9039e7-61d7-4876-a41e-0e6a3071099a","html_url":"https://github.com/WhisperNet/ticket-common","commit_stats":null,"previous_names":["whispernet/ticket-common"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WhisperNet/ticket-common","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhisperNet%2Fticket-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhisperNet%2Fticket-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhisperNet%2Fticket-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhisperNet%2Fticket-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WhisperNet","download_url":"https://codeload.github.com/WhisperNet/ticket-common/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhisperNet%2Fticket-common/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35961441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-27T02:00:06.776Z","response_time":101,"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":[],"created_at":"2025-05-30T19:12:02.010Z","updated_at":"2026-07-27T18:31:07.725Z","avatar_url":"https://github.com/WhisperNet.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tckt-common Module Documentation\n\nThe `tckt-common` module is a shared library that provides essential utilities and functionality for all microservices in the `ticketing-microservice-app` project. This documentation explains how to use the module effectively.\n\n---\n\n## Installation\n\nTo include the `tckt-common` module in your microservice, install it via npm:\n\n```bash\nnpm install @whispernet-sust/ticket-common\n```\n\n---\n\n## Features Overview\n\n### 1. Error Handling\n\n- **Purpose**: Standardized error classes and middleware for consistent error responses.\n- **Usage**:\n\n  ```typescript\n  import { CustomError, errorHandler } from '@whispernet-sust/ticket-common';\n\n  // Example: Custom Error\n  class NotFoundError extends CustomError {\n    statusCode = 404;\n\n    constructor() {\n      super('Resource not found');\n    }\n\n    serializeErrors() {\n      return [{ message: 'Resource not found' }];\n    }\n  }\n\n  // Middleware usage\n  app.use(errorHandler);\n  ```\n\n### 2. Event Management\n\n- **Purpose**: Simplifies event publishing and listening using a common event bus.\n- **Usage**:\n\n  ```typescript\n  import {\n    BasePublisher,\n    BaseListener,\n    Subjects,\n  } from '@whispernet-sust/ticket-common';\n\n  // Example: Event Publisher\n  class TicketCreatedPublisher extends BasePublisher\u003cTicketCreatedEvent\u003e {\n    subject: Subjects.TicketCreated = Subjects.TicketCreated;\n  }\n\n  // Example: Event Listener\n  class TicketCreatedListener extends BaseListener\u003cTicketCreatedEvent\u003e {\n    subject: Subjects.TicketCreated = Subjects.TicketCreated;\n    queueGroupName = 'service-queue-group';\n\n    onMessage(data: TicketCreatedEvent['data'], msg: Message) {\n      console.log('Event data:', data);\n      msg.ack();\n    }\n  }\n  ```\n\n### 3. Custom Middleware\n\n- **Purpose**: Predefined middleware for common tasks like authentication and request validation.\n- **Usage**:\n\n  ```typescript\n  import { validateRequest, requireAuth } from '@whispernet-sust/ticket-common';\n\n  // Example: Validation Middleware\n  app.post('/api/tickets', validateRequest, (req, res) =\u003e {\n    res.send({});\n  });\n\n  // Example: Authentication Middleware\n  app.get('/api/tickets', requireAuth, (req, res) =\u003e {\n    res.send({});\n  });\n  ```\n\n### 4. Common Types\n\n- **Purpose**: Shared TypeScript types and interfaces for consistent data structures.\n- **Usage**:\n\n  ```typescript\n  import { TicketCreatedEvent } from '@whispernet-sust/ticket-common';\n\n  const event: TicketCreatedEvent = {\n    id: '123',\n    title: 'Concert',\n    price: 100,\n  };\n  ```\n\n---\n\n## Best Practices\n\n1. **Centralized Updates**: Always use the latest version of `tckt-common` to ensure consistency across microservices.\n2. **Custom Extensions**: Extend the provided classes or interfaces to suit your specific microservice needs.\n3. **Error Handling**: Use the provided error classes and middleware to maintain uniform error responses.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhispernet%2Fticket-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhispernet%2Fticket-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhispernet%2Fticket-common/lists"}