Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hedis

Hedis is a crappy little redis wrapper I wrote (based on node-redis) to have a consistent and easy to use communication interface between my nodejs projects.

Example usage

bob.ts

import Hedis from 'hedis';

!async function main() {
	const hedis = await (new Hedis('bob', 'hedis', {
		url: 'redis://localhost:6379',
	}).init());

	hedis.on('message', (message) => {
		console.log('message: ', message);
	});

	hedis.listen((request) => {
		console.log('request: ', request.data);

		setTimeout(() => {
			request.respond('oh, hi alice');
		}, 20);

	});
}();

alice.ts

import Hedis from 'hedis';

!async function main() {
	const hedis = await (new Hedis('alice', 'hedis', {
		url: 'redis://localhost:6379',
	}).init());

	hedis.on('message', (message) => {
		console.log('message: ', message);
	});

	hedis.request('bob', 'request from alice')
		.then((response) => {
			console.log('response: ', response);

			hedis.post('bob', 'hello bob');
		})
		.catch((error) => {
			console.error('error: ', error);
		});
}();

⚠️ Keep in mind that the hedis username is always also a channel!

About

Hedis is a crappy little redis wrapper I wrote, based on node-redis, to have a consistent and easy to use communication interface between my nodejs projects.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages