From d2e2b49c46f03a05fd2c2b1dfe17a6caa8579e7a Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Fri, 31 Jul 2020 20:22:09 +0200 Subject: [PATCH] Optimize dependency import --- registry/src/deps.ts | 2 ++ registry/src/utils.ts | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/registry/src/deps.ts b/registry/src/deps.ts index 829fc60..75ecdfb 100644 --- a/registry/src/deps.ts +++ b/registry/src/deps.ts @@ -11,6 +11,8 @@ export * as LoggerMW from "https://deno.land/x/abc@v1/middleware/logger.ts"; export * as Path from "https://deno.land/std@0.62.0/path/mod.ts"; export * as FS from "https://deno.land/std@0.62.0/fs/mod.ts"; +export * as Base64 from "https://deno.land/std@0.62.0/encoding/base64.ts"; + export * as Compress from "https://git.stamm.me/Deno/DenReg/raw/branch/master/tar/mod.ts"; export { Marked } from "https://deno.land/x/markdown/mod.ts"; diff --git a/registry/src/utils.ts b/registry/src/utils.ts index d9039d1..0b0fb03 100644 --- a/registry/src/utils.ts +++ b/registry/src/utils.ts @@ -1,5 +1,4 @@ -import { ABC } from "./deps.ts"; -import { decode } from "https://deno.land/std/encoding/base64.ts"; +import { ABC, Base64 } from "./deps.ts"; import config from "./config.ts"; const packageNameRegex = /^[@]?[a-zA-Z][\d\w\-\_]*$/g.compile(); @@ -42,7 +41,7 @@ export const basicauth = (realm: string) => (next: ABC.HandlerFunc) => ( if (value && value.toLowerCase().startsWith("basic ")) { const credentials = value.slice(6); const [username, passwd] = new TextDecoder() - .decode(decode(credentials)) + .decode(Base64.decode(credentials)) .split(":", 2); if (config?.user[username]?.password === passwd) { @@ -97,7 +96,7 @@ export async function getFile( pkgName: string, version: string | null | undefined, file: string -): Promise { +): Promise { const meta = await db.package.findOne({ name: pkgName }); if (!meta || meta.versions.length < 1) return null;