Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

fastify-sse-v2

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-sse-v2 - npm Package Compare versions

Comparing version
1.0.2
to
1.0.3
+6
-1
CHANGELOG.md

@@ -9,2 +9,6 @@ # Changelog

## [1.0.3]
### Fixed
- type definitions referencing itself
## [1.0.2]

@@ -18,5 +22,6 @@ ### Fixed

[Unreleased]: https://github.com/nodefactoryio/fastify-sse-v2/compare/v1.0.2...HEAD
[Unreleased]: https://github.com/nodefactoryio/fastify-sse-v2/compare/v1.0.3...HEAD
[1.0.3]: https://github.com/nodefactoryio/fastify-sse-v2/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/nodefactoryio/fastify-sse-v2/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/nodefactoryio/fastify-sse-v2/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/nodefactoryio/fastify-sse-v2/releases/tag/v1.0.0
+4
-3

@@ -1,5 +0,6 @@

/// <reference path="index.d.ts" />
/// <reference types="node" />
/// <reference types="fastify" />
export declare const FastifySSEPlugin: (instance: import("fastify").FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse>, options: import("./types").SsePluginOptions, callback: (err?: import("fastify").FastifyError) => void) => void;
import { IncomingMessage, Server, ServerResponse } from "http";
import { Plugin } from "fastify";
import { SsePluginOptions } from "./types";
export declare const FastifySSEPlugin: Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions>;
declare module "fastify" {

@@ -6,0 +7,0 @@ interface EventMessage {

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/index.ts"],"names":["FastifySSEPlugin","plugin","name","fastify"],"mappings":";;;;;;;AAAA;;AACA;;;;AAEO,MAAMA,gBAAgB,GAAG,4BAAcC,cAAd,EAAsB;AACpDC,EAAAA,IAAI,EAAE,gBAD8C;AAEpDC,EAAAA,OAAO,EAAE;AAF2C,CAAtB,CAAzB","sourcesContent":["import fastifyPlugin from \"fastify-plugin\";\nimport {plugin} from \"./plugin\";\n\nexport const FastifySSEPlugin = fastifyPlugin(plugin, {\n name: \"fastify-sse-v2\",\n fastify: \"2.x\",\n});\n\ndeclare module \"fastify\" {\n\n interface EventMessage {\n /**\n * Message payload\n */\n data?: string;\n\n /**\n * Message identifier, if set, client will send `Last-Event-ID: <id>` header on reconnect\n */\n id?: string;\n\n /**\n * Message type\n */\n event?: string;\n\n /**\n * Update client reconnect interval (how long will client wait before trying to reconnect).\n */\n retry?: number;\n }\n\n interface FastifyReply<HttpResponse> {\n sse(source: AsyncIterable<EventMessage>): void;\n }\n}"],"file":"index.js"}
{"version":3,"sources":["../src/index.ts"],"names":["FastifySSEPlugin","plugin","name","fastify"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,gBAAmF,GAC1F,4BAAcC,cAAd,EAAsB;AACtBC,EAAAA,IAAI,EAAE,gBADgB;AAEtBC,EAAAA,OAAO,EAAE;AAFa,CAAtB,CADC","sourcesContent":["import fastifyPlugin from \"fastify-plugin\";\nimport {plugin} from \"./plugin\";\nimport {IncomingMessage, Server, ServerResponse} from \"http\";\nimport {Plugin} from \"fastify\";\nimport {SsePluginOptions} from \"./types\";\n\nexport const FastifySSEPlugin: Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions> \n = fastifyPlugin(plugin, {\n name: \"fastify-sse-v2\",\n fastify: \"2.x\",\n });\n\ndeclare module \"fastify\" {\n\n interface EventMessage {\n /**\n * Message payload\n */\n data?: string;\n\n /**\n * Message identifier, if set, client will send `Last-Event-ID: <id>` header on reconnect\n */\n id?: string;\n\n /**\n * Message type\n */\n event?: string;\n\n /**\n * Update client reconnect interval (how long will client wait before trying to reconnect).\n */\n retry?: number;\n }\n\n interface FastifyReply<HttpResponse> {\n sse(source: AsyncIterable<EventMessage>): void;\n }\n}"],"file":"index.js"}
/// <reference types="node" />
import fastify from "fastify";
import { Plugin } from "fastify";
import { IncomingMessage, Server, ServerResponse } from "http";
import { SsePluginOptions } from "./types";
export declare const plugin: fastify.Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions>;
export declare const plugin: Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions>;

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/plugin.ts"],"names":["plugin","instance","options","decorateReply","source","outputStream","push","retry","retryDelay","type","header","send","pipe"],"mappings":";;;;;;;AAGA;;AACA;;;;AAEO,MAAMA,MAAiF,GAC1F,gBAAgBC,QAAhB,EAA0BC,OAA1B,EAAkD;AAChDD,EAAAA,QAAQ,CAACE,aAAT,CACE,KADF,EAEE,UAA8CC,MAA9C,EAAyF;AACvF,UAAMC,YAAY,GAAG,2BAArB;AACAA,IAAAA,YAAY,CAACC,IAAb,CAAkB,4BAAkB;AAACC,MAAAA,KAAK,EAAEL,OAAO,CAACM,UAAR,IAAsB;AAA9B,KAAlB,CAAlB;AACA,SAAKC,IAAL,CAAU,mBAAV,EACGC,MADH,CACU,YADV,EACwB,YADxB,EAEGA,MAFH,CAEU,eAFV,EAE2B,UAF3B,EAGGC,IAHH,CAGQN,YAHR;AAIA,6BAAS,iCAAuBD,MAAvB,CAAT,EAAyCQ,IAAzC,CAA8CP,YAA9C;AACD,GAVH;AAWD,CAbE","sourcesContent":["import fastify, {EventMessage, FastifyReply} from \"fastify\";\nimport {IncomingMessage, Server, ServerResponse} from \"http\";\nimport {SsePluginOptions} from \"./types\";\nimport {getOutputStream, serializeSSEEvent, transformAsyncIterable} from \"./sse\";\nimport toStream from \"it-to-stream\";\n\nexport const plugin: fastify.Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions> = \n async function (instance, options): Promise<void> {\n instance.decorateReply( \n \"sse\",\n function (this: FastifyReply<ServerResponse>, source: AsyncIterable<EventMessage>): void {\n const outputStream = getOutputStream();\n outputStream.push(serializeSSEEvent({retry: options.retryDelay || 3000}));\n this.type(\"text/event-stream\")\n .header(\"Connection\", \"keep-alive\")\n .header(\"Cache-Control\", \"no-cache\")\n .send(outputStream);\n toStream(transformAsyncIterable(source)).pipe(outputStream);\n });\n };"],"file":"plugin.js"}
{"version":3,"sources":["../src/plugin.ts"],"names":["plugin","instance","options","decorateReply","source","outputStream","push","retry","retryDelay","type","header","send","pipe"],"mappings":";;;;;;;AAGA;;AACA;;;;AAEO,MAAMA,MAAyE,GAClF,gBAAgBC,QAAhB,EAA0BC,OAA1B,EAAkD;AAChDD,EAAAA,QAAQ,CAACE,aAAT,CACE,KADF,EAEE,UAA8CC,MAA9C,EAAyF;AACvF,UAAMC,YAAY,GAAG,2BAArB;AACAA,IAAAA,YAAY,CAACC,IAAb,CAAkB,4BAAkB;AAACC,MAAAA,KAAK,EAAEL,OAAO,CAACM,UAAR,IAAsB;AAA9B,KAAlB,CAAlB;AACA,SAAKC,IAAL,CAAU,mBAAV,EACGC,MADH,CACU,YADV,EACwB,YADxB,EAEGA,MAFH,CAEU,eAFV,EAE2B,UAF3B,EAGGC,IAHH,CAGQN,YAHR;AAIA,6BAAS,iCAAuBD,MAAvB,CAAT,EAAyCQ,IAAzC,CAA8CP,YAA9C;AACD,GAVH;AAWD,CAbE","sourcesContent":["import {EventMessage, FastifyReply, Plugin} from \"fastify\";\nimport {IncomingMessage, Server, ServerResponse} from \"http\";\nimport {SsePluginOptions} from \"./types\";\nimport {getOutputStream, serializeSSEEvent, transformAsyncIterable} from \"./sse\";\nimport toStream from \"it-to-stream\";\n\nexport const plugin: Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions> =\n async function (instance, options): Promise<void> {\n instance.decorateReply( \n \"sse\",\n function (this: FastifyReply<ServerResponse>, source: AsyncIterable<EventMessage>): void {\n const outputStream = getOutputStream();\n outputStream.push(serializeSSEEvent({retry: options.retryDelay || 3000}));\n this.type(\"text/event-stream\")\n .header(\"Connection\", \"keep-alive\")\n .header(\"Cache-Control\", \"no-cache\")\n .send(outputStream);\n toStream(transformAsyncIterable(source)).pipe(outputStream);\n });\n };"],"file":"plugin.js"}
{
"name": "fastify-sse-v2",
"version": "1.0.2",
"version": "1.0.3",
"description": "Fastify plugin for sending server side events.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

import fastifyPlugin from "fastify-plugin";
import {plugin} from "./plugin";
import {IncomingMessage, Server, ServerResponse} from "http";
import {Plugin} from "fastify";
import {SsePluginOptions} from "./types";
export const FastifySSEPlugin = fastifyPlugin(plugin, {
name: "fastify-sse-v2",
fastify: "2.x",
});
export const FastifySSEPlugin: Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions>
= fastifyPlugin(plugin, {
name: "fastify-sse-v2",
fastify: "2.x",
});

@@ -9,0 +13,0 @@ declare module "fastify" {

@@ -1,2 +0,2 @@

import fastify, {EventMessage, FastifyReply} from "fastify";
import {EventMessage, FastifyReply, Plugin} from "fastify";
import {IncomingMessage, Server, ServerResponse} from "http";

@@ -7,3 +7,3 @@ import {SsePluginOptions} from "./types";

export const plugin: fastify.Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions> =
export const plugin: Plugin<Server, IncomingMessage, ServerResponse, SsePluginOptions> =
async function (instance, options): Promise<void> {

@@ -10,0 +10,0 @@ instance.decorateReply(