npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@apiquest/plugin-sse

v1.0.6

Published

SSE protocol plugin for ApiQuest

Readme

@apiquest/plugin-sse

Server-Sent Events (SSE) protocol plugin for ApiQuest. Provides support for testing SSE endpoints with event streaming and message validation.

Installation

# Using npm
npm install -g @apiquest/plugin-sse

# Or using fracture CLI
fracture plugin install sse

Features

  • SSE connection management
  • Event streaming with named events
  • Message data validation
  • Event counting and assertions
  • Custom headers support
  • Authentication integration (via @apiquest/plugin-auth)
  • Timeout configuration

Usage

Set the collection protocol to sse:

{
  "$schema": "https://apiquest.net/schemas/collection-v1.0.json",
  "protocol": "sse",
  "items": [
    {
      "type": "request",
      "id": "stream-events",
      "name": "Stream Server Events",
      "data": {
        "url": "https://api.example.com/events",
        "timeout": 30000,
        "scripts": [
          {
            "event": "onMessage",
            "script": "quest.test('Message received', () => {\n  const msg = quest.message;\n  expect(msg.data).to.be.a('string');\n});"
          },
          {
            "event": "onComplete",
            "script": "quest.test('Stream completed', () => {\n  expect(quest.messages.length).to.be.greaterThan(0);\n});"
          }
        ]
      }
    }
  ]
}

With Custom Headers

{
  "data": {
    "url": "https://api.example.com/stream",
    "headers": {
      "Accept": "text/event-stream",
      "x-stream-id": "{{streamId}}"
    },
    "timeout": 60000
  }
}

Event Scripts

SSE requests support event-based scripts:

  • onMessage - Runs for each received message
  • onError - Runs when an error occurs
  • onComplete - Runs when the stream completes
{
  "data": {
    "scripts": [
      {
        "event": "onMessage",
        "script": "const data = JSON.parse(quest.message.data);\nquest.variables.set('lastEventId', data.id);\n\nquest.test('Valid event data', () => {\n  expect(data).to.have.property('timestamp');\n});"
      },
      {
        "event": "onError",
        "script": "console.error('Stream error:', quest.error);"
      },
      {
        "event": "onComplete",
        "script": "quest.test('Received messages', () => {\n  expect(quest.messages.length).to.equal(10);\n});"
      }
    ]
  }
}

Message Counting

Use quest.expectMessages() in the preRequestScript to enable deterministic test counting:

{
  "type": "request",
  "id": "stream-events",
  "name": "Stream Server Events",
  "preRequestScript": "quest.expectMessages(5, 10000);",
  "data": {
    "url": "https://api.example.com/events",
    "scripts": [
      {
        "event": "onMessage",
        "script": "quest.test('Message received', () => {\n  expect(quest.message.data).to.exist;\n});"
      }
    ]
  }
}

This informs the runner to expect 5 messages, enabling accurate test count reporting (5 messages × tests per message).

Response Handling

Access SSE data in scripts:

// In onMessage script
quest.test('Event has data', () => {
  expect(quest.message.data).to.be.a('string');
});

quest.test('Event type is update', () => {
  expect(quest.message.event).to.equal('update');
});

// In onComplete script
quest.test('Received all messages', () => {
  expect(quest.messages.length).to.equal(5);
});

quest.test('All messages valid', () => {
  quest.messages.forEach(msg => {
    const data = JSON.parse(msg.data);
    expect(data).to.have.property('id');
  });
});

Compatibility

  • Authentication: Works with @apiquest/plugin-auth for Bearer, Basic, API Key
  • Node.js: Requires Node.js 20+

Documentation

License

Dual-licensed under AGPL-3.0-or-later and commercial license. See LICENSE.txt for details.