New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fastify-uws

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-uws - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

100

dist/server.js

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

var O = Object.defineProperty;
var U = (c, r, s) => r in c ? O(c, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : c[r] = s;
var e = (c, r, s) => U(c, typeof r != "symbol" ? r + "" : r, s);
import G from "node:dns/promises";
import W from "node:events";
import z from "ipaddr.js";
var U = Object.defineProperty;
var G = (c, r, s) => r in c ? U(c, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : c[r] = s;
var i = (c, r, s) => G(c, typeof r != "symbol" ? r + "" : r, s);
import W from "node:dns/promises";
import z from "node:events";
import B from "ipaddr.js";
import N from "uWebSockets.js";
import { ERR_SERVER_DESTROYED as B, ERR_SOCKET_BAD_PORT as F, ERR_ENOTFOUND as K, ERR_ADDRINUSE as V } from "./errors.js";
import { HTTPSocket as Y } from "./http-socket.js";
import { Request as j } from "./request.js";
import { Response as J } from "./response.js";
import { kHandler as A, kHttps as w, kWs as o, kAddress as t, kListenSocket as d, kApp as _, kClosed as f, kListenAll as g, kListening as p, kListen as v } from "./symbols.js";
function M() {
import { ERR_SERVER_DESTROYED as F, ERR_SOCKET_BAD_PORT as K, ERR_ENOTFOUND as V, ERR_ADDRINUSE as Y } from "./errors.js";
import { HTTPSocket as j } from "./http-socket.js";
import { Request as J } from "./request.js";
import { Response as M } from "./response.js";
import { kHandler as A, kHttps as w, kWs as h, kAddress as t, kListenSocket as d, kApp as _, kClosed as f, kListenAll as g, kListening as p, kListen as v } from "./symbols.js";
function Q() {
return N.App();
}
const a = {};
var S, D, P, C, L, H, I, x, b;
class os extends W {
constructor(s, i = {}) {
var S, D, P, C, L, H, I, x, q;
class os extends z {
constructor(s, e = {}) {
super();
e(this, b);
e(this, "timeout");
e(this, x);
e(this, I);
e(this, H);
e(this, L);
e(this, C);
e(this, P);
e(this, D);
e(this, S);
const { connectionTimeout: l = 0, https: u = !1 } = i;
this[A] = s, this.timeout = l, this[w] = u, this[o] = null, this[t] = null, this[d] = null, this[_] = M(), this[f] = !1;
i(this, q);
i(this, "timeout");
i(this, x);
i(this, I);
i(this, H);
i(this, L);
i(this, C);
i(this, P);
i(this, D);
i(this, S);
const { connectionTimeout: o = 0, https: u = !1 } = e;
this[A] = s, this.timeout = o, this[w] = u, this[h] = null, this[t] = null, this[d] = null, this[_] = Q(), this[f] = !1;
}

@@ -46,9 +46,9 @@ get encrypted() {

}
listen(s) {
listen(s, e) {
s != null && s.signal && s.signal.addEventListener("abort", () => {
this.close();
}), this[v](s).then(() => {
this[p] = !0, this.emit("listening");
}).catch((i) => {
this[t] = null, process.nextTick(() => this.emit("error", i));
e == null || e(), this[p] = !0, this.emit("listening");
}).catch((o) => {
this[t] = null, process.nextTick(() => this.emit("error", o));
});

@@ -61,7 +61,7 @@ }

}) {
var l;
var o;
if (this[t] = null, this[p] = !1, this[f]) return s();
const i = (l = this[t]) == null ? void 0 : l.port;
if (i !== void 0 && a[i] === this && delete a[i], this[t] = null, this[f] = !0, this[d] && (N.us_listen_socket_close(this[d]), this[d] = null), this[o])
for (const u of this[o].connections)
const e = (o = this[t]) == null ? void 0 : o.port;
if (e !== void 0 && a[e] === this && delete a[e], this[t] = null, this[f] = !0, this[d] && (N.us_listen_socket_close(this[d]), this[d] = null), this[h])
for (const u of this[h].connections)
u.close();

@@ -76,24 +76,24 @@ process.nextTick(() => {

}
async [(b = A, x = w, I = o, H = t, L = d, C = _, P = f, D = g, S = p, v)]({ port: s, host: i }) {
if (this[f]) throw new B();
async [(q = A, x = w, I = h, H = t, L = d, C = _, P = f, D = g, S = p, v)]({ port: s, host: e }) {
if (this[f]) throw new F();
if (s != null && Number.isNaN(Number(s)))
throw new F(s);
throw new K(s);
s = s == null ? 0 : Number(s);
const l = await G.lookup(i);
const o = await W.lookup(e);
if (this[t] = {
...l,
...o,
port: s
}, this[t].address.startsWith("[")) throw new K(this[t].address);
const u = z.parse(this[t].address);
}, this[t].address.startsWith("[")) throw new V(this[t].address);
const u = B.parse(this[t].address);
this[t].family = u.kind() === "ipv6" ? "IPv6" : "IPv4";
const q = u.toNormalizedString(), T = this[_], n = (m) => (k, E) => {
const h = new Y(this, k, m === "GET" || m === "HEAD"), R = new j(E, h, m), y = new J(h);
R.headers.upgrade && this.emit("upgrade", R, h), this[A](R, y);
const y = u.toNormalizedString(), T = this[_], n = (m) => (k, E) => {
const l = new j(this, k, m === "GET" || m === "HEAD"), R = new J(E, l, m), O = new M(l);
R.headers.upgrade && this.emit("upgrade", R, l), this[A](R, O);
};
return T.connect("/*", n("CONNECT")).del("/*", n("DELETE")).get("/*", n("GET")).head("/*", n("HEAD")).options("/*", n("OPTIONS")).patch("/*", n("PATCH")).post("/*", n("POST")).put("/*", n("PUT")).trace("/*", n("TRACE")), s !== 0 && a[s] && (this[o] = a[s][o]), this[o] && this[o].addServer(this), new Promise((m, k) => {
const E = (h) => {
if (!h) return k(new V(this[t].address, s));
this[d] = h, s = this[t].port = N.us_socket_local_port(h), a[s] || (a[s] = this), m();
return T.connect("/*", n("CONNECT")).del("/*", n("DELETE")).get("/*", n("GET")).head("/*", n("HEAD")).options("/*", n("OPTIONS")).patch("/*", n("PATCH")).post("/*", n("POST")).put("/*", n("PUT")).trace("/*", n("TRACE")), s !== 0 && a[s] && (this[h] = a[s][h]), this[h] && this[h].addServer(this), new Promise((m, k) => {
const E = (l) => {
if (!l) return k(new Y(this[t].address, s));
this[d] = l, s = this[t].port = N.us_socket_local_port(l), a[s] || (a[s] = this), m();
};
this[g] = i === "localhost", this[g] ? T.listen(s, E) : T.listen(q, s, E);
this[g] = e === "localhost", this[g] ? T.listen(s, E) : T.listen(y, s, E);
});

@@ -100,0 +100,0 @@ }

@@ -31,3 +31,3 @@ import { default as EventEmitter } from 'node:events';

signal: AbortSignal;
}): void;
}, cb: any): void;
closeIdleConnections(): void;

@@ -34,0 +34,0 @@ close(cb?: () => void): void;

{
"name": "fastify-uws",
"version": "0.8.0",
"version": "0.8.1",
"description": "A performant HTTP and WebSocket server for Fastify with uWebSockets.",

@@ -5,0 +5,0 @@ "main": "./dist/fastify-uws.cjs",

@@ -19,15 +19,15 @@ # fastify-uws

## Prerequisites
## Supported
- `fastify` v4.28.1+
- `fastify` v4.x
- `@fastify/websocket` v10.x
> [!WARNING]
> If your `fastify` version is below `4.28.0`, please install `fastify-uws` version `0.7.1`.
## Usage
Just two lines are needed to speed up your Fastify application.
```ts
// app.ts
import fastify from 'fastify';
import { serverFactory } from 'fastify-uws';
import { serverFactory } from 'fastify-uws'; // Import here

@@ -43,3 +43,3 @@ import router from '~/plugins/router';

},
serverFactory,
serverFactory, // And use here
});

@@ -135,2 +135,9 @@

Just a single line of change can speed up your WebSocket application in Fastify.
```diff
- import websocket from '@fastify/websocket';
+ import { websocket } from 'fastify-uws';
```
```ts

@@ -137,0 +144,0 @@ // app.ts

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc