From 7a571f0a22074db89e8c0a6259dbc3a60e671d90 Mon Sep 17 00:00:00 2001 From: syumai Date: Sat, 14 Aug 2021 11:18:47 +0900 Subject: [PATCH 1/2] Release 0.15.0 --- README.md | 2 +- dem.json | 2 +- response.ts | 11 ++++++----- serve_test.ts | 4 ++-- vendor/https/deno.land/std/encoding/utf8.ts | 2 +- vendor/https/deno.land/std/flags/mod.ts | 2 +- vendor/https/deno.land/std/http/server.ts | 2 +- vendor/https/deno.land/std/testing/asserts.ts | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1c3bf23..3264d6b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ import { post, redirect, contentType, -} from "https://denopkg.com/syumai/dinatra@0.14.0/mod.ts"; +} from "https://denopkg.com/syumai/dinatra@0.15.0/mod.ts"; app( get("/hello", () => "hello"), diff --git a/dem.json b/dem.json index 7791bb1..4663b3f 100644 --- a/dem.json +++ b/dem.json @@ -3,7 +3,7 @@ { "protocol": "https", "path": "deno.land/std", - "version": "0.73.0", + "version": "0.104.0", "files": [ "/encoding/utf8.ts", "/flags/mod.ts", diff --git a/response.ts b/response.ts index e25ad02..b11602f 100644 --- a/response.ts +++ b/response.ts @@ -1,12 +1,13 @@ -import { encode } from "./vendor/https/deno.land/std/encoding/utf8.ts"; import { ReadCloser } from "./io.ts"; +const encoder = new TextEncoder(); + // HeaderMap is a type of response headers. type HeaderMap = | Headers | { - [key: string]: any; - }; + [key: string]: any; + }; // ResponseBody is a type of response body. type ResponseBody = string | ReadCloser | Deno.Reader; @@ -56,7 +57,7 @@ export function processResponse(res: Response): HTTPResponse { let body: Uint8Array | ReadCloser | Deno.Reader; if (typeof rawBody === "string") { - body = encode(rawBody); + body = encoder.encode(rawBody); } else { body = rawBody; } @@ -69,7 +70,7 @@ export function processResponse(res: Response): HTTPResponse { } function isStatusHeadersBodyResponse( - res: Response, + res: Response ): res is StatusHeadersBodyResponse { const r = res as StatusHeadersBodyResponse; return Array.isArray(r) && r.length === 3; diff --git a/serve_test.ts b/serve_test.ts index e35b4cf..9e51ce1 100644 --- a/serve_test.ts +++ b/serve_test.ts @@ -54,7 +54,7 @@ const testCases: Array = [ name: "valid basic handler with path parameters", registered: get( "/parameters/:param1/:param2", - ({ params }) => `${params.param1} ${params.param2}`, + ({ params }) => `${params.param1} ${params.param2}` ), path: "parameters/p1/p2", method: Method.GET, @@ -134,7 +134,7 @@ for (const tc of testCases) { const contentLength = res.headers.get("content-length"); assertEquals(actual, tc.expected); - assertEquals(contentLength, tc.expected.length.toString()); + assertEquals(contentLength, new Blob([tc.expected]).size.toString()); const { path, method } = tc.registered; app.unregister(path, method); diff --git a/vendor/https/deno.land/std/encoding/utf8.ts b/vendor/https/deno.land/std/encoding/utf8.ts index e5e3dcc..82ab848 100644 --- a/vendor/https/deno.land/std/encoding/utf8.ts +++ b/vendor/https/deno.land/std/encoding/utf8.ts @@ -1 +1 @@ -export * from "https://deno.land/std@0.73.0/encoding/utf8.ts"; +export * from "https://deno.land/std@0.104.0/encoding/utf8.ts"; diff --git a/vendor/https/deno.land/std/flags/mod.ts b/vendor/https/deno.land/std/flags/mod.ts index 68d33d9..c51a80d 100644 --- a/vendor/https/deno.land/std/flags/mod.ts +++ b/vendor/https/deno.land/std/flags/mod.ts @@ -1 +1 @@ -export * from "https://deno.land/std@0.73.0/flags/mod.ts"; +export * from "https://deno.land/std@0.104.0/flags/mod.ts"; diff --git a/vendor/https/deno.land/std/http/server.ts b/vendor/https/deno.land/std/http/server.ts index d4ea2a8..ebc8f45 100644 --- a/vendor/https/deno.land/std/http/server.ts +++ b/vendor/https/deno.land/std/http/server.ts @@ -1 +1 @@ -export * from "https://deno.land/std@0.73.0/http/server.ts"; +export * from "https://deno.land/std@0.104.0/http/server.ts"; diff --git a/vendor/https/deno.land/std/testing/asserts.ts b/vendor/https/deno.land/std/testing/asserts.ts index b01b5cd..668cecb 100644 --- a/vendor/https/deno.land/std/testing/asserts.ts +++ b/vendor/https/deno.land/std/testing/asserts.ts @@ -1 +1 @@ -export * from "https://deno.land/std@0.73.0/testing/asserts.ts"; +export * from "https://deno.land/std@0.104.0/testing/asserts.ts"; From 392cd3eb62cc5a5263e55469a9c9a6685873198b Mon Sep 17 00:00:00 2001 From: syumai Date: Sat, 14 Aug 2021 11:28:32 +0900 Subject: [PATCH 2/2] fmt --- Makefile | 2 +- response.ts | 6 +++--- serve_test.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 21a64b7..93fdefb 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SHELL=/bin/bash +SHELL=/usr/bin/env bash TARGET_SRC=$(shell shopt -s globstar && ls ./**/*.{ts,js,tsx} | grep -v ./vendor | grep -v ./testdata) test: diff --git a/response.ts b/response.ts index b11602f..f247bd1 100644 --- a/response.ts +++ b/response.ts @@ -6,8 +6,8 @@ const encoder = new TextEncoder(); type HeaderMap = | Headers | { - [key: string]: any; - }; + [key: string]: any; + }; // ResponseBody is a type of response body. type ResponseBody = string | ReadCloser | Deno.Reader; @@ -70,7 +70,7 @@ export function processResponse(res: Response): HTTPResponse { } function isStatusHeadersBodyResponse( - res: Response + res: Response, ): res is StatusHeadersBodyResponse { const r = res as StatusHeadersBodyResponse; return Array.isArray(r) && r.length === 3; diff --git a/serve_test.ts b/serve_test.ts index 9e51ce1..20080ae 100644 --- a/serve_test.ts +++ b/serve_test.ts @@ -54,7 +54,7 @@ const testCases: Array = [ name: "valid basic handler with path parameters", registered: get( "/parameters/:param1/:param2", - ({ params }) => `${params.param1} ${params.param2}` + ({ params }) => `${params.param1} ${params.param2}`, ), path: "parameters/p1/p2", method: Method.GET,