From 17377d6a98b85a4be41bd0b53b9430535c4ba112 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Fri, 19 Feb 2021 17:22:21 +0100 Subject: [PATCH] use deps.ts --- src/.gitignore => .gitignore | 0 cli.ts | 2 +- deps.ts | 7 +++++++ server.ts | 4 +++- src/repositories/locales.test.ts | 2 +- src/types/id.test.ts | 2 +- src/usecases/hello.test.ts | 4 ++-- 7 files changed, 15 insertions(+), 6 deletions(-) rename src/.gitignore => .gitignore (100%) create mode 100644 deps.ts diff --git a/src/.gitignore b/.gitignore similarity index 100% rename from src/.gitignore rename to .gitignore diff --git a/cli.ts b/cli.ts index 8538b2f..7f2ff94 100644 --- a/cli.ts +++ b/cli.ts @@ -1,4 +1,4 @@ -import { readLines } from "https://deno.land/std@0.87.0/io/bufio.ts"; +import { readLines } from "./deps.ts"; import { ID, sayHello, sayRandomHello, ValidationError } from "./src/index.ts"; const start = async () => { diff --git a/deps.ts b/deps.ts new file mode 100644 index 0000000..bcc504b --- /dev/null +++ b/deps.ts @@ -0,0 +1,7 @@ +export { + assert, + assertStrictEquals, + assertThrows, +} from "https://deno.land/std@0.87.0/testing/asserts.ts"; +export { readLines } from "https://deno.land/std@0.87.0/io/bufio.ts"; +export { listenAndServe } from "https://deno.land/std@0.87.0/http/server.ts"; diff --git a/server.ts b/server.ts index 9083954..bc478c1 100644 --- a/server.ts +++ b/server.ts @@ -1,6 +1,8 @@ -import { listenAndServe } from "https://deno.land/std@0.87.0/http/server.ts"; +import { listenAndServe } from "./deps.ts"; const port = 8000; console.log(`Server listening on http://localhost:${port}/`); await listenAndServe({ port }, (req) => req.respond({ body: "Hello" })); + +// write handler using req.url diff --git a/src/repositories/locales.test.ts b/src/repositories/locales.test.ts index ea5e9d2..c71657a 100644 --- a/src/repositories/locales.test.ts +++ b/src/repositories/locales.test.ts @@ -1,4 +1,4 @@ -import { assertStrictEquals } from "https://deno.land/std@0.87.0/testing/asserts.ts"; +import { assertStrictEquals } from "../../deps.ts"; import { getLocaleById } from "./locales.ts"; Deno.test("Get locale by id", () => { diff --git a/src/types/id.test.ts b/src/types/id.test.ts index 915c880..5623ed9 100644 --- a/src/types/id.test.ts +++ b/src/types/id.test.ts @@ -1,4 +1,4 @@ -import { assertThrows } from "https://deno.land/std@0.87.0/testing/asserts.ts"; +import { assertThrows } from "../../deps.ts"; import { ValidationError } from "../errors/exceptions.ts"; import { ID } from "./id.ts"; diff --git a/src/usecases/hello.test.ts b/src/usecases/hello.test.ts index 859f468..f1ae587 100644 --- a/src/usecases/hello.test.ts +++ b/src/usecases/hello.test.ts @@ -1,6 +1,6 @@ -import { assertStrictEquals } from "https://deno.land/std@0.87.0/testing/asserts.ts"; -import { sayHello, sayRandomHello } from "./hello.ts"; +import { assertStrictEquals } from "../../deps.ts"; import { ID } from "../types/id.ts"; +import { sayHello, sayRandomHello } from "./hello.ts"; Deno.test("Random Hello", () => { const result = sayRandomHello();