Skip to content

Commit 5e9e3ff

Browse files
committed
chore(deps): use import map instead of deps.ts
1 parent f833a13 commit 5e9e3ff

File tree

8 files changed

+84
-50
lines changed

8 files changed

+84
-50
lines changed

deno.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,18 @@
1010
"rules": {
1111
"exclude": ["no-explicit-any"]
1212
}
13+
},
14+
"imports": {
15+
"@lambdalisue/github-emoji": "jsr:@lambdalisue/github-emoji@^1.0.0",
16+
"@std/encoding": "jsr:@std/encoding@^1.0.5",
17+
"@std/log": "jsr:@std/log@^0.224.11",
18+
"x/http_errors": "https://deno.land/x/[email protected]/mod.ts"
19+
},
20+
"unstable": [
21+
"kv"
22+
],
23+
"compilerOptions": {
24+
"noUncheckedIndexedAccess": true,
25+
"strictFunctionTypes": true
1326
}
1427
}

deno.lock

Lines changed: 56 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/crypto.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { decodeHex, encodeHex } from "@std/encoding";
2+
13
import config from "./config.ts";
2-
import { hex } from "../deps.ts";
34

45
export const hasKey = !!config.signKey;
56

@@ -13,7 +14,7 @@ async function getKey(): Promise<CryptoKey> {
1314

1415
_signKey = await crypto.subtle.importKey(
1516
"raw",
16-
hex.decodeHex(config.signKey),
17+
decodeHex(config.signKey),
1718
{ name: "HMAC", hash: "SHA-256" },
1819
false,
1920
["sign", "verify"],
@@ -26,12 +27,12 @@ export async function sign(input: string): Promise<string> {
2627
const key = await getKey();
2728
const inputData = encoder.encode(input);
2829
const sig = await crypto.subtle.sign("HMAC", key, inputData);
29-
return hex.encodeHex(sig);
30+
return encodeHex(sig);
3031
}
3132

3233
export async function verify(input: string, signature: string): Promise<boolean> {
3334
const key = await getKey();
3435
const inputData = encoder.encode(input);
35-
const sig = hex.decodeHex(signature);
36+
const sig = decodeHex(signature);
3637
return await crypto.subtle.verify("HMAC", key, sig, inputData);
3738
}

lib/formatter.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { githubEmoji } from "../deps.ts";
1+
import { emojify as githubEmojify } from "@lambdalisue/github-emoji";
22

33
// Empirically determined GitHub embed description limit in the Discord API.
44
// Anything above this will be ellipsized :/
@@ -16,12 +16,8 @@ function ellipsizeText(s: string): string {
1616
return s;
1717
}
1818

19-
function transformEmojis(s: string): string {
20-
return githubEmoji.emojify(s);
21-
}
22-
2319
const TRANSFORMS: ((s: string) => string)[] = [
24-
transformEmojis,
20+
githubEmojify,
2521
ellipsizeText,
2622
];
2723

lib/handler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { httpErrors } from "../deps.ts";
1+
import * as httpErrors from "x/http_errors";
2+
23
import config from "./config.ts";
34
import { hasKey, verify } from "./crypto.ts";
45
import filterWebhook from "./filter.ts";

lib/util.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { log } from "../deps.ts";
1+
import * as log from "@std/log";
22

33
export function parseBool(s: string): boolean {
44
return ["1", "true", "on", "y", "yes"].includes(s.toLowerCase());
@@ -30,10 +30,6 @@ export function wildcardMatch(pattern: string, target: string): boolean {
3030
return invert !== new RegExp(pattern).test(target);
3131
}
3232

33-
function _getLogString(data: unknown): string {
34-
return log.getLogger().asString(data);
35-
}
36-
3733
/**
3834
* logging proxy that adds some metadata to log messages
3935
*/
@@ -45,7 +41,8 @@ export function requestLog(headers: Headers) {
4541
// is there a better way to do this? certainly.
4642
// does this work? also yes.
4743
const proxyLog: (func: (s: any) => string) => (msg: any) => string = (func) => {
48-
return (msg) => func(prefix + _getLogString(msg));
44+
// FIXME: `String()` mangles objects
45+
return (msg) => func(prefix + String(msg));
4946
};
5047

5148
return {

main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { httpErrors, log } from "./deps.ts";
1+
import * as log from "@std/log";
2+
import * as httpErrors from "x/http_errors";
3+
24
import config from "./lib/config.ts";
35
import handler from "./lib/handler.ts";
46
import { requestLog } from "./lib/util.ts";

0 commit comments

Comments
 (0)