fix: no longer use deprecated std functions

This commit is contained in:
shiftinv 2024-02-01 17:30:36 +01:00
parent 7e4a78fcf2
commit dc0e9990c2
5 changed files with 11 additions and 64 deletions

View File

@ -9,30 +9,11 @@
"https://deno.land/std@0.211.0/io/buf_reader.ts": "3ee2cf0d6570ec1ede46efd5d0b0701719dc573f103a123d2cf9f4bfbc36af31",
"https://deno.land/std@0.211.0/io/buf_writer.ts": "214134bd77bc46e4478cf74b771dfb614b9e23b313df513a34c54aa88df81584",
"https://deno.land/std@0.214.0/assert/assert.ts": "bec068b2fccdd434c138a555b19a2c2393b71dfaada02b7d568a01541e67cdc5",
"https://deno.land/std@0.214.0/assert/assert_exists.ts": "24a7bf965e634f909242cd09fbaf38bde6b791128ece08e33ab08586a7cc55c9",
"https://deno.land/std@0.214.0/assert/assertion_error.ts": "9f689a101ee586c4ce92f52fa7ddd362e86434ffdf1f848e45987dc7689976b8",
"https://deno.land/std@0.214.0/async/delay.ts": "8e1d18fe8b28ff95885e2bc54eccec1713f57f756053576d8228e6ca110793ad",
"https://deno.land/std@0.214.0/cli/parse_args.ts": "b24efc18e9cb4fab5d7daed7a04fa5edbdd5c7998b1e44d44aa9d85111817011",
"https://deno.land/std@0.214.0/encoding/_util.ts": "beacef316c1255da9bc8e95afb1fa56ed69baef919c88dc06ae6cb7a6103d376",
"https://deno.land/std@0.214.0/encoding/base64.ts": "96e61a556d933201266fea84ae500453293f2aff130057b579baafda096a96bc",
"https://deno.land/std@0.214.0/encoding/hex.ts": "4d47d3b25103cf81a2ed38f54b394d39a77b63338e1eaa04b70c614cb45ec2e6",
"https://deno.land/std@0.214.0/fmt/bytes.ts": "7b294a4b9cf0297efa55acb55d50610f3e116a0ac772d1df0ae00f0b833ccd4a",
"https://deno.land/std@0.214.0/fmt/colors.ts": "aeaee795471b56fc62a3cb2e174ed33e91551b535f44677f6320336aabb54fbb",
"https://deno.land/std@0.214.0/fs/exists.ts": "d2757ef764eaf5c6c5af7228e8447db2de42ab084a2dae540097f905723d83f5",
"https://deno.land/std@0.214.0/http/_negotiation/common.ts": "051a9f6edd1ed69507df89bbc16fc1b13b7654b9b8fd38072ec33ae4c185fc13",
"https://deno.land/std@0.214.0/http/_negotiation/encoding.ts": "afc658fca003248777919257474a2d128892cbca4a3b9faa1ddee8d7a53e52a9",
"https://deno.land/std@0.214.0/http/_negotiation/language.ts": "4d38c2abeaabcd69de1f1b81e2c3e33ba9c3f4f9eea1b7af93664561d43092ff",
"https://deno.land/std@0.214.0/http/_negotiation/media_type.ts": "1f6f2036e3173b42b0bdf8df8011d72e20668d35eadc8cec11a5ac0921aa60fb",
"https://deno.land/std@0.214.0/http/cookie.ts": "5779cde46c67f9650c5e61902bdedfffd4b9b86c2eb65f601133d11f41acc95e",
"https://deno.land/std@0.214.0/http/etag.ts": "9c120f11b2e57fdaeda28a6cf6c060a3d203e58f56e5856a717281dd0318eedc",
"https://deno.land/std@0.214.0/http/file_server.ts": "9ac4b039b6d2a419b10dd027bdafdfa9d262ddea0b6f033f96a0b6c3706bab69",
"https://deno.land/std@0.214.0/http/mod.ts": "b0e06293a8a2f71b041add53d4674d4997bd2b83a4760bddad1b5e552130bcc8",
"https://deno.land/std@0.214.0/http/negotiation.ts": "d06ef2958ca712a7dbe4538eed6a46abfa2b87f8e150b7c89d83a6055dabd7cc",
"https://deno.land/std@0.214.0/http/server.ts": "6dce295abc169d0956ae00432441331b3425afad4d79e8b3475739be2f04d614",
"https://deno.land/std@0.214.0/http/server_sent_event_stream.ts": "d9c20b46f986d78f60c38dbd91e95c71d73b45f29739a8ef4216dfa5f2e71eb3",
"https://deno.land/std@0.214.0/http/status.ts": "ed61b4882af2514a81aefd3245e8df4c47b9a8e54929a903577643d2d1ebf514",
"https://deno.land/std@0.214.0/http/unstable_signed_cookie.ts": "a8d214120f7e9cbc9e30cc398844dae969dfaedbdec8d6d02baeb08b32db43e9",
"https://deno.land/std@0.214.0/http/user_agent.ts": "14639cfce2b4a95e057b10418b5be1bdfb54ab18fa9388688bfaf137481be159",
"https://deno.land/std@0.214.0/log/base_handler.ts": "c9479234e87afaa1fbb7a52a18c3eba878e50a5a238bdd1ed8fc88ae951cb4d9",
"https://deno.land/std@0.214.0/log/console_handler.ts": "75653acd6932fb97c7121f63336b39de3f072e329874d66f05abcb2a7f514558",
"https://deno.land/std@0.214.0/log/file_handler.ts": "7b58c7017117ae290700b0e23f21573c1dc8ba8b5d4978d8aa0b8e05742d75e2",
@ -41,39 +22,6 @@
"https://deno.land/std@0.214.0/log/logger.ts": "f9110211816e27b147fd0f34639e5c7618670048aad789f5a304bd7623505ba5",
"https://deno.land/std@0.214.0/log/mod.ts": "09365c6bb39440f1c56e1984eff6a23b92eed27deb467aafcb64e17444513737",
"https://deno.land/std@0.214.0/log/rotating_file_handler.ts": "dc0333959ff725ac1f43b741ababa9fef074f658a60c65235d12e44952085fbe",
"https://deno.land/std@0.214.0/media_types/_db.ts": "1d695d9fe1c785e523d6de7191b33f33ecc7866db77358a4f966221cca56e2f9",
"https://deno.land/std@0.214.0/media_types/_util.ts": "afd54920a8a81add64248897898d3f30ca414a8803fe0c4e6d2893a3f6bd32b0",
"https://deno.land/std@0.214.0/media_types/content_type.ts": "ed3f2e1f243b418ad3f441edc95fd92efbadb0f9bde36219c7564c67f9639513",
"https://deno.land/std@0.214.0/media_types/format_media_type.ts": "ffef4718afa2489530cb94021bb865a466eb02037609f7e82899c017959d288a",
"https://deno.land/std@0.214.0/media_types/get_charset.ts": "bce5c0343c14590516cbfa1a3e80891d9a7a53bc9b4a9010061cc4f879e18f6c",
"https://deno.land/std@0.214.0/media_types/parse_media_type.ts": "487f000a38c230ccbac25420a50f600862e06796d0eee19d19631b9e84ee9654",
"https://deno.land/std@0.214.0/media_types/type_by_extension.ts": "bf4e3f5d6b58b624d5daa01cbb8b1e86d9939940a77e7c26e796a075b60ec73b",
"https://deno.land/std@0.214.0/media_types/vendor/mime-db.v1.52.0.ts": "0218d2c7d900e8cd6fa4a866e0c387712af4af9a1bae55d6b2546c73d273a1e6",
"https://deno.land/std@0.214.0/path/_common/assert_path.ts": "2ca275f36ac1788b2acb60fb2b79cb06027198bc2ba6fb7e163efaedde98c297",
"https://deno.land/std@0.214.0/path/_common/constants.ts": "dc5f8057159f4b48cd304eb3027e42f1148cf4df1fb4240774d3492b5d12ac0c",
"https://deno.land/std@0.214.0/path/_common/normalize.ts": "684df4aa71a04bbcc346c692c8485594fc8a90b9408dfbc26ff32cf3e0c98cc8",
"https://deno.land/std@0.214.0/path/_common/normalize_string.ts": "dfdf657a1b1a7db7999f7c575ee7e6b0551d9c20f19486c6c3f5ff428384c965",
"https://deno.land/std@0.214.0/path/_common/relative.ts": "faa2753d9b32320ed4ada0733261e3357c186e5705678d9dd08b97527deae607",
"https://deno.land/std@0.214.0/path/_os.ts": "8fb9b90fb6b753bd8c77cfd8a33c2ff6c5f5bc185f50de8ca4ac6a05710b2c15",
"https://deno.land/std@0.214.0/path/constants.ts": "0c206169ca104938ede9da48ac952de288f23343304a1c3cb6ec7625e7325f36",
"https://deno.land/std@0.214.0/path/extname.ts": "593303db8ae8c865cbd9ceec6e55d4b9ac5410c1e276bfd3131916591b954441",
"https://deno.land/std@0.214.0/path/join.ts": "ae2ec5ca44c7e84a235fd532e4a0116bfb1f2368b394db1c4fb75e3c0f26a33a",
"https://deno.land/std@0.214.0/path/posix/_util.ts": "1e3937da30f080bfc99fe45d7ed23c47dd8585c5e473b2d771380d3a6937cf9d",
"https://deno.land/std@0.214.0/path/posix/extname.ts": "8d36ae0082063c5e1191639699e6f77d3acf501600a3d87b74943f0ae5327427",
"https://deno.land/std@0.214.0/path/posix/join.ts": "aef88d5fa3650f7516730865dbb951594d1a955b785e2450dbee93b8e32694f3",
"https://deno.land/std@0.214.0/path/posix/normalize.ts": "baeb49816a8299f90a0237d214cef46f00ba3e95c0d2ceb74205a6a584b58a91",
"https://deno.land/std@0.214.0/path/posix/relative.ts": "3907d6eda41f0ff723d336125a1ad4349112cd4d48f693859980314d5b9da31c",
"https://deno.land/std@0.214.0/path/posix/resolve.ts": "bac20d9921beebbbb2b73706683b518b1d0c1b1da514140cee409e90d6b2913a",
"https://deno.land/std@0.214.0/path/relative.ts": "ab739d727180ed8727e34ed71d976912461d98e2b76de3d3de834c1066667add",
"https://deno.land/std@0.214.0/path/resolve.ts": "a6f977bdb4272e79d8d0ed4333e3d71367cc3926acf15ac271f1d059c8494d8d",
"https://deno.land/std@0.214.0/path/windows/_util.ts": "d5f47363e5293fced22c984550d5e70e98e266cc3f31769e1710511803d04808",
"https://deno.land/std@0.214.0/path/windows/extname.ts": "165a61b00d781257fda1e9606a48c78b06815385e7d703232548dbfc95346bef",
"https://deno.land/std@0.214.0/path/windows/join.ts": "e0b3356615c1a75c56ebb6a7311157911659e11fd533d80d724800126b761ac3",
"https://deno.land/std@0.214.0/path/windows/normalize.ts": "78126170ab917f0ca355a9af9e65ad6bfa5be14d574c5fb09bb1920f52577780",
"https://deno.land/std@0.214.0/path/windows/relative.ts": "3e1abc7977ee6cc0db2730d1f9cb38be87b0ce4806759d271a70e4997fc638d7",
"https://deno.land/std@0.214.0/path/windows/resolve.ts": "75b2e3e1238d840782cee3d8864d82bfaa593c7af8b22f19c6422cf82f330ab3",
"https://deno.land/std@0.214.0/streams/byte_slice_stream.ts": "5bbdcadb118390affa9b3d0a0f73ef8e83754f59bb89df349add669dd9369713",
"https://deno.land/std@0.214.0/version.ts": "26f3aeb50a5cba75a6e87b81f507061081a9297cf2e5e8e3c90d7cd15470fec7",
"https://deno.land/std@0.69.0/_util/assert.ts": "e1f76e77c5ccb5a8e0dbbbe6cce3a56d2556c8cb5a9a8802fc9565af72462149",
"https://deno.land/std@0.69.0/async/deferred.ts": "ac95025f46580cf5197928ba90995d87f26e202c19ad961bc4e3177310894cdc",
"https://deno.land/std@0.69.0/async/delay.ts": "35957d585a6e3dd87706858fb1d6b551cb278271b03f52c5a2cb70e65e00c26a",

View File

@ -1,4 +1,3 @@
export * as http from "https://deno.land/std@0.214.0/http/mod.ts";
export * as log from "https://deno.land/std@0.214.0/log/mod.ts";
export * as hex from "https://deno.land/std@0.214.0/encoding/hex.ts";

View File

@ -51,7 +51,7 @@ export function requestLog(headers: Headers) {
return {
debug: proxyLog(log.debug),
info: proxyLog(log.info),
warning: proxyLog(log.warning),
warn: proxyLog(log.warn),
error: proxyLog(log.error),
critical: proxyLog(log.critical),
};

View File

@ -39,7 +39,7 @@ export async function sendWebhook(
// if we'd wait longer than the configured limit, just return the 429
if (resetms > config.maxWebhookRetryMs) {
reqLog.warning(
reqLog.warn(
`ratelimited for ${resetms}ms (> ${config.maxWebhookRetryMs}ms), not retrying`,
);
break;
@ -47,11 +47,11 @@ export async function sendWebhook(
// maybe wait and retry
if (retries >= config.maxWebhookRetries) {
reqLog.warning(`reached maximum number of retries (${retries})`);
reqLog.warn(`reached maximum number of retries (${retries})`);
break;
}
retries++;
reqLog.warning(`retrying after ${resetms}ms (retry ${retries})`);
reqLog.warn(`retrying after ${resetms}ms (retry ${retries})`);
await sleep(resetms);
} while (true);

14
main.ts
View File

@ -1,4 +1,4 @@
import { http, httpErrors, log } from "./deps.ts";
import { httpErrors, log } from "./deps.ts";
import config from "./lib/config.ts";
import handler from "./lib/handler.ts";
import { requestLog } from "./lib/util.ts";
@ -19,7 +19,7 @@ function setupLogs() {
});
}
async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Response> {
async function handleRequest(req: Request, info: Deno.ServeHandlerInfo): Promise<Response> {
const reqLog = requestLog(req.headers);
let res: Response;
@ -33,7 +33,7 @@ async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Res
}
} catch (err) {
if (err instanceof httpErrors.HttpError && err.expose) {
reqLog.warning(`http error: ${err.message}`);
reqLog.warn(`http error: ${err.message}`);
res = new Response(err.message, { status: err.status });
} else {
reqLog.critical(err);
@ -60,7 +60,7 @@ async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Res
// log request
const respLen = res.headers.get("content-length") || 0;
const addr = connInfo.remoteAddr as Deno.NetAddr;
const addr = info.remoteAddr;
reqLog.info(
`http: ${addr.hostname}:${addr.port} - ${req.method} ${req.url} ${res.status} ${respLen}`,
);
@ -72,13 +72,13 @@ if (import.meta.main) {
setupLogs();
if (!config.signKey) {
log.warning("url signing disabled");
log.warn("url signing disabled");
}
log.info(`starting webserver on ${config.hostname}:${config.port}`);
http.serve(handleRequest, {
Deno.serve({
hostname: config.hostname,
port: config.port,
onListen: () => log.info(`listening on ${config.hostname}:${config.port}`),
});
}, handleRequest);
}