Skip to content

Commit dc0e999

Browse files
committed
fix: no longer use deprecated std functions
1 parent 7e4a78f commit dc0e999

File tree

5 files changed

+11
-64
lines changed

5 files changed

+11
-64
lines changed

deno.lock

Lines changed: 0 additions & 52 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * as http from "https://deno.land/[email protected]/http/mod.ts";
21
export * as log from "https://deno.land/[email protected]/log/mod.ts";
32
export * as hex from "https://deno.land/[email protected]/encoding/hex.ts";
43

lib/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function requestLog(headers: Headers) {
5151
return {
5252
debug: proxyLog(log.debug),
5353
info: proxyLog(log.info),
54-
warning: proxyLog(log.warning),
54+
warn: proxyLog(log.warn),
5555
error: proxyLog(log.error),
5656
critical: proxyLog(log.critical),
5757
};

lib/webhook.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ export async function sendWebhook(
3939

4040
// if we'd wait longer than the configured limit, just return the 429
4141
if (resetms > config.maxWebhookRetryMs) {
42-
reqLog.warning(
42+
reqLog.warn(
4343
`ratelimited for ${resetms}ms (> ${config.maxWebhookRetryMs}ms), not retrying`,
4444
);
4545
break;
4646
}
4747

4848
// maybe wait and retry
4949
if (retries >= config.maxWebhookRetries) {
50-
reqLog.warning(`reached maximum number of retries (${retries})`);
50+
reqLog.warn(`reached maximum number of retries (${retries})`);
5151
break;
5252
}
5353
retries++;
54-
reqLog.warning(`retrying after ${resetms}ms (retry ${retries})`);
54+
reqLog.warn(`retrying after ${resetms}ms (retry ${retries})`);
5555
await sleep(resetms);
5656
} while (true);
5757

main.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { http, httpErrors, log } from "./deps.ts";
1+
import { httpErrors, log } from "./deps.ts";
22
import config from "./lib/config.ts";
33
import handler from "./lib/handler.ts";
44
import { requestLog } from "./lib/util.ts";
@@ -19,7 +19,7 @@ function setupLogs() {
1919
});
2020
}
2121

22-
async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Response> {
22+
async function handleRequest(req: Request, info: Deno.ServeHandlerInfo): Promise<Response> {
2323
const reqLog = requestLog(req.headers);
2424

2525
let res: Response;
@@ -33,7 +33,7 @@ async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Res
3333
}
3434
} catch (err) {
3535
if (err instanceof httpErrors.HttpError && err.expose) {
36-
reqLog.warning(`http error: ${err.message}`);
36+
reqLog.warn(`http error: ${err.message}`);
3737
res = new Response(err.message, { status: err.status });
3838
} else {
3939
reqLog.critical(err);
@@ -60,7 +60,7 @@ async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Res
6060

6161
// log request
6262
const respLen = res.headers.get("content-length") || 0;
63-
const addr = connInfo.remoteAddr as Deno.NetAddr;
63+
const addr = info.remoteAddr;
6464
reqLog.info(
6565
`http: ${addr.hostname}:${addr.port} - ${req.method} ${req.url} ${res.status} ${respLen}`,
6666
);
@@ -72,13 +72,13 @@ if (import.meta.main) {
7272
setupLogs();
7373

7474
if (!config.signKey) {
75-
log.warning("url signing disabled");
75+
log.warn("url signing disabled");
7676
}
7777

7878
log.info(`starting webserver on ${config.hostname}:${config.port}`);
79-
http.serve(handleRequest, {
79+
Deno.serve({
8080
hostname: config.hostname,
8181
port: config.port,
8282
onListen: () => log.info(`listening on ${config.hostname}:${config.port}`),
83-
});
83+
}, handleRequest);
8484
}

0 commit comments

Comments
 (0)