From 798904b0f2ed0c7284b67bba2f125f406b5850de Mon Sep 17 00:00:00 2001 From: Samrith Shankar Date: Fri, 20 Mar 2020 14:38:34 +0100 Subject: Add require-await lint rule (#4401) --- std/http/file_server.ts | 10 +++++----- std/http/io.ts | 4 ++-- std/http/mock.ts | 8 ++++---- std/http/server_test.ts | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'std/http') diff --git a/std/http/file_server.ts b/std/http/file_server.ts index 18a68aa49..20d5d61e6 100755 --- a/std/http/file_server.ts +++ b/std/http/file_server.ts @@ -158,17 +158,17 @@ async function serveDir( return res; } -async function serveFallback(req: ServerRequest, e: Error): Promise { +function serveFallback(req: ServerRequest, e: Error): Promise { if (e instanceof Deno.errors.NotFound) { - return { + return Promise.resolve({ status: 404, body: encoder.encode("Not found") - }; + }); } else { - return { + return Promise.resolve({ status: 500, body: encoder.encode("Internal server error") - }; + }); } } diff --git a/std/http/io.ts b/std/http/io.ts index 5518146a8..6d5d1f665 100644 --- a/std/http/io.ts +++ b/std/http/io.ts @@ -7,8 +7,8 @@ import { STATUS_TEXT } from "./http_status.ts"; export function emptyReader(): Deno.Reader { return { - async read(_: Uint8Array): Promise { - return Deno.EOF; + read(_: Uint8Array): Promise { + return Promise.resolve(Deno.EOF); } }; } diff --git a/std/http/mock.ts b/std/http/mock.ts index 3a4eeed82..cee697bed 100644 --- a/std/http/mock.ts +++ b/std/http/mock.ts @@ -14,11 +14,11 @@ export function mockConn(base: Partial = {}): Deno.Conn { rid: -1, closeRead: (): void => {}, closeWrite: (): void => {}, - read: async (): Promise => { - return 0; + read: (): Promise => { + return Promise.resolve(0); }, - write: async (): Promise => { - return -1; + write: (): Promise => { + return Promise.resolve(-1); }, close: (): void => {}, ...base diff --git a/std/http/server_test.ts b/std/http/server_test.ts index 0a4986dcf..2a7c46134 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -68,7 +68,7 @@ test(async function responseWrite(): Promise { } }); -test(async function requestContentLength(): Promise { +test(function requestContentLength(): void { // Has content length { const req = new ServerRequest(); -- cgit v1.2.3