Skip to content

Commit

Permalink
fix: 2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cmorten committed Apr 16, 2023
1 parent b36b4be commit 1417cd5
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/API/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].3/mod.ts";
import opine from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();
const PORT = 3000;
Expand All @@ -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/[email protected].3/mod.ts";
import opine from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand All @@ -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/[email protected].3/mod.ts";
import opine from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand Down
8 changes: 4 additions & 4 deletions .github/API/middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].3/mod.ts";
import { json, opine } from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand Down Expand Up @@ -77,7 +77,7 @@ reasons.
> recommended.
```ts
import { opine, raw } from "https://deno.land/x/[email protected].3/mod.ts";
import { opine, raw } from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand Down Expand Up @@ -230,7 +230,7 @@ reasons.
> recommended.
```ts
import { opine, text } from "https://deno.land/x/[email protected].3/mod.ts";
import { opine, text } from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand Down Expand Up @@ -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/[email protected].3/mod.ts";
import { opine, urlencoded } from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand Down
4 changes: 2 additions & 2 deletions .github/API/opine.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ 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/[email protected].3/mod.ts";
import opine from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();
```

The `opine()` function is also exported as a named export:

```ts
import { opine } from "https://deno.land/x/[email protected].3/mod.ts";
import { opine } from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();
```
4 changes: 2 additions & 2 deletions .github/API/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import {
json,
opine,
urlencoded,
} from "https://deno.land/x/[email protected].3/mod.ts";
} from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand All @@ -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/[email protected].3/mod.ts";
import opine from "https://deno.land/x/[email protected].4/mod.ts";

import { readAll } from "https://deno.land/[email protected]/streams/conversion.ts";

Expand Down
4 changes: 2 additions & 2 deletions .github/API/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].3/mod.ts";
import { Router } from "https://deno.land/x/[email protected].4/mod.ts";

const router = Router(options);
```
Expand Down Expand Up @@ -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/[email protected].3/mod.ts";
import opine, { Router } from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();
const router = Router();
Expand Down
5 changes: 5 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ChangeLog

## [2.3.4] - 16-04-2023

- fix: derive protocol from original request url.
- deps: support Deno `1.32.4`, std `0.183.0` (where possible), and other minor dep upgrades.

## [2.3.3] - 27-08-2022

- fix: support `ReadableStream` in `res.send()`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- uses: denolib/setup-deno@v2
with:
deno-version: 1.25.0
deno-version: 1.32.4
- run: |
mkdir -p artifacts
cat > artifacts/message.md <<EOF
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- run: make deps
- uses: denolib/setup-deno@v2
with:
deno-version: 1.25.0
deno-version: 1.32.4
- run: make typedoc
- run: make ci
- uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-egg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- uses: denolib/setup-deno@v2
with:
deno-version: 1.25.0
deno-version: 1.32.4
- run: deno install -A -f --unstable -n eggs https://x.nest.land/[email protected]/eggs.ts
- run: |
export PATH="/home/runner/.deno/bin:$PATH"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
deno-version: [1.25.0]
deno-version: [1.32.4]

runs-on: ${{ matrix.os }}

Expand All @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
deno-version: [1.25.0]
deno-version: [1.32.4]

runs-on: ${{ matrix.os }}

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A minimalist web framework for <a href="https://deno.land/">Deno</a> ported from
</p>
<p align="center">
<a href="https://deno.land/x/opine"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fopine%2Fmod.ts" alt="Opine latest /x/ version" /></a>
<a href="https://github.com/denoland/deno/blob/main/Releases.md"><img src="https://img.shields.io/badge/deno-1.25.0-brightgreen?logo=deno" alt="Minimum supported Deno version" /></a>
<a href="https://github.com/denoland/deno/blob/main/Releases.md"><img src="https://img.shields.io/badge/deno-1.32.4-brightgreen?logo=deno" alt="Minimum supported Deno version" /></a>
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fdep-count%2Fx%2Fopine%2Fmod.ts" alt="Opine dependency count" /></a>
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fupdates%2Fx%2Fopine%2Fmod.ts" alt="Opine dependency outdatedness" /></a>
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fcache-size%2Fx%2Fopine%2Fmod.ts" alt="Opine cached size" /></a>
Expand Down Expand Up @@ -52,7 +52,7 @@ Express not working for you? [Raise an issue on Deno](https://github.com/denolan
## Getting Started

```ts
import { opine } from "https://deno.land/x/[email protected].3/mod.ts";
import { opine } from "https://deno.land/x/[email protected].4/mod.ts";

const app = opine();

Expand All @@ -75,14 +75,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/[email protected].3/mod.ts";
import { opine } from "https://deno.land/x/[email protected].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/[email protected].3/mod.ts";
import { opine } from "https://x.nest.land/[email protected].4/mod.ts";
```

## Features
Expand Down
22 changes: 11 additions & 11 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ export {
serve,
Server,
serveTls,
} from "https://deno.land/std@0.153.0/http/server.ts";
export type { ConnInfo } from "https://deno.land/std@0.153.0/http/server.ts";
} from "https://deno.land/std@0.183.0/http/server.ts";
export type { ConnInfo } from "https://deno.land/std@0.183.0/http/server.ts";
export {
Status,
STATUS_TEXT,
} from "https://deno.land/std@0.153.0/http/http_status.ts";
} from "https://deno.land/std@0.183.0/http/http_status.ts";
export {
deleteCookie,
setCookie,
} from "https://deno.land/std@0.153.0/http/cookie.ts";
export type { Cookie } from "https://deno.land/std@0.153.0/http/cookie.ts";
} from "https://deno.land/std@0.183.0/http/cookie.ts";
export type { Cookie } from "https://deno.land/std@0.183.0/http/cookie.ts";
export {
basename,
dirname,
Expand All @@ -23,16 +23,16 @@ export {
normalize,
resolve,
sep,
} from "https://deno.land/std@0.153.0/path/mod.ts";
export { setImmediate } from "https://deno.land/std@0.153.0/node/timers.ts";
export { parse } from "https://deno.land/std@0.153.0/node/querystring.ts";
export { default as EventEmitter } from "https://deno.land/std@0.153.0/node/events.ts";
export { Sha1 } from "https://deno.land/std@0.153.0/hash/sha1.ts";
} from "https://deno.land/std@0.183.0/path/mod.ts";
export { setImmediate } from "https://deno.land/std@0.177.0/node/timers.ts";
export { parse } from "https://deno.land/std@0.177.0/node/querystring.ts";
export { default as EventEmitter } from "https://deno.land/std@0.177.0/node/events.ts";
export { Sha1 } from "https://deno.land/std@0.160.0/hash/sha1.ts";
export {
readableStreamFromReader,
readAll,
readerFromStreamReader,
} from "https://deno.land/std@0.153.0/streams/conversion.ts";
} from "https://deno.land/std@0.172.0/streams/conversion.ts";

export {
charset,
Expand Down
8 changes: 4 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h1 align="center">Opine</h1>
</p>
<p align="center">
<a href="https://deno.land/x/opine"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fopine%2Fmod.ts" alt="Opine latest /x/ version" /></a>
<a href="https://github.com/denoland/deno/blob/main/Releases.md"><img src="https://img.shields.io/badge/deno-1.25.0-brightgreen?logo=deno" alt="Minimum supported Deno version" /></a>
<a href="https://github.com/denoland/deno/blob/main/Releases.md"><img src="https://img.shields.io/badge/deno-1.32.4-brightgreen?logo=deno" alt="Minimum supported Deno version" /></a>
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fdep-count%2Fx%2Fopine%2Fmod.ts" alt="Opine dependency count" /></a>
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fupdates%2Fx%2Fopine%2Fmod.ts" alt="Opine dependency outdatedness" /></a>
<a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fcache-size%2Fx%2Fopine%2Fmod.ts" alt="Opine cached size" /></a>
Expand Down Expand Up @@ -111,7 +111,7 @@ <h2>Table of Contents</h2>
<a href="#getting-started" id="getting-started" style="color: inherit; text-decoration: none;">
<h2>Getting Started</h2>
</a>
<pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/[email protected].3/mod.ts&quot;</span>;
<pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/[email protected].4/mod.ts&quot;</span>;

<span class="hljs-keyword">const</span> app = opine();

Expand All @@ -130,11 +130,11 @@ <h2>Installation</h2>
repo and via the <a href="https://deno.land/x">Deno Registry</a>.</p>
<p>Before importing, <a href="https://deno.land/#installation">download and install Deno</a>.</p>
<p>You can then import Opine straight into your project:</p>
<pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/[email protected].3/mod.ts&quot;</span>;
<pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/[email protected].4/mod.ts&quot;</span>;
</code></pre>
<p>Opine is also available on <a href="https://nest.land/package/opine">nest.land</a>, a
package registry for Deno on the Blockchain.</p>
<pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://x.nest.land/[email protected].3/mod.ts&quot;</span>;
<pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://x.nest.land/[email protected].4/mod.ts&quot;</span>;
</code></pre>
<a href="#features" id="features" style="color: inherit; text-decoration: none;">
<h2>Features</h2>
Expand Down
2 changes: 1 addition & 1 deletion egg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opine",
"description": "Minimalist web framework for Deno ported from ExpressJS.",
"version": "2.3.3",
"version": "2.3.4",
"repository": "https://github.com/cmorten/opine",
"stable": true,
"checkFormat": false,
Expand Down
13 changes: 12 additions & 1 deletion src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ export class WrappedRequest implements OpineRequest {
this.#responsePromiseResolver = resolve;
});

this.url = request.url;
this.proto = parseUrl(this)?.protocol ?? "";

const { pathname, search, hash } = new URL(request.url);
this.url = `${pathname}${search}${hash}`;
this.proto = parseUrl(this)?.protocol ?? "";
this.method = request.method;
this.headers = new Headers(this.#request.headers);
}
Expand Down Expand Up @@ -300,14 +302,23 @@ export class WrappedRequest implements OpineRequest {
return typeofrequest(this.headers, arr as string[]);
}

/**
* Upgrades the HTTP connection to a WebSocket connection by internally calling
* `Deno.upgradeWebSocket(req)`. Returns the created WebSocket.
*
* @returns {WebSocket} The created WebSocket
* @public
*/
upgrade(): WebSocket {
const { socket, response } = Deno.upgradeWebSocket(this.#request);
this.#responsePromiseResolver(response);

return socket;
}

get #body() {
const streamReader = this.#request.body?.getReader();

return streamReader ? readerFromStreamReader(streamReader) : emptyReader();
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/compileTrust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function compileTrust(value: TrustValue) {
if (typeof value === "number") {
// Support trusting hop count
return function (_: unknown, i: number) {
return i < value;
return i < (value as number);
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/createError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class HttpError extends Error {
status: number;
statusCode: number;
expose = false;
[key: string]: unknown
[key: string]: unknown;

constructor(code: number, message?: string) {
super(message);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/forwarded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ function parse(header: string) {
// gather addresses, backwards
for (let i = header.length - 1; i >= 0; i--) {
switch (header.charCodeAt(i)) {
case 0x20:/* */
case 0x20: /* */
if (start === end) {
start = end = i;
}

break;
case 0x2c:/* , */
case 0x2c: /* , */
if (start !== end) {
list.push(header.substring(start, end));
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/fresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ export function parseTokenList(str: string): any[] {
// gather tokens
for (let i = 0, len = str.length; i < len; i++) {
switch (str.charCodeAt(i)) {
case 0x20:/* */
case 0x20: /* */
if (start === end) {
start = end = i + 1;
}
break;
case 0x2c:/* , */
case 0x2c: /* , */
list.push(str.substring(start, end));
start = end = i + 1;
break;
Expand Down
Loading

0 comments on commit 1417cd5

Please sign in to comment.