Registry / web-framework / electrode-server

electrode-server

JSON →
library3.3.0jsnpmunverified

Electrode Server is a configurable web server built atop Hapi.js and Node.js, designed to standardize the setup and serving of web applications. The current stable version is 3.3.0. It provides a baseline Hapi server instance that can be extended primarily through configuration, reducing the need for boilerplate code and duplicated server setup logic across projects. While offering default settings that allow for a quick startup, its strength lies in its extensive configuration options, managed optionally by tools like `electrode-confippet`, enabling fine-grained control over Hapi server and connection settings, including port, host, compression, and plugin registration. It simplifies the integration of Hapi plugins by providing a structured way to register them. Electrode Server aims to abstract away common server setup concerns, allowing developers to focus on application-specific features and logic. The package does not explicitly detail its release cadence, but minor versions are released as needed.

npm install electrode-server
INSTALL
IMPORT
SIG · ELECTRODE-SERVER
E
electrode-server
web-frameworkjavascriptv3.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ElectrodeServerFunction
const startServer = require('electrode-server');
import startServer from 'electrode-server';
The primary API is a function exported directly by the module. This package is CommonJS-only.
DirectServerStart
require('electrode-server')();
import 'electrode-server';
The module can be invoked directly upon require to start a server with default settings. Using ESM import statements will fail.
ConfiguredServerStart
const config = { connection: { port: 9000 } }; require('electrode-server')(config);
import electrodeServer from 'electrode-server'; electrodeServer({ connection: { port: 9000 } });
Configuration is passed as an argument to the function returned by `require('electrode-server')`. ESM named imports are not supported.

Demonstrates starting an Electrode server on a custom port with a basic Hapi route registered via the plugin configuration.

const config = { connection: { host: process.env.HOST ?? 'localhost', port: parseInt(process.env.PORT ?? '3000', 10), routes: { cors: true } }, plugins: { 'my-routes-plugin': { register: (server, options) => { server.route({ method: 'GET', path: '/', handler: (request, h) => { return 'Hello, Electrode Server!'; } }); }, options: {} } } }; require('electrode-server')(config); console.log(`Electrode Server running on http://${config.connection.host}:${config.connection.port}`);
Debug
Known issues
breakingThe minimum Node.js version required has been updated from `>= 4.2.2` to `v8.x.x+` (as stated in the README). Running on older Node.js environments will lead to errors.
fix
Ensure your project's Node.js environment is version 8 or higher. Update your `package.json` engines field accordingly.
affects: >=3.0.0
breakingThe `connections` configuration object, which previously allowed defining multiple connections, has been deprecated. Only a single connection object (`connection`) is now supported, implying a single server instance. Migrating from older versions requires adjusting your server configuration.
fix
Refactor your server configuration to use the `connection` object for a single server definition, instead of the deprecated `connections` object.
affects: >=3.0.0
gotchaThis package is implemented as a CommonJS module. Attempting to use ES Modules `import` syntax will result in `ERR_REQUIRE_ESM` or similar errors.
fix
Always use the CommonJS `require()` syntax to import and interact with `electrode-server`.
affects: >=1.0.0
gotchaWhen running the server with default settings, accessing `http://localhost:3000` will return a `404 Not Found` response because no routes are registered by default. You must configure Hapi plugins to add routes and handlers.
fix
Register your Hapi plugins containing route definitions through the `plugins` configuration object when initializing `electrode-server`.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'electrode-server'
The package `electrode-server` has not been installed.
fix
Run `npm install electrode-server` or `yarn add electrode-server` in your project directory.
TypeError: require(...) is not a function
Attempting to call `require('electrode-server')` as a function, but the module might not be correctly exported or Node.js versions mismatch.
fix
Ensure you are using Node.js v8.x.x+ as required by the module. Verify `electrode-server` is installed correctly.
Error: plugin 'your-plugin-name' missing a 'register' property
A Hapi plugin defined in the `plugins` configuration is missing the required `register` function, or the module path is incorrect.
fix
Verify that your Hapi plugin module correctly exports a `register` function and that the `module` or `register` property in your `electrode-server` plugin configuration points to the correct location/function.
Upgrade
Version history
3.3.0latest on npm
Audit
Dependencies
electrode-confippetoptionalRecommended for managing complex application configurations, though not strictly required for basic use.
Agent activity
10 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
electrode-server — npm install electrode-server · libregistry