How eventregistry/event-registry-node-js works
Project type and purpose
• This is a client‐side TypeScript/Node.js library (“eventregistry”) that wraps the Event Registry REST API.
• Its sole responsibility is to let users build queries (articles, events, trends, etc.), submit them to the external Event Registry service, and parse the JSON response into typed objects.
File structure
• Top‐level files: configuration (.eslintrc.js, tsconfig.json), metadata (package.json, README.md), tests, and examples.
• src/ directory: all core modules—each file corresponds to one piece of functionality (analytics.ts, query.ts, queryArticles.ts, etc.).
• tests/ directory: unit tests validating each query and helper.
• examples/ directory: usage scenarios demonstrating how clients import and call the library.
README for additional insights
• The README describes how to instantiate the core EventRegistry class, create Query and Request objects, and invoke async calls.
• It lists the main use cases (articles, events, trends, social shares, duplicates, etc.)—each maps to a module under src/.
a. Main components
• Client Application (user code or examples)
• EventRegistry Core (src/index.ts + src/eventRegistry.ts)
• Query Layer (classes under src/query*.ts and src/queryEvent.ts, src/queryArticles.ts, etc.)
• Request/Result Layer (classes under src/request* or “returnInfo.ts”)
• Data Models (src/types.ts, src/data.ts)
• Utility Modules (src/logger.ts, src/base.ts, src/eventRegistry.ts)
• HTTP Transport (the underlying HTTP client invoked by EventRegistry.execQuery)
• External System (Event Registry REST API)
b. Relationships and interactions
1. Client → EventRegistry constructor (inject API key, config)
2. Client → Instantiate Query object (e.g., new QueryArticles(er, params))
3. Client → Optionally attach a RequestInfo object (e.g., new RequestArticlesInfo)
4. Client → Call er.execQuery(query)
5. EventRegistry → Translates query into HTTP request via base.ts/http client
6. HTTP client → Sends request over TLS → Event Registry API
7. Event Registry API → Returns JSON payload
8. EventRegistry → Parses JSON into typed Data Models (types.ts)
9. EventRegistry → Returns Promise resolving to typed response to Client
c. Architectural patterns and design principles
• Modularization: one file per feature (SRP)
• Builder Pattern: Query and Request objects chain configuration calls
• Dependency Injection: Client injects API key and settings into EventRegistry
• Promise/async-await for asynchronous calls
• Type safety: TypeScript interfaces for requests/responses
d. Relevant technologies and libraries
• TypeScript (tsconfig.json)
• Node.js (package.json)
• Jasmine for testing (test/spec/*.spec.ts)
• ESLint/TSlint for linting
• npm scripts for build/test