New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@glidemq/hapi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glidemq/hapi

Hapi plugin for glide-mq - queue management REST API and SSE events

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

@glidemq/hapi

npm license

Hapi v21 plugin that turns glide-mq queues into a REST API with real-time SSE - one registration, 24 endpoints. Works as a general-purpose job queue API and as an AI orchestration layer with built-in usage tracking, budget monitoring, and streaming endpoints.

Why

  • Zero route boilerplate - declare queues, get job CRUD, metrics, schedulers, and SSE endpoints
  • Testable without Valkey - createTestApp builds an in-memory Hapi server for server.inject() assertions
  • Joi validation - all request bodies and query params validated with structured error messages

Install

npm install @glidemq/hapi glide-mq @hapi/hapi joi

Requires glide-mq >= 0.14.0 and Hapi 21+.

Quick start

import Hapi from "@hapi/hapi";
import { glideMQPlugin } from "@glidemq/hapi";

const server = Hapi.server({ port: 3000 });

await server.register({
  plugin: glideMQPlugin,
  options: {
    connection: { addresses: [{ host: "localhost", port: 6379 }] },
    queues: {
      emails: {
        processor: async (job) => {
          await sendEmail(job.data.to, job.data.subject);
          return { sent: true };
        },
      },
    },
    routes: true, // mounts REST + SSE endpoints
  },
});

await server.start();
// POST /emails/jobs to enqueue, GET /emails/events for SSE

glideMQPlugin creates a registry on server.glidemq and optionally mounts routes. The onPostStop hook handles graceful shutdown.

AI-native endpoints

glide-mq 0.14+ provides AI orchestration primitives - token/cost tracking, real-time streaming, human-in-the-loop suspend/signal, model failover chains, budget caps, dual-axis rate limiting, and vector search. This plugin exposes them as REST/SSE endpoints:

MethodPathDescription
GET/{name}/flows/{id}/usageAggregated token/cost usage for a flow
GET/{name}/flows/{id}/budgetBudget status and remaining limits for a flow
GET/{name}/jobs/{id}/streamSSE stream of a job's output chunks

Job serialization includes AI fields when present: usage, signals, budgetKey, fallbackIndex, tpmTokens. SSE events include usage, suspended, and budget-exceeded event types.

All AI features are also accessible programmatically via the server.glidemq registry. See the glide-mq docs for details.

Configuration

interface GlideMQPluginOptions {
  connection?: ConnectionOptions; // Required unless testing: true
  queues?: Record<string, QueueConfig>;
  producers?: Record<string, ProducerConfig>;
  prefix?: string;    // Valkey key prefix (default: "glide")
  testing?: boolean;  // In-memory mode, no Valkey needed
  routes?: boolean | GlideMQRoutesOptions; // Mount REST + SSE endpoints
}

Route access control via GlideMQRoutesOptions:

await server.register({
  plugin: glideMQPlugin,
  options: {
    connection: { addresses: [{ host: "localhost", port: 6379 }] },
    queues: { emails: { processor: async (job) => ({ sent: true }) } },
    routes: {
      queues: ["emails"],    // restrict to specific queues
      producers: ["emails"], // restrict to specific producers
    },
  },
});

Testing

import { createTestApp } from "@glidemq/hapi/testing";

const { server } = await createTestApp({
  emails: { processor: async (job) => ({ sent: true }) },
});

const res = await server.inject({
  method: "POST",
  url: "/emails/jobs",
  payload: { name: "welcome", data: { to: "user@test.com" } },
});
// res.statusCode === 201

await server.stop();

Limitations

  • No built-in authentication. Add Hapi auth strategies or gateway-level controls separately.
  • addAndWait (POST /{name}/jobs/wait) is not available in testing mode.
  • Producers are not supported in testing mode.

License

Apache-2.0

Keywords

hapi

FAQs

Package last updated on 28 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts