Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

BREAKING: migrate to a import map #219

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions bench/compare.ts

This file was deleted.

5 changes: 0 additions & 5 deletions bench/server.ts

This file was deleted.

6 changes: 3 additions & 3 deletions cli/cmd/bundle/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { ensureFile } from 'https://deno.land/std@0.200.0/fs/ensure_file.ts'
import { join } from 'https://deno.land/std@0.200.0/path/mod.ts'
import * as esbuild from 'https://deno.land/x/esbuild@v0.19.2/mod.js'
import { ensureFile } from 'std/fs/ensure_file.ts'
import { join } from 'std/path/mod.ts'
import * as esbuild from 'esbuild'

export async function bundle({
input = './mod.ts',
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/new/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { ensureFile } from 'https://deno.land/std@0.200.0/fs/ensure_file.ts'
import { Select } from 'https://deno.land/x/cliffy@v0.25.7/mod.ts'
import { Select } from 'cliffy'

type VSCodeSettings = {
files: string[]
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/random/create_crypto_key.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { encode } from 'https://deno.land/std@0.200.0/encoding/base64.ts'
import { encode } from 'std/encoding/base64.ts'

export async function createCryptoKey() {
const key = await crypto.subtle.generateKey(
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/random/create_jwt_secret.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { encode } from 'https://deno.land/std@0.200.0/encoding/base64.ts'
import { encode } from 'std/encoding/base64.ts'

export async function createJwtSecret() {
const key = await crypto.subtle.generateKey(
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/random/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { gray, white } from 'https://deno.land/std@0.200.0/fmt/colors.ts'
import { Select } from 'https://deno.land/x/cliffy@v0.25.7/mod.ts'
import { Select } from 'cliffy'
import { gray, white } from 'std/fmt/colors.ts'
import { createCryptoKey } from './create_crypto_key.ts'
import { createJwtSecret } from './create_jwt_secret.ts'

Expand Down
15 changes: 4 additions & 11 deletions cli/cmd/serve/mod.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { loadSync } from 'https://deno.land/std@0.200.0/dotenv/mod.ts'
import { parse } from 'https://deno.land/std@0.200.0/flags/mod.ts'
import {
brightGreen,
gray,
white,
} from 'https://deno.land/std@0.200.0/fmt/colors.ts'
import {
keypress,
KeyPressEvent,
} from 'https://deno.land/x/cliffy@v0.25.7/keypress/mod.ts'
import { keypress, KeyPressEvent } from 'cliffy/keypress'
import { loadSync } from 'std/dotenv/mod.ts'
import { parse } from 'std/flags/mod.ts'
import { brightGreen, gray, white } from 'std/fmt/colors.ts'
import { cheetah } from '../../../cheetah.ts'
import { logError } from '../../utils.ts'

Expand Down
2 changes: 1 addition & 1 deletion cli/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { parse } from 'https://deno.land/std@0.200.0/flags/mod.ts'
import { parse } from 'std/flags/mod.ts'
import { bundleCommand } from './cmd/bundle/mod.ts'
import { newCommand } from './cmd/new/mod.ts'
import { randomCommand } from './cmd/random/mod.ts'
Expand Down
2 changes: 1 addition & 1 deletion cli/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { brightRed, gray } from 'https://deno.land/std@0.200.0/fmt/colors.ts'
import { brightRed, gray } from 'std/fmt/colors.ts'

export function logError(message: string) {
console.error(gray(`${brightRed('error')} - ${message}`))
Expand Down
4 changes: 2 additions & 2 deletions context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
/// <reference types='./env.d.ts' />
import { encode } from 'https://deno.land/std@0.200.0/encoding/base64.ts'
import { ZodType } from 'https://deno.land/x/zod@v3.21.4/types.ts'
import { encode } from 'std/encoding/base64.ts'
import { ZodType } from 'zod'
import { AppContext } from './cheetah.ts'
import { ObjectType, Payload } from './handler.ts'
import { RequestContext } from './request_context.ts'
Expand Down
2 changes: 1 addition & 1 deletion crypto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { decode } from 'https://deno.land/std@0.200.0/encoding/base64.ts'
import { decode } from 'std/encoding/base64.ts'
import { Context } from './context.ts'

export async function encrypt(c: Context, message: string) {
Expand Down
31 changes: 25 additions & 6 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,31 @@
"./readme.md"
]
},
"imports": {
"authenticus": "https://deno.land/x/authenticus@v2.0.3/mod.ts",
"authenticus/preset": "https://deno.land/x/authenticus@v2.0.3/createPreset.ts",
"aws4fetch": "https://esm.sh/aws4fetch@1.0.17?target=es2022",
"brotli": "https://deno.land/x/brotli@0.1.7/mod.ts",
"cliffy": "https://deno.land/x/cliffy@v0.25.7/mod.ts",
"cliffy/keypress": "https://deno.land/x/cliffy@v0.25.7/keypress/mod.ts",
"djwt": "https://deno.land/x/djwt@v2.8/mod.ts",
"dom": "https://deno.land/x/deno_dom@v0.1.38/deno-dom-wasm.ts",
"esbuild": "https://deno.land/x/esbuild@v0.19.2/mod.js",
"foras": "https://deno.land/x/foras@2.0.8/src/deno/mod.ts",
"otpauth": "https://deno.land/x/otpauth@v9.1.4/dist/otpauth.esm.js",
"preact": "https://esm.sh/preact@10.17.1?target=es2022",
"preact/render-to-string": "https://esm.sh/preact-render-to-string@6.1.0?deps=preact@10.17.1&target=es2022",
"std/": "https://deno.land/std@0.200.0/",
"twind": "https://esm.sh/@twind/core@1.1.3",
"twind/preset-autoprefix": "https://esm.sh/@twind/preset-autoprefix@1.0.7",
"twind/preset-tailwind": "https://esm.sh/@twind/preset-tailwind@1.1.4",
"worker": "https://cdn.jsdelivr.net/npm/@cloudflare/workers-types@4.20230821.0/index.ts",
"upstash": "https://deno.land/x/upstash_redis@v1.22.0/mod.ts",
"zod": "https://deno.land/x/zod@v3.21.4/mod.ts"
},
"lock": false,
"tasks": {
"check": "deno fmt && deno lint --unstable && deno task test",
"compare": "deno run -A bench/compare.ts",
"license_year": "deno run -A .github/update_license_year.ts",
"test": "deno test -A --unstable",
"upgrade": "deno run -A https://deno.land/x/upgrade@v1.0.1/mod.ts -q"
},
"lock": false
"test": "deno test -A --unstable"
}
}
9 changes: 2 additions & 7 deletions ext/compress.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { compress as brotli } from 'https://deno.land/x/brotli@0.1.7/mod.ts'
import {
deflate,
gzip,
initBundledOnce,
InitOutput,
} from 'https://deno.land/x/foras@2.0.8/src/deno/mod.ts'
import { compress as brotli } from 'brotli'
import { deflate, gzip, initBundledOnce, InitOutput } from 'foras'
import { createExtension } from '../mod.ts'

type CompressionAlgorithm = {
Expand Down
4 changes: 2 additions & 2 deletions ext/debug.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { format } from 'https://deno.land/std@0.200.0/fmt/bytes.ts'
import { format } from 'std/fmt/bytes.ts'
import {
brightBlue,
brightGreen,
brightRed,
gray,
white,
} from 'https://deno.land/std@0.200.0/fmt/colors.ts'
} from 'std/fmt/colors.ts'
import { createExtension } from '../mod.ts'

/**
Expand Down
6 changes: 3 additions & 3 deletions ext/files.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { R2Bucket } from 'https://cdn.jsdelivr.net/npm/@cloudflare/workers-types@4.20230821.0/index.ts'
import { join } from 'https://deno.land/std@0.200.0/path/mod.ts'
import { AwsClient } from 'https://esm.sh/aws4fetch@1.0.17?target=es2022'
import { AwsClient } from 'aws4fetch'
import { join } from 'std/path/mod.ts'
import { R2Bucket } from 'worker'
import { createExtension } from '../extensions.ts'
import { AppContext } from '../mod.ts'

Expand Down
4 changes: 2 additions & 2 deletions extensions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { ZodString, ZodUnion } from 'https://deno.land/x/zod@v3.21.4/types.ts'
import { ZodString, ZodUnion } from 'zod'
import { Method } from './base.ts'
import { Handler, ObjectType } from './handler.ts'
import { AppContext, Context } from './mod.ts'
import { Method } from './base.ts'

type HasRequired<T> = Partial<T> extends T ? false : true

Expand Down
5 changes: 3 additions & 2 deletions handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { ZodTypeDef, ZodUnion } from 'https://deno.land/x/zod@v3.21.4/index.ts'
import {
ZodObject,
ZodRecord,
ZodString,
ZodType,
} from 'https://deno.land/x/zod@v3.21.4/types.ts'
ZodTypeDef,
ZodUnion,
} from 'zod'
import { Context } from './mod.ts'

export type ObjectType =
Expand Down
4 changes: 2 additions & 2 deletions jwt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { decode } from 'https://deno.land/std@0.200.0/encoding/base64.ts'
import * as Jwt from 'https://deno.land/x/djwt@v2.8/mod.ts'
import * as Jwt from 'djwt'
import { decode } from 'std/encoding/base64.ts'
import { Context } from './mod.ts'

interface Payload {
Expand Down
2 changes: 1 addition & 1 deletion location_data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { IncomingRequestCfProperties } from 'https://cdn.jsdelivr.net/npm/@cloudflare/workers-types@4.20230821.0/index.ts'
import { IncomingRequestCfProperties } from 'worker'
import { Context } from './context.ts'

type CloudflareRequest = Request & {
Expand Down
7 changes: 2 additions & 5 deletions oauth/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { Preset } from 'https://deno.land/x/authenticus@v2.0.3/createPreset.ts'
import {
GitHub as githubPreset,
Google as googlePreset,
} from 'https://deno.land/x/authenticus@v2.0.3/mod.ts'
import { GitHub as githubPreset, Google as googlePreset } from 'authenticus'
import { Preset } from 'authenticus/preset'
import { OAuthMethod } from './types.ts'

export type OAuthClient = {
Expand Down
2 changes: 1 addition & 1 deletion oauth/get_session_data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { getCookies } from 'https://deno.land/std@0.200.0/http/cookie.ts'
import { getCookies } from 'std/http/cookie.ts'
import { Context } from '../context.ts'
import { verify } from '../jwt.ts'
import { OAuthSessionData, OAuthSessionToken } from './types.ts'
Expand Down
2 changes: 1 addition & 1 deletion oauth/get_session_id.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { getCookies } from 'https://deno.land/std@0.200.0/http/cookie.ts'
import { getCookies } from 'std/http/cookie.ts'
import { Context } from '../context.ts'
import { verify } from '../jwt.ts'
import { OAuthSessionToken } from './types.ts'
Expand Down
2 changes: 1 addition & 1 deletion oauth/get_session_token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { getCookies } from 'https://deno.land/std@0.200.0/http/cookie.ts'
import { getCookies } from 'std/http/cookie.ts'
import { Context } from '../context.ts'
import { verify } from '../jwt.ts'

Expand Down
8 changes: 2 additions & 6 deletions oauth/handle_callback.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { UserAgent } from 'https://deno.land/std@0.200.0/http/user_agent.ts'
import {
getNormalizedUser,
getToken,
getUser,
} from 'https://deno.land/x/authenticus@v2.0.3/mod.ts'
import { getNormalizedUser, getToken, getUser } from 'authenticus'
import { UserAgent } from 'std/http/user_agent.ts'
import { Context } from '../context.ts'
import { sign, verify } from '../jwt.ts'
import { LocationData } from '../location_data.ts'
Expand Down
2 changes: 1 addition & 1 deletion oauth/sign_in.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { createAuthorizeUrl } from 'https://deno.land/x/authenticus@v2.0.3/mod.ts'
import { createAuthorizeUrl } from 'authenticus'
import { Context } from '../context.ts'
import { sign } from '../jwt.ts'
import { OAuthClient } from './client.ts'
Expand Down
4 changes: 2 additions & 2 deletions oauth/store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { KVNamespace } from 'https://cdn.jsdelivr.net/npm/@cloudflare/workers-types@4.20230821.0/index.ts'
import { Redis } from 'https://deno.land/x/upstash_redis@v1.22.0/mod.ts'
import { Redis } from 'upstash'
import { KVNamespace } from 'worker'
import { Context } from '../context.ts'
import { OAuthSessionData } from './types.ts'

Expand Down
2 changes: 1 addition & 1 deletion oauth/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { UserAgent } from 'https://deno.land/std@0.200.0/http/user_agent.ts'
import { UserAgent } from 'std/http/user_agent.ts'
import { LocationData } from '../location_data.ts'

export type OAuthMethod =
Expand Down
2 changes: 1 addition & 1 deletion otp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import * as OTP from 'https://deno.land/x/otpauth@v9.1.4/dist/otpauth.esm.js'
import * as OTP from 'otpauth'

export const otp = {
/**
Expand Down
16 changes: 6 additions & 10 deletions render.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// Copyright 2023 Samuel Kopp. All rights reserved. Apache-2.0 license.
import { brightYellow, gray } from 'https://deno.land/std@0.200.0/fmt/colors.ts'
import {
defineConfig,
extract,
install,
} from 'https://esm.sh/@twind/core@1.1.3'
import presetAutoPrefix from 'https://esm.sh/@twind/preset-autoprefix@1.0.7'
import presetTailwind from 'https://esm.sh/@twind/preset-tailwind@1.1.4'
import renderToString from 'https://esm.sh/preact-render-to-string@6.1.0?deps=preact@10.17.1&target=es2022'
import { VNode } from 'https://esm.sh/preact@10.17.1?target=es2022'
import { VNode } from 'preact'
import renderToString from 'preact/render-to-string'
import { brightYellow, gray } from 'std/fmt/colors.ts'
import { defineConfig, extract, install } from 'twind'
import presetAutoPrefix from 'twind/preset-autoprefix'
import presetTailwind from 'twind/preset-tailwind'
import { Context } from './mod.ts'

export function render(c: Context, Component: VNode) {
Expand Down
9 changes: 2 additions & 7 deletions request_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
import {
deadline as resolveWithDeadline,
DeadlineError,
} from 'https://deno.land/std@0.200.0/async/deadline.ts'
import { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts'
import {
ZodStringDef,
ZodType,
ZodUnionDef,
} from 'https://deno.land/x/zod@v3.21.4/types.ts'
} from 'std/async/deadline.ts'
import { z, ZodStringDef, ZodType, ZodUnionDef } from 'zod'
import { Method } from './base.ts'
import { BaseType, ObjectType } from './handler.ts'
import { AppContext, Context } from './mod.ts'
Expand Down
Loading