From a10a41f1004b1ee63d7b5f2604e5a6b2a5b01bd5 Mon Sep 17 00:00:00 2001 From: Craig Morten Date: Fri, 31 Dec 2021 16:58:19 +0000 Subject: [PATCH] [#150] Support Deno 1.17.1 (#152) --- .github/API/application.md | 12 ++++++------ .github/API/middlewares.md | 8 ++++---- .github/API/opine.md | 4 ++-- .github/API/request.md | 4 ++-- .github/API/router.md | 4 ++-- .github/CHANGELOG.md | 4 ++++ .github/workflows/benchmark.yml | 2 +- .github/workflows/publish-docs.yml | 2 +- .github/workflows/publish-egg.yml | 2 +- .github/workflows/test.yml | 4 ++-- README.md | 8 ++++---- deps.ts | 24 ++++++++++++------------ docs/index.html | 8 ++++---- egg.json | 2 +- src/application.ts | 19 +++++++++++-------- src/utils/finalHandler.ts | 2 +- test/deps.ts | 8 ++++---- version.ts | 4 ++-- 18 files changed, 64 insertions(+), 57 deletions(-) diff --git a/.github/API/application.md b/.github/API/application.md index 2cf5e88f..3ddbf3bc 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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/mod.ts"; const app = opine(); diff --git a/.github/API/middlewares.md b/.github/API/middlewares.md index e8a04844..30221e3a 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.0.0/mod.ts"; +import { json, opine } from "https://deno.land/x/opine@2.0.1/mod.ts"; const app = opine(); @@ -77,7 +77,7 @@ reasons. > recommended. ```ts -import { opine, raw } from "https://deno.land/x/opine@2.0.0/mod.ts"; +import { opine, raw } from "https://deno.land/x/opine@2.0.1/mod.ts"; const app = opine(); @@ -230,7 +230,7 @@ reasons. > recommended. ```ts -import { opine, text } from "https://deno.land/x/opine@2.0.0/mod.ts"; +import { opine, text } from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import { opine, urlencoded } from "https://deno.land/x/opine@2.0.1/mod.ts"; const app = opine(); diff --git a/.github/API/opine.md b/.github/API/opine.md index 635d6864..1f859b72 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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import { opine } from "https://deno.land/x/opine@2.0.1/mod.ts"; const app = opine(); ``` diff --git a/.github/API/request.md b/.github/API/request.md index 0bd8bf32..0a61e905 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.0.0/mod.ts"; +} from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import opine from "https://deno.land/x/opine@2.0.1/mod.ts"; const app = opine(); diff --git a/.github/API/router.md b/.github/API/router.md index 59bbfb64..8b6f043a 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.0.0/mod.ts"; +import { Router } from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import opine, { Router } from "https://deno.land/x/opine@2.0.1/mod.ts"; const app = opine(); const router = Router(); diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 9207e3be..4ee77897 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -1,5 +1,9 @@ # ChangeLog +## [2.0.1] - 18-12-2021 + +- deps: support Deno `1.17.1`, std `0.119.0`, and other minor dep upgrades. + ## [2.0.0] - 28-11-2021 - feat: support Deno `1.16.3`, std `0.116.0`, and other minor dep upgrades. diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 1b3e0e01..ba3fd831 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v2 - uses: denolib/setup-deno@v2 with: - deno-version: 1.16.3 + deno-version: 1.17.1 - run: | mkdir -p artifacts cat > artifacts/message.md <Deno ported

Opine latest /x/ version - Minimum supported Deno version + Minimum supported Deno version Opine dependency count Opine dependency outdatedness Opine cached size @@ -41,7 +41,7 @@ Fast, minimalist web framework for Deno ported ## Getting Started ```ts -import { opine } from "https://deno.land/x/opine@2.0.0/mod.ts"; +import { opine } from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import { opine } from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts"; +import { opine } from "https://x.nest.land/opine@2.0.1/mod.ts"; ``` ## Features diff --git a/deps.ts b/deps.ts index a30ed60c..699ab97f 100644 --- a/deps.ts +++ b/deps.ts @@ -1,14 +1,14 @@ -export { Server } from "https://deno.land/std@0.116.0/http/server.ts"; -export type { ConnInfo } from "https://deno.land/std@0.116.0/http/server.ts"; +export { Server } from "https://deno.land/std@0.119.0/http/server.ts"; +export type { ConnInfo } from "https://deno.land/std@0.119.0/http/server.ts"; export { Status, STATUS_TEXT, -} from "https://deno.land/std@0.116.0/http/http_status.ts"; +} from "https://deno.land/std@0.119.0/http/http_status.ts"; export { deleteCookie, setCookie, -} from "https://deno.land/std@0.116.0/http/cookie.ts"; -export type { Cookie } from "https://deno.land/std@0.116.0/http/cookie.ts"; +} from "https://deno.land/std@0.119.0/http/cookie.ts"; +export type { Cookie } from "https://deno.land/std@0.119.0/http/cookie.ts"; export { basename, dirname, @@ -19,15 +19,15 @@ export { normalize, resolve, sep, -} from "https://deno.land/std@0.116.0/path/mod.ts"; -export { setImmediate } from "https://deno.land/std@0.116.0/node/timers.ts"; -export { parse } from "https://deno.land/std@0.116.0/node/querystring.ts"; -export { default as EventEmitter } from "https://deno.land/std@0.116.0/node/events.ts"; -export { Sha1 } from "https://deno.land/std@0.116.0/hash/sha1.ts"; +} from "https://deno.land/std@0.119.0/path/mod.ts"; +export { setImmediate } from "https://deno.land/std@0.119.0/node/timers.ts"; +export { parse } from "https://deno.land/std@0.119.0/node/querystring.ts"; +export { default as EventEmitter } from "https://deno.land/std@0.119.0/node/events.ts"; +export { Sha1 } from "https://deno.land/std@0.119.0/hash/sha1.ts"; export { readableStreamFromReader, readerFromStreamReader, -} from "https://deno.land/std@0.116.0/streams/conversion.ts"; +} from "https://deno.land/std@0.119.0/streams/conversion.ts"; export { charset, @@ -46,6 +46,6 @@ export { encodeUrl } from "https://deno.land/x/encodeurl@1.0.0/mod.ts"; export { gunzip, inflate } from "https://deno.land/x/compress@v0.4.1/mod.ts"; export { default as parseRange } from "https://cdn.skypack.dev/range-parser@1.2.1?dts"; -export { default as qs } from "https://cdn.skypack.dev/qs@6.10.1?dts"; +export { default as qs } from "https://cdn.skypack.dev/qs@6.10.2?dts"; export { default as ipaddr } from "https://cdn.skypack.dev/ipaddr.js@2.0.1?dts"; export { default as ms } from "https://cdn.skypack.dev/ms@2.1.3?dts"; diff --git a/docs/index.html b/docs/index.html index 3e499e88..d7123b8f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -82,7 +82,7 @@

Opine

Opine latest /x/ version - Minimum supported Deno version + Minimum supported Deno version Opine dependency count Opine dependency outdatedness Opine cached size @@ -105,7 +105,7 @@

Table of Contents

Getting Started

-
import { opine } from "https://deno.land/x/opine@2.0.0/mod.ts";
+				
import { opine } from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts";
+				
import { opine } from "https://deno.land/x/opine@2.0.1/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.0.0/mod.ts";
+				
import { opine } from "https://x.nest.land/opine@2.0.1/mod.ts";
 

Features

diff --git a/egg.json b/egg.json index 4b6f9de1..f53584ba 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.0.0", + "version": "2.0.1", "repository": "https://github.com/asos-craigmorten/opine", "stable": true, "checkFormat": false, diff --git a/src/application.ts b/src/application.ts index d90759d0..ecfffa16 100644 --- a/src/application.ts +++ b/src/application.ts @@ -551,22 +551,25 @@ app.listen = function listen( options?: number | string | HTTPOptions | HTTPSOptions, callback?: () => void, ): Server { - let addr: string; + let port = 0; + let hostname = ""; - if (typeof options === "undefined") { - addr = ":0"; - } else if (typeof options === "number") { - addr = `:${options}`; + if (typeof options === "number") { + port = options; } else if (typeof options === "string") { - addr = options; + const addr = options.split(":"); + hostname = addr[0]; + port = parseInt(addr[1]); } else { - addr = `${options.hostname ?? ""}:${options.port ?? 0}`; + hostname = options?.hostname ?? ""; + port = options?.port ?? 0; } const isTls = isTlsOptions(options); const server = new Server({ - addr, + port, + hostname, handler: async (request, connInfo) => { const opineRequest = new WrappedRequest(request, connInfo); this(opineRequest); diff --git a/src/utils/finalHandler.ts b/src/utils/finalHandler.ts index 87462c17..82d08410 100644 --- a/src/utils/finalHandler.ts +++ b/src/utils/finalHandler.ts @@ -183,7 +183,7 @@ function getErrorStatusCode(err: any): number | undefined { function getResourceName(req: OpineRequest): string { try { return (parseUrl(req) as ParsedURL).pathname; - } catch (e) { + } catch { return "resource"; } } diff --git a/test/deps.ts b/test/deps.ts index aadf198c..337fcdad 100644 --- a/test/deps.ts +++ b/test/deps.ts @@ -1,8 +1,8 @@ -export { deferred } from "https://deno.land/std@0.116.0/async/deferred.ts"; -export type { Deferred } from "https://deno.land/std@0.116.0/async/deferred.ts"; +export { deferred } from "https://deno.land/std@0.119.0/async/deferred.ts"; +export type { Deferred } from "https://deno.land/std@0.119.0/async/deferred.ts"; export { expect, mock } from "https://deno.land/x/expect@v0.2.9/mod.ts"; -export { superdeno } from "https://deno.land/x/superdeno@4.6.1/mod.ts"; +export { superdeno } from "https://deno.land/x/superdeno@4.7.1/mod.ts"; export type { IRequest as SuperDenoRequest, IResponse as SuperDenoResponse, -} from "https://deno.land/x/superdeno@4.6.1/mod.ts"; +} from "https://deno.land/x/superdeno@4.7.1/mod.ts"; diff --git a/version.ts b/version.ts index 63b4dd96..d2b941f4 100644 --- a/version.ts +++ b/version.ts @@ -1,9 +1,9 @@ /** * Version of Opine. */ -export const VERSION = "2.0.0"; +export const VERSION = "2.0.1"; /** * Supported version of Deno. */ -export const DENO_SUPPORTED_VERSIONS: string[] = ["1.16.3"]; +export const DENO_SUPPORTED_VERSIONS: string[] = ["1.17.1"];