feat: introduce plugin system with routes/hooks, metadata, tests, and docs#113
Merged
Conversation
- Added PluginManager to manage plugins, including loading local and package plugins. - Introduced API for plugins to register routes, audio sources, and lyrics sources. - Implemented stream interceptors and before-play hooks for enhanced audio processing. - Created example and audio cache plugins to demonstrate plugin capabilities. - Updated source and lyrics managers to support dynamic plugin registration. - Enhanced documentation for plugin system and usage examples.
Signed-off-by: Tapao <40026698+Tapao-NonSen@users.noreply.github.com>
Signed-off-by: Tapao <40026698+Tapao-NonSen@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a plugin system for NodeLink, enabling developers to extend functionality without modifying core files. Plugins can register HTTP routes, audio/lyrics sources, stream interceptors, and playback hooks.
Key Changes:
- New
PluginManagerclass to discover, load, and manage plugins from local files and NPM packages - Integration of plugin routes into the request handler with proper priority ordering
- Two example plugins:
audio-cache-plugin(disk caching with TTL/size limits) andprebuffer-plugin(stream buffering)
Reviewed Changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/plugins/pluginManager.js | Core plugin system: loads plugins, manages routes, interceptors, and before-play hooks |
| src/plugins/src/audio-cache-plugin.js | Caches audio streams to disk with configurable TTL and size limits |
| src/plugins/src/prebuffer-plugin.js | Buffers initial stream bytes before playback for smoother starts |
| src/plugins/src/example-plugin.js | Minimal example demonstrating plugin API usage |
| src/api/index.js | Integrates plugin routes into request handler (static then dynamic) |
| src/api/info.js | Exposes loaded plugin metadata in /v4/info endpoint |
| src/api/routes.js | New endpoint listing all builtin and plugin routes |
| src/api/plugins.js | New endpoint listing loaded plugins and their routes |
| src/managers/sourceManager.js | Refactored to support plugin-registered sources; integrates stream interceptor pipeline |
| src/managers/lyricsManager.js | Added addLyricsSource method for plugin-registered lyrics providers |
| src/playback/player.js | Invokes plugin beforePlay hooks before stream initialization |
| src/worker.js | Initializes PluginManager in worker process |
| src/index.js | Initializes PluginManager in main server process |
| test/plugins.integration.test.js | Integration tests for plugin routes and metadata |
| docs/plugins.md | Comprehensive plugin API documentation with examples |
| config.default.js | Default configuration for audioCache and prebuffer plugins |
Comments suppressed due to low confidence (1)
docs/plugins.md:1
- The documentation states plugins should be under
src/plugins/*.js, but the actual code loads fromsrc/plugins/src/*.js(see pluginManager.js line 92). Update documentation to match implementation:src/plugins/src/*.js.
Plugin System
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
docs/plugins.md:1
- The documentation states plugins should be in
src/plugins/*.js, but the actual implementation loads fromsrc/plugins/src/*.jsas seen in pluginManager.js line 92. This should be corrected tosrc/plugins/src/*.jsto match the implementation.
Plugin System
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1Lucas1apk
requested changes
Nov 5, 2025
…o cache and prebuffer plugins
1Lucas1apk
requested changes
Nov 5, 2025
…ty and completeness
1Lucas1apk
added a commit
that referenced
this pull request
Nov 6, 2025
…nd docs #113 feat: introduce plugin system with routes/hooks, metadata, tests, and docs reason: The system is quite unstable, causing problems with NodeLink's functionality. I accepted without reliable testing beforehand; I need you to run tests before adding the system. It was my mistake!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Added a plugin system to NodeLink. It allows loading and registering plugins (local or NPM) that can define custom HTTP routes, audio sources, lyrics providers, stream interceptors, and pre-play hooks.
Refactored core components (
SourcesManager,LyricsManager) to use registration methods that support plugin-based sources. Added new API endpoints for plugin and route information.Also included new configuration fields for plugins and improved HTTP route resolution to include plugin routes before internal ones.
Why
To make NodeLink modular and extendable without changing internal files.
Developers can now add custom behavior, caching, or third-party integrations through plugins, improving maintainability and flexibility.
Checkmarks
Additional information
This prepares NodeLink for broader ecosystem use — plugins can now add new sources or logic dynamically, making future extensions and experimentation simpler.