A Light weight Events listener for redis and mariadb/mysql
For my project, i made this to listen a key has expired then update that data to database.
Just download this source code, then let's edit/make anything do u want.
- the only thing needed is Install Dependencies
- npm
$ npm install
- bun
$ bun install
Everything is in .env files.
REDIS_HOST
for hostname/ip of redisREDIS_PORT
for port of redisREDIS_PASSWORD
for password of redis (optional)REDIS_DB
database index. (optional)
DB_HOST
for hostname/ip of databaseDB_PORT
for port of databaseDB_USER
for username of databaseDB_PASSWORD
for password of databaseDB_NAME
for database name
first, create typescript file in src/events
directory, and in that file required these exports:
listenerName
name of event to listenhandler
your function with these optional args:pattern: string
,channel: string
,message: string
- and last one is export default for all of that things.
and for now you need to provide manually your handler/listener in src/events/static.ts
, put/import your listener to events
constant with these required:
name
from[your_listener].listenerName
handler
from[your_listener].handler
e.g. src/events/example.ts
, src/events/promise-example.ts
It's very simple
- npm
$ npm dev
- bun
$ bun dev
- npm
$ npm build
- bun
$ bun build
- npm
OR
$ npm start
$ node dist/index.js
- bun
OR
$ bun start
$ bun run dist/index.js
Feel free to contribute to this project.
I made this for community and my personal project.
Please open issue first before pull request.
Thank you.