tiger-server
v0.6.2
Published
Even simple than trigger
Readme
tiger-server
Tiger server is a very lightweight server for very simple process like webhooks.
Usage
npm install tiger-server --saveand create server.ts:
import { defineServer, http, cron, queue } from "tiger-server";
import type { QueueModule, CronModule, HttpModule } from "tiger-server";
export default defineServer(async (tiger) => {
await tiger.use(http, cron, queue);
await tiger.define<QueueModule<{message: string}>>({
id: "hello",
target: "queue:hello",
async process(_state, message) {
this.log(`Message received: ${JSON.stringify(message)}`);
}
});
await tiger.define<CronModule<{count: number}>>({
id: "cron",
target: "cron:*/5 * * * * *",
async process({ count = 0 }) {
count++;
await this.notify("queue:hello", { count });
return { count }
}
});
await tiger.define<HttpModule>({
id: "request",
target: "http:/hello",
async process(_state, { req, res }) {
await this.notify("queue:hello", { message: "request recieved" });
res.send("success!")
}
});
});Run it with Node.js 22.6+:
npx tiger-server run server.tsThis relies on Node’s native TypeScript loader, so there is no build step and the code runs directly.
The
httpplugin defaults to0.0.0.0:9527. Overridehttp.port/http.host(orTIGER_HTTP_PORT/TIGER_HTTP_HOST) to run multiple Tiger instances side-by-side while sharing the same cron queue.
The Monitor UI follows
monitor.host:monitor.port(defaults0.0.0.0:9753). Tweakmonitorconfig orTIGER_MONITOR_*env vars—or disable it entirely withmonitor.disabled/TIGER_MONITOR_DISABLED=1.
The
queueplugin is now an in-memory message bus. It deliversqueue:(or legacyzmq:) notifications to modules defined in the same process without any external socket or runtime-specific dependency.
The
cronplugin persists its schedule either in LevelDB (cron.levelDbPath, default.tiger-cron) or, when you run distributed mode with a Postgres driver, inside the shared Postgres database. Multiple Tiger processes simply read from the same store and pop due runs cooperatively.
To build distributed modules, configure the
distributedblock. Setdistributed.drivertopostgres(and pointDATABASE_URLto your Postgres instance) to enable a shared job/state store, or leave it aslevelfor single-node experimentation. Every distributed module must declare anidanddistributed: true; Tiger will enqueue work, persist state, and heartbeat the node registry through the configured persistence provider. Usedistributed.maxQueueLength(default100) to keep runaway producers from filling the queue indefinitely.
When running with the Postgres driver, apply the bundled Sequelize migrations (e.g.
DATABASE_URL=postgres://... npx sequelize-cli db:migrate) before starting Tiger so the job, state, and registry tables exist.
When distributed mode is enabled, a management dashboard and API are available at
/tiger/manageon the same port as the monitor. It lists every node’s last heartbeat, whether it is enabled/disabled, and lets you pause or resume queue consumption for any node while it continues to report heartbeats and finish in-flight work.
Logo is generated from Wikipedia, the original script is under GPL license.
