Skip to content

Comments

'modules' folder created - update architecture to hybrid microsservices/monolit#19

Merged
DrakoMichael merged 23 commits intomainfrom
development
Feb 5, 2026
Merged

'modules' folder created - update architecture to hybrid microsservices/monolit#19
DrakoMichael merged 23 commits intomainfrom
development

Conversation

@DrakoMichael
Copy link
Owner

This pull request introduces significant improvements and documentation updates related to Twitch OAuth2 integration, application bootstrapping, and logging. It includes new guides and example usage, enhanced release notes, and updates to environment variable configuration. Additionally, it removes an outdated API documentation file.

Twitch OAuth2 Integration Documentation and Configuration:

  • Added .env.example with detailed Twitch OAuth2 configuration variables and instructions for obtaining credentials and tokens.
  • Added TWITCH_OAUTH2_GUIDE.md, a comprehensive setup and troubleshooting guide for integrating Twitch OAuth2 and EventSub WebSocket, including both automatic and manual token flows, security tips, and next steps.
  • Added EXAMPLE_USAGE.md providing a practical, step-by-step example for configuring and running the application with Twitch OAuth2, including expected logs, troubleshooting, and usage of the Session ID.

Release Notes and Feature Improvements:

  • Added RELEASE_NOTES.md for v1.0.1, detailing new features such as enhanced bootstrapping (sequential module initialization, health checks, safe error handling), an advanced logging system (multi-level, file output, colored console), improved configuration loading, bug fixes, technical details, and planned future improvements.

Documentation Cleanup:

  • Removed the obsolete API documentation file docs/api/1.module_Main-Main.html to keep the documentation up-to-date.

DrakoMichael and others added 23 commits January 25, 2026 21:58
Refactored WebSocket bootstrap logic for improved initialization and error handling. Updated ws_functions to accept config and improved broadcast logic. Replaced index_test.js with a simpler bypass.js for testing, and updated package.json test script accordingly. Cleaned up spam generator code and improved settings loader export. Added release notes for v1.0.1.
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
…shake-twitch

[WIP] Implement handshake using OAuth2 with Twitch external websocket
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
[WIP] Add web page to edit config.json settings
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
Co-authored-by: DrakoMichael <22016138+DrakoMichael@users.noreply.github.com>
…auth0

[WIP] Add redirect URL for Auth0 in Express application
Deleted the entire contents of the docs/api directory, including HTML documentation, fonts, scripts, and styles. This cleans up generated documentation and related assets from the repository.
Moved Twitch-specific connection logic from connectionHUB.js to a new handleTwitchConnection.js module for better separation of concerns. Updated connectionHUB.js to delegate Twitch events to the new handler. Minor code style and class name improvements in index.js.
Extracted Twitch EventSub WebSocket event handling and protocol logic from connectionWS.js into a new connectionRules.js module for improved separation of concerns and maintainability. Updated connectionWS.js to delegate event handling to connectionRules. Minor cleanup in logManager.js and websocket_bootstrap.js.
@DrakoMichael DrakoMichael requested a review from Copilot February 5, 2026 09:15
@DrakoMichael DrakoMichael merged commit e8426ec into main Feb 5, 2026
3 of 4 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a significant architectural refactoring that transitions the codebase toward a hybrid microservices/monolith architecture by creating a 'modules' folder. The primary focus is on integrating Twitch OAuth2 EventSub WebSocket support and reorganizing the spam generator functionality into a standalone module.

Changes:

  • Added comprehensive Twitch OAuth2 integration with EventSub WebSocket support, including authentication, session management, keepalive handling, and event processing
  • Refactored spam generator from services to a new modular structure in modules/service_spamChatBot/
  • Enhanced WebSocket functionality with config injection and new broadcast method
  • Added extensive documentation including OAuth2 guide and usage examples
  • Updated configuration structure to support Twitch credentials and module-specific settings

Reviewed changes

Copilot reviewed 108 out of 146 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/tests/bypass.js New test bypass utility (contains unprofessional comment)
src/tests/index_test.js Removed placeholder test class
src/services/websocket/ws_functions.js Enhanced with config injection and broadcast method
src/services/websocket/websocket_starter.js Improved error handling
src/services/websocket/websocket_bootstrap.js Refactored to class-based singleton with logging
src/services/spamGenerator/liveChatSpam.js Deleted - moved to modules
src/services/settings/loadsettings.js Function declaration style change
src/services/settings/config_backup.js Added Twitch configuration section
src/services/externalConnections/twitch/* New Twitch OAuth2 integration files
src/services/dataBase/sqlite3_bootstrap.js Fixed import path case sensitivity
src/services/app/logManager.js Minor formatting corrections
src/services/app/debugBootstrap.js Added Twitch connection initialization (has bug)
src/services/app/bootstrapApp.js Updated to use new module structure
src/public/scripts.js WebSocket port changed to 8181
src/index.js Class renamed from 'main' to 'Main'
src/config.json Added Twitch config (misconfigured)
package.json Added dotenv dependency
modules/service_spamChatBot/* New modular spam chat bot implementation
docs/api/* Removed outdated API documentation
EXAMPLE_USAGE.md, .env.example New documentation files
.gitignore Fixed log paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// ensure bot is running (start if not)
let bot = spamChatBot.getInstance();
if (!bot) {
bot = await spamChatBot.start({ port: this.config.spam_port || 8081, pingInterval: this.config.pingInterval });
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port configuration fallback uses 'config.spam_port' which doesn't exist in the configuration. According to config.json, the property should be 'config.dev_config.spam_module_websocket_port'. This will result in the port being set to 8081 (default) instead of the configured value.

Copilot uses AI. Check for mistakes.
// EXEMPLO 6: Uso com função helper (compatibilidade total)
// ============================================================================

const { createSpamGenerator, stopLiveChatSpam } = require('./liveChatSpam');
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example file uses 'require' syntax (CommonJS) on line 147, but the rest of the codebase uses ES6 module imports. This inconsistency may cause errors if the file is executed, as the project uses "type": "module" in package.json.

Copilot uses AI. Check for mistakes.
}
} else {
// fallback to existing websocket bootstrap if present
const wsFunctions = websocket_bootstrap.getInstance();
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import for 'websocket_bootstrap' is missing. Line 68 references 'websocket_bootstrap.getInstance()' but there is no import statement for this module at the top of the file.

Copilot uses AI. Check for mistakes.
// fallback to existing websocket bootstrap if present
const wsFunctions = websocket_bootstrap.getInstance();
if (wsFunctions && typeof wsFunctions.sendNewChat === 'function') {
try { wsFunctions.sendNewChat(formattedMessage); } catch (_) {}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method 'sendNewChat' does not exist on wsFunctions. Based on the ws_functions.js changes in this PR, the method was renamed to 'broadcast'. This will cause a runtime error if this fallback code path is executed.

Copilot uses AI. Check for mistakes.
* Exemplo de uso do LiveChatSpam
*/

import LiveChatSpam from './liveChatSpam.js';
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 5 imports 'LiveChatSpam' but the module 'liveChatSpam.js' was deleted in this PR and replaced with 'spammer.js'. This example file will not work and appears to reference the old API.

Copilot uses AI. Check for mistakes.
"dev_config": {
"dev_websocket_port" : 8181,
"dev_express_port" : 3232,
"debbug": false,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'debbug' configuration option is misspelled. It should be 'debug' for consistency and clarity. This appears in the configuration file and throughout the codebase.

Copilot uses AI. Check for mistakes.
"connected_chat_notify": true,
"enable_spam": true,
"connected_chat_notify": true,
"spam_module_websocket_port": 8282,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property 'spam_module_websocket_port' is added to the configuration but is not referenced anywhere in the Spammer or spamChatBot code. The spammer.js file uses 'config.spam_port' on line 21, which doesn't exist in the configuration. This inconsistency will cause the spam feature to malfunction.

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +18
"twitch": {
"client_id": "",
"client_secret": "",
"access_token": "",
"refresh_token": "",
"enable_twitch_connection": true
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'enable_twitch_connection' is set to 'true' in config.json but the Twitch OAuth2 credentials (client_id, client_secret, access_token, refresh_token) are empty strings. This will cause the Twitch connection to fail on startup with the error "Missing client_id or access_token in configuration". For a default configuration file, this should either be set to false or include placeholder comments indicating required values.

Copilot uses AI. Check for mistakes.
*/
static async init(config) {
console.log("Debug Bootstrap initialized.");
await websocket_bootstrap.ignite_test();
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The websocket_bootstrap.ignite_test() method is called but it was removed in the websocket_bootstrap.js changes in this PR. This will cause a runtime error when debug mode is enabled.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants