diff --git a/.github/API/application.md b/.github/API/application.md index 667c9391..642d2b39 100644 --- a/.github/API/application.md +++ b/.github/API/application.md @@ -8,7 +8,7 @@ The `app` object conventionally denotes the Opine application. Create it by calling the top-level `opine()` function exported by the Opine module: ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -69,7 +69,7 @@ sub-app was mounted. > to a route. ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); // the main app const admin = opine(); // the sub app @@ -487,7 +487,7 @@ starts listening for requests - this is provided for legacy reasons to aid in transitions from Express on Node. ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -523,7 +523,7 @@ This method is supported for legacy reasons to aid in transitions from Express on Node. ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); const PORT = 3000; @@ -542,7 +542,7 @@ starts listening for requests - this is provided for legacy reasons to aid in transitions from Express on Node. ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -560,7 +560,7 @@ starts listening for requests - this is provided for legacy reasons to aid in transitions from Express on Node. ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); diff --git a/.github/API/middlewares.md b/.github/API/middlewares.md index 9260f433..4953cad5 100644 --- a/.github/API/middlewares.md +++ b/.github/API/middlewares.md @@ -28,7 +28,7 @@ reasons. > `toString` may not be a function and instead a string or other user-input. ```ts -import { json, opine } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { json, opine } from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -77,7 +77,7 @@ reasons. > recommended. ```ts -import { opine, raw } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { opine, raw } from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -230,7 +230,7 @@ reasons. > recommended. ```ts -import { opine, text } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { opine, text } from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -277,7 +277,7 @@ reasons. > `toString` may not be a function and instead a string or other user-input. ```ts -import { opine, urlencoded } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { opine, urlencoded } from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); diff --git a/.github/API/opine.md b/.github/API/opine.md index e293c490..12c677f8 100644 --- a/.github/API/opine.md +++ b/.github/API/opine.md @@ -8,7 +8,7 @@ Creates an Opine application. The `opine()` function is a top-level function exported by the Opine module: ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); ``` @@ -16,7 +16,7 @@ const app = opine(); The `opine()` function is also exported as a named export: ```ts -import { opine } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { opine } from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); ``` diff --git a/.github/API/request.md b/.github/API/request.md index d2003d08..57244ec3 100644 --- a/.github/API/request.md +++ b/.github/API/request.md @@ -101,7 +101,7 @@ import { json, opine, urlencoded, -} from "https://deno.land/x/opine@2.1.3/mod.ts"; +} from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -118,7 +118,7 @@ The following example shows how to implement your own simple body-parsing middleware to transform `req.body` into a raw string: ```ts -import opine from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine from "https://deno.land/x/opine@2.1.4/mod.ts"; import { readAll } from "https://deno.land/std@0.120.0/streams/conversion.ts"; diff --git a/.github/API/router.md b/.github/API/router.md index 1835630c..c3ef9582 100644 --- a/.github/API/router.md +++ b/.github/API/router.md @@ -16,7 +16,7 @@ Opine has a top-level named function export `Router()` that creates a new `router` object. ```ts -import { Router } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { Router } from "https://deno.land/x/opine@2.1.4/mod.ts"; const router = Router(options); ``` @@ -260,7 +260,7 @@ function defined and work their way "down" the middleware stack processing for each path they match. ```ts -import opine, { Router } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import opine, { Router } from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); const router = Router(); diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 4108c904..e9e87076 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -1,5 +1,10 @@ # ChangeLog +## [2.1.4] - 12-03-2022 + +- fix: handle new OS error thrown for long filenames on windows +- test: compensate for WebSocket messages fired after close resulting in leaking timer ops + ## [2.1.3] - 12-03-2022 - deps: support Deno `1.19.3`, std `0.129.0`, and other minor dep upgrades. diff --git a/README.md b/README.md index 66b0866f..42ab58dd 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Fast, minimalist web framework for Deno ported ## Getting Started ```ts -import { opine } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { opine } from "https://deno.land/x/opine@2.1.4/mod.ts"; const app = opine(); @@ -65,14 +65,14 @@ Before importing, [download and install Deno](https://deno.land/#installation). You can then import Opine straight into your project: ```ts -import { opine } from "https://deno.land/x/opine@2.1.3/mod.ts"; +import { opine } from "https://deno.land/x/opine@2.1.4/mod.ts"; ``` Opine is also available on [nest.land](https://nest.land/package/opine), a package registry for Deno on the Blockchain. ```ts -import { opine } from "https://x.nest.land/opine@2.1.3/mod.ts"; +import { opine } from "https://x.nest.land/opine@2.1.4/mod.ts"; ``` ## Features diff --git a/docs/index.html b/docs/index.html index 061a74ce..d49923c9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -105,7 +105,7 @@
import { opine } from "https://deno.land/x/opine@2.1.3/mod.ts";
+ import { opine } from "https://deno.land/x/opine@2.1.4/mod.ts";
const app = opine();
@@ -125,11 +125,11 @@ Installation
repo and via the Deno Registry.
Before importing, download and install Deno.
You can then import Opine straight into your project:
- import { opine } from "https://deno.land/x/opine@2.1.3/mod.ts";
+ import { opine } from "https://deno.land/x/opine@2.1.4/mod.ts";
Opine is also available on nest.land, a
package registry for Deno on the Blockchain.
- import { opine } from "https://x.nest.land/opine@2.1.3/mod.ts";
+ import { opine } from "https://x.nest.land/opine@2.1.4/mod.ts";
Features
diff --git a/egg.json b/egg.json
index e222d5c3..d7b5c159 100644
--- a/egg.json
+++ b/egg.json
@@ -1,7 +1,7 @@
{
"name": "opine",
"description": "Fast, minimalist web framework for Deno ported from ExpressJS.",
- "version": "2.1.3",
+ "version": "2.1.4",
"repository": "https://github.com/cmorten/opine",
"stable": true,
"checkFormat": false,
diff --git a/src/utils/send.ts b/src/utils/send.ts
index f90ab224..81e5b7c3 100644
--- a/src/utils/send.ts
+++ b/src/utils/send.ts
@@ -59,7 +59,7 @@ const MAX_MAXAGE = 60 * 60 * 24 * 365 * 1000; // 1 year
const UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
const ENOENT_REGEXP = /\(os error 2\)/;
-const ENAMETOOLONG_REGEXP = /\(os error 63\)|\(os error 36\)/;
+const ENAMETOOLONG_REGEXP = /\(os error 63\)|\(os error 36\)|\(os error 123\)/;
/**
* Normalize the index option into an array.
diff --git a/test/units/req.upgrade.test.ts b/test/units/req.upgrade.test.ts
index b2baa721..574f2fc8 100644
--- a/test/units/req.upgrade.test.ts
+++ b/test/units/req.upgrade.test.ts
@@ -1,24 +1,39 @@
import { opine } from "../../mod.ts";
-import { expect } from "../deps.ts";
+import { deferred, expect } from "../deps.ts";
import { describe, it } from "../utils.ts";
describe("req", function () {
describe(".upgrade", function () {
- it("should upgrade websocket requests", function (done) {
+ it("should upgrade websocket requests", async function (done) {
let serverSocket: WebSocket;
+ const clientSocketClosedDeferred = deferred();
+ const clientSocketPingedDeferred = deferred();
+ const clientSocketPongedDeferred = deferred();
+ const serverSocketClosedDeferred = deferred();
+ const serverSocketPingedDeferred = deferred();
+ const serverSocketPongedDeferred = deferred();
+
const handleSocket = (socket: WebSocket) => {
serverSocket = socket;
- socket.addEventListener("open", () => {
+ serverSocket.addEventListener("close", () => {
+ serverSocketClosedDeferred.resolve();
+ });
+
+ serverSocket.addEventListener("open", () => {
console.log("[server]: ping");
- socket.send("ping");
+ serverSocket.send("ping");
+ serverSocketPingedDeferred.resolve();
});
- socket.addEventListener("message", (e) => {
+ serverSocket.addEventListener("message", (e) => {
if (e.data === "ping") {
console.log("[server]: pong");
- socket.send("pong");
+ serverSocket.send("pong");
+ serverSocketPongedDeferred.resolve();
+ } else if (e.data === "pong") {
+ serverSocket.close();
}
});
};
@@ -35,31 +50,45 @@ describe("req", function () {
const server = app.listen(3000);
- const socket = new WebSocket("ws://localhost:3000/ws");
+ const clientSocket = new WebSocket("ws://localhost:3000/ws");
+
+ clientSocket.addEventListener("close", () => {
+ clientSocketClosedDeferred.resolve();
+ });
- socket.addEventListener("open", () => {
+ clientSocket.addEventListener("open", () => {
console.log("[client]: ping");
- socket.send("ping");
+ clientSocket.send("ping");
+ clientSocketPingedDeferred.resolve();
});
- socket.addEventListener("message", (e) => {
+ clientSocket.addEventListener("message", (e) => {
if (e.data === "ping") {
console.log("[client]: pong");
- socket.send("pong");
+ clientSocket.send("pong");
+ clientSocketPongedDeferred.resolve();
} else if (e.data === "pong") {
- socket.close();
- serverSocket.close();
- server.close();
-
- done();
+ clientSocket.close();
} else {
done(new Error("unexpected message"));
}
});
- socket.addEventListener("error", (e) => {
+ clientSocket.addEventListener("error", (e) => {
done(e);
});
+
+ await Promise.all([
+ clientSocketPingedDeferred,
+ clientSocketPongedDeferred,
+ serverSocketPingedDeferred,
+ serverSocketPongedDeferred,
+ serverSocketClosedDeferred,
+ clientSocketClosedDeferred,
+ ]);
+
+ server.close();
+ done();
});
});
});
diff --git a/version.ts b/version.ts
index 968c6f6d..07da7caf 100644
--- a/version.ts
+++ b/version.ts
@@ -1,7 +1,7 @@
/**
* Version of Opine.
*/
-export const VERSION = "2.1.3";
+export const VERSION = "2.1.4";
/**
* Supported version of Deno.