Skip to content

Commit

Permalink
chore: update to std 0.211.0, commons 0.4.0, dnt 0.39.0
Browse files Browse the repository at this point in the history
kitsonk committed Jan 11, 2024
1 parent aad4908 commit 494aa7b
Showing 21 changed files with 77 additions and 508 deletions.
4 changes: 2 additions & 2 deletions _build_npm.ts
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
* @module
*/

import { build, emptyDir } from "https://deno.land/x/dnt@0.38.1/mod.ts";
import { copy } from "https://deno.land/std@0.200.0/fs/copy.ts";
import { build, emptyDir } from "https://deno.land/x/dnt@0.39.0/mod.ts";
import { copy } from "https://deno.land/std@0.211.0/fs/copy.ts";

async function start() {
await emptyDir("./npm");
16 changes: 0 additions & 16 deletions bundle_test.ts

This file was deleted.

4 changes: 2 additions & 2 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@
"coverage": "deno coverage --unstable --lcov ./cov",
"example": "deno run --unstable --allow-net examples/echoServer.ts",
"test": "deno test --import-map import-map.json --allow-read --allow-write --allow-net --parallel --ignore=npm,http_server_native_unstable_test.ts",
"test:bundle": "deno bundle --import-map import-map.json mod.ts oak.bundle.js",
"test:no-check": "deno test --import-map import-map.json --allow-read --allow-write --allow-net --no-check --parallel --ignore=npm,http_server_native_unstable_test.ts",
"test:unstable": "deno test --coverage=./cov --import-map import-map.json --allow-read --allow-write --allow-net --unstable --cert ./examples/tls/RootCA.crt --parallel --ignore=npm"
}
},
"lock": false
}
416 changes: 0 additions & 416 deletions deno.lock

This file was deleted.

75 changes: 36 additions & 39 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -4,71 +4,44 @@

// `std` dependencies

export {
type Deferred,
deferred,
} from "https://deno.land/std@0.200.0/async/deferred.ts";
export {
concat,
copy as copyBytes,
equals,
} from "https://deno.land/std@0.200.0/bytes/mod.ts";
export { timingSafeEqual } from "https://deno.land/std@0.200.0/crypto/timing_safe_equal.ts";
export { KeyStack } from "https://deno.land/std@0.200.0/crypto/keystack.ts";
export * as base64 from "https://deno.land/std@0.200.0/encoding/base64.ts";
} from "https://deno.land/std@0.211.0/bytes/mod.ts";
export { timingSafeEqual } from "https://deno.land/std@0.211.0/crypto/timing_safe_equal.ts";
export { KeyStack } from "https://deno.land/std@0.211.0/crypto/unstable_keystack.ts";
export { encodeBase64 } from "https://deno.land/std@0.211.0/encoding/base64.ts";
export {
mergeHeaders,
SecureCookieMap,
type SecureCookieMapGetOptions,
type SecureCookieMapSetDeleteOptions,
} from "https://deno.land/std@0.200.0/http/cookie_map.ts";
export {
createHttpError,
errors,
HttpError,
type HttpErrorOptions,
isHttpError,
} from "https://deno.land/std@0.200.0/http/http_errors.ts";
export {
type ErrorStatus,
isErrorStatus,
isRedirectStatus,
type RedirectStatus,
Status,
STATUS_TEXT,
} from "https://deno.land/std@0.200.0/http/http_status.ts";
} from "https://deno.land/std@0.211.0/http/unstable_cookie_map.ts";
export {
calculate,
type ETagOptions,
type FileInfo,
ifMatch,
ifNoneMatch,
} from "https://deno.land/std@0.200.0/http/etag.ts";
export { type HttpMethod as HTTPMethods } from "https://deno.land/std@0.200.0/http/method.ts";
} from "https://deno.land/std@0.211.0/http/etag.ts";
export {
accepts,
acceptsEncodings,
acceptsLanguages,
} from "https://deno.land/std@0.200.0/http/negotiation.ts";
export {
ServerSentEvent,
type ServerSentEventInit,
ServerSentEventStreamTarget,
type ServerSentEventTarget,
type ServerSentEventTargetOptions,
} from "https://deno.land/std@0.200.0/http/server_sent_event.ts";
export { UserAgent } from "https://deno.land/std@0.200.0/http/user_agent.ts";
export { LimitedReader } from "https://deno.land/std@0.200.0/io/mod.ts";
} from "https://deno.land/std@0.211.0/http/negotiation.ts";
export { UserAgent } from "https://deno.land/std@0.211.0/http/user_agent.ts";
export { LimitedReader } from "https://deno.land/std@0.211.0/io/mod.ts";
export {
contentType,
extension,
typeByExtension,
} from "https://deno.land/std@0.200.0/media_types/mod.ts";
} from "https://deno.land/std@0.211.0/media_types/mod.ts";
export {
readAll,
readerFromStreamReader,
writeAll,
} from "https://deno.land/std@0.200.0/streams/mod.ts";
} from "https://deno.land/std@0.211.0/streams/mod.ts";
export {
basename,
extname,
@@ -77,10 +50,34 @@ export {
normalize,
parse,
SEP,
} from "https://deno.land/std@0.200.0/path/mod.ts";
} from "https://deno.land/std@0.211.0/path/mod.ts";

// 3rd party dependencies

export {
createHttpError,
errors,
HttpError,
type HttpErrorOptions,
isHttpError,
} from "https://deno.land/x/oak_commons@0.4.0/http_errors.ts";
export { type HttpMethod as HTTPMethods } from "https://deno.land/x/oak_commons@0.4.0/method.ts";
export {
ServerSentEvent,
type ServerSentEventInit,
ServerSentEventStreamTarget,
type ServerSentEventTarget,
type ServerSentEventTargetOptions,
} from "https://deno.land/x/oak_commons@0.4.0/server_sent_event.ts";
export {
type ErrorStatus,
isErrorStatus,
isRedirectStatus,
type RedirectStatus,
Status,
STATUS_TEXT,
} from "https://deno.land/x/oak_commons@0.4.0/status.ts";

export {
compile,
type Key,
2 changes: 1 addition & 1 deletion examples/closeServer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
cyan,
green,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import { Application, Context, Router, Status } from "../mod.ts";

2 changes: 1 addition & 1 deletion examples/cookieServer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
cyan,
green,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import { Application } from "../mod.ts";

2 changes: 1 addition & 1 deletion examples/countingServer.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import {
cyan,
green,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import {
Application,
2 changes: 1 addition & 1 deletion examples/httpsServer.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import {
cyan,
green,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import { Application } from "../mod.ts";

2 changes: 1 addition & 1 deletion examples/proxyServer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
green,
red,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import { Application, HttpError, proxy, Status } from "../mod.ts";

4 changes: 2 additions & 2 deletions examples/readerServer.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@
*/

// Importing some console colors
import { bold, yellow } from "https://deno.land/std@0.200.0/fmt/colors.ts";
import { StringReader } from "https://deno.land/std@0.200.0/io/string_reader.ts";
import { bold, yellow } from "https://deno.land/std@0.211.0/fmt/colors.ts";
import { StringReader } from "https://deno.land/std@0.211.0/io/string_reader.ts";

import { Application } from "../mod.ts";

2 changes: 1 addition & 1 deletion examples/routingServer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
cyan,
green,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import {
Application,
2 changes: 1 addition & 1 deletion examples/server.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import {
cyan,
green,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import { Application } from "../mod.ts";

2 changes: 1 addition & 1 deletion examples/sseServer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
cyan,
green,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import {
Application,
2 changes: 1 addition & 1 deletion examples/staticServer.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import {
green,
red,
yellow,
} from "https://deno.land/std@0.200.0/fmt/colors.ts";
} from "https://deno.land/std@0.211.0/fmt/colors.ts";

import { Application, HttpError, Status } from "../mod.ts";

16 changes: 11 additions & 5 deletions http_server_native_unstable_test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// Copyright 2018-2023 the oak authors. All rights reserved. MIT license.

import { type Deferred, deferred } from "./deps.ts";
import { assertEquals, unreachable } from "./test_deps.ts";

import { HttpServer } from "./http_server_native.ts";

import { Application } from "./application.ts";
import { isNode } from "./util.ts";

type Deferred<T> = {
promise: Promise<T>;
resolve: (value: T | PromiseLike<T>) => void;
// deno-lint-ignore no-explicit-any
reject: (reason?: any) => void;
};

Deno.test({
name:
"HttpServer should not handle requests sequentially when dealing with connections over H2",
@@ -28,10 +34,10 @@ Deno.test({
const requestCount = 1024;
const requestDeferreds: Array<Deferred<void>> = [
...new Array(requestCount),
].map(() => deferred<void>());
].map(() => Promise.withResolvers<void>());
const responseDeferreds: Array<Deferred<void>> = [
...new Array(requestCount),
].map(() => deferred<void>());
].map(() => Promise.withResolvers<void>());
const requestHandlers: Array<
(nativeRequest: unknown) => Promise<void>
> = [];
@@ -51,7 +57,7 @@ Deno.test({

if (i + 1 < requestCount) {
for (let j = requestCount; j > i; j--) {
await responseDeferreds[j];
await responseDeferreds[j]?.promise;
}
}

@@ -76,7 +82,7 @@ Deno.test({
// Don't make next request until sure server has received it
// so we can later assert on order of response compared with
// order of request.
await requestDeferreds[i];
await requestDeferreds[i]?.promise;
}

const results = await Promise.all(responsePromises);
2 changes: 1 addition & 1 deletion range.ts
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@ export class MultiPartStream extends ReadableStream<Uint8Array> {
const rangeHeader = encoder.encode(
`Content-Range: ${range.start}-${range.end}/${size}\n\n`,
);
controller.enqueue(concat(this.#preamble, rangeHeader, bytes));
controller.enqueue(concat([this.#preamble, rangeHeader, bytes]));
},
});

4 changes: 2 additions & 2 deletions range_test.ts
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ test({
parts.push(part);
}
const decoder = new TextDecoder();
const actual = decoder.decode(concat(...parts));
const actual = decoder.decode(concat(parts));
assertEquals(
actual,
"\n--test_boundary\nContent-Type: text/plain; charset=UTF-8\nContent-Range: 0-5/10\n\nhello \n--test_boundary\nContent-Type: text/plain; charset=UTF-8\nContent-Range: 6-9/10\n\ndeno\n--test_boundary--\n",
@@ -185,7 +185,7 @@ test({
parts.push(part);
}
const decoder = new TextDecoder();
const actual = decoder.decode(concat(...parts));
const actual = decoder.decode(concat(parts));
assertEquals(
actual,
"\n--test_boundary\nContent-Type: text/plain; charset=UTF-8\nContent-Range: 0-5/10\n\nhello \n--test_boundary\nContent-Type: text/plain; charset=UTF-8\nContent-Range: 6-9/10\n\ndeno\n--test_boundary--\n",
2 changes: 1 addition & 1 deletion request.ts
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ export class Request {
/** An object representing the requesting user agent. If the `User-Agent`
* header isn't defined in the request, all the properties will be undefined.
*
* See [std/http/user_agent#UserAgent](https://deno.land/std@0.200.0/http/user_agent.ts?s=UserAgent)
* See [std/http/user_agent#UserAgent](https://deno.land/std@0.211.0/http/user_agent.ts?s=UserAgent)
* for more information.
*/
get userAgent(): UserAgent {
20 changes: 9 additions & 11 deletions test_deps.ts
Original file line number Diff line number Diff line change
@@ -5,14 +5,12 @@ export {
BufWriter,
StringReader,
StringWriter,
} from "https://deno.land/std@0.200.0/io/mod.ts";
export { writeAllSync } from "https://deno.land/std@0.200.0/streams/mod.ts";
export {
assert,
assertEquals,
assertInstanceOf,
assertRejects,
assertStrictEquals,
assertThrows,
unreachable,
} from "https://deno.land/std@0.200.0/testing/asserts.ts";
} from "https://deno.land/std@0.211.0/io/mod.ts";
export { writeAllSync } from "https://deno.land/std@0.211.0/streams/mod.ts";
export { assert } from "https://deno.land/std@0.211.0/assert/assert.ts";
export { assertEquals } from "https://deno.land/std@0.211.0/assert/assert_equals.ts";
export { assertInstanceOf } from "https://deno.land/std@0.211.0/assert/assert_instance_of.ts";
export { assertRejects } from "https://deno.land/std@0.211.0/assert/assert_rejects.ts";
export { assertStrictEquals } from "https://deno.land/std@0.211.0/assert/assert_strict_equals.ts";
export { assertThrows } from "https://deno.land/std@0.211.0/assert/assert_throws.ts";
export { unreachable } from "https://deno.land/std@0.211.0/assert/unreachable.ts";
4 changes: 2 additions & 2 deletions util.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
import type { State } from "./application.ts";
import type { Context } from "./context.ts";
import {
base64,
createHttpError,
encodeBase64,
isAbsolute,
join,
normalize,
@@ -378,7 +378,7 @@ const replacements: Record<string, string> = {
const encoder = new TextEncoder();

export function encodeBase64Safe(data: string | ArrayBuffer): string {
return base64.encode(data).replace(/\/|\+|=/g, (c) => replacements[c]);
return encodeBase64(data).replace(/\/|\+|=/g, (c) => replacements[c]);
}

export function isNode(): boolean {

0 comments on commit 494aa7b

Please sign in to comment.