Registry / database / redis-app

redis-app

JSON →
library0.13.6jsnpmunverified

A lightweight application archetype for Node.js Redis-based microservices, providing lifecycle boilerplate such as configuration loading from environment variables, database client initialization, graceful shutdown, and dependency injection. Version 0.13.6 (stable), low release cadence. Differentiators: minimal setup, integrates app-spec for spec-based config validation, and attaches common dependencies (lodash, redis, logger) to global scope for convenience. Suited for rapid prototyping and small utilities.

npm install redis-app
INSTALL
IMPORT
SIG · REDIS-APP
R
redis-app
databasejavascriptv0.13.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
require('redis-app')
import redisApp from 'redis-app'
This package is CommonJS-only, no ESM default export. Use require().
none
const app = require('redis-app')()
const app = new (require('redis-app'))()
It's a factory function, not a constructor.

Shows the typical usage: require redis-app with package.json, a spec object, a callback to assign dependencies to global, and a main function.

const path = require('path'); require('redis-app')( require('./package.json'), { redisOptions: { type: 'object', default: { host: 'localhost', port: 6379 } }, prefix: { type: 'string', default: 'myapp:' } }, async (redisApp) => { Object.assign(global, redisApp); }, async () => { const { client, config } = global; // Your main logic console.log('Config:', config); await client.set('test', 'value'); const val = await client.get('test'); console.log('Got:', val); process.exit(0); } ).catch(err => { console.error(err); process.exit(1); });
Debug
Known issues
gotchaAttaching dependencies to global scope can lead to namespace pollution and hard-to-debug errors.
fix
Use the provided redisApp object directly instead of Object.assign(global, redisApp).
affects: >=0.0.0
gotchaThe package expects a spec object compatible with app-spec. An incorrect spec will fail silently or throw obscure errors.
fix
Ensure spec object has proper keys with type and default properties.
affects: >=0.0.0
gotchaThe package implicitly uses process.env for configuration values (unless overridden in spec). Missing environment variables will cause the app to fail.
fix
Set required environment variables or provide defaults in the spec.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: redisApp is not a function
Trying to invoke the required module incorrectly, e.g. without parentheses.
fix
Use require('redis-app')() - it returns a function that must be called.
Error: Cannot find module 'app-spec'
Missing dependency app-spec not installed.
fix
Run 'npm install app-spec'.
ReferenceError: client is not defined
Did not assign redisApp dependencies to global or forgot to destructure.
fix
Call Object.assign(global, redisApp) in the callback.
Error: Config validation failed: option 'foo' missing
The spec requires a key 'foo' but env var FOO is not set and no default provided.
fix
Add a default to the spec or set the FOO environment variable.
Upgrade
Version history
0.13.6latest on npm
Audit
Dependencies
app-specrequiredUsed for configuration spec definition and validation
lodashrequiredLodash utilities attached to global scope
redisrequiredRedis client for database operations
Agent activity
11 hits · last 30 days
node
8
Meta
1
Resources
redis-app — npm install redis-app · libregistry