feat: Add a lot of stuff

This commit is contained in:
Wanjohi
2025-10-25 22:11:33 +03:00
parent a3ee9aadd9
commit c5d0242d50
85 changed files with 6718 additions and 1377 deletions

View File

@@ -27,7 +27,7 @@
"@macaron-css/solid": "1.5.3",
"@modular-forms/solid": "^0.25.1",
"@nestri/core": "*",
"@nestri/functions": "*",
"@nestri/cloud-functions": "*",
"@nestri/zero": "*",
"@openauthjs/openauth": "*",
"@openauthjs/solid": "0.0.0-20250311201457",
@@ -47,4 +47,4 @@
"valibot": "^1.0.0-rc.3",
"zod": "^3.24.2"
}
}
}

View File

@@ -1,36 +1,35 @@
import { hc } from "hono/client";
import { useSteam } from "./context";
import { useOpenAuth } from "@openauthjs/solid";
import { type app } from "@nestri/functions/api/index";
import { type app } from "@nestri/cloud-functions/api/index";
import { createInitializedContext } from "@nestri/www/common/context";
export const { use: useApi, provider: ApiProvider } = createInitializedContext(
"ApiContext",
() => {
const steam = useSteam();
const auth = useOpenAuth();
"ApiContext",
() => {
const steam = useSteam();
const auth = useOpenAuth();
const client = hc<typeof app>(import.meta.env.VITE_API_URL, {
async fetch(...args: Parameters<typeof fetch>): Promise<Response> {
const [input, init] = args;
const request =
input instanceof Request ? input : new Request(input, init);
const headers = new Headers(request.headers);
headers.set("authorization", `Bearer ${await auth.access()}`);
headers.set("x-nestri-steam", steam().id);
const client = hc<typeof app>(import.meta.env.VITE_API_URL, {
async fetch(...args: Parameters<typeof fetch>): Promise<Response> {
const [input, init] = args;
const request =
input instanceof Request ? input : new Request(input, init);
const headers = new Headers(request.headers);
headers.set("authorization", `Bearer ${await auth.access()}`);
headers.set("x-nestri-steam", steam().id);
return fetch(
new Request(request, {
...init,
headers,
}),
);
},
});
return {
client,
ready: true,
};
},
);
return fetch(
new Request(request, {
...init,
headers,
}),
);
},
});
return {
client,
ready: true,
};
},
);