Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ add undici for uber fast webdis requests #139

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"sharp": "^0.32.5",
"tailwind-merge": "^1.14.0",
"text-field-edit": "^4.0.0",
"undici": "^6.6.2",
"vfile": "^6.0.1",
"zod": "^3.22.2",
"zod-form-data": "^2.0.1",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions src/lib/server/kv/webdis.server.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { _envObject as env } from "../../../env-config.mjs";

import { request } from "undici";
/**
* @typedef {import("./index.server").KVStore} KVStore
*/
Expand Down Expand Up @@ -58,22 +58,20 @@ export class WebdisKV {

const rand = Math.ceil(Math.random() * 10e15);
console.time(`[${rand} webdis] ${fullURL}`);
return await fetch(fullURL, {
return await request(fullURL, {
method: "PUT",
cache: "no-store",
headers: {
Authorization: `Basic ${btoa(authString)}`
},
body: body ?? undefined
}).then((r) =>
r.text().then((text) => {
if (!r.ok) {
}).then(({ body, statusCode }) =>
body.text().then((text) => {
if (statusCode !== 200) {
console.log(
"Couldn't fetch from webdis KV, received this response from server : ",
{
text,
status: r.status,
statusText: r.statusText
status: statusCode
}
);
}
Expand Down
Loading