feat: Deploy to Cloudflare workers
Some checks failed
Deployment / wordpress (push) Failing after 1s
Deployment / nuxt (push) Failing after 7s

This commit is contained in:
2026-01-27 19:59:34 -05:00
parent a1a8114f49
commit c6dfbeb247
12 changed files with 1139 additions and 381 deletions

View File

@@ -1,7 +1,7 @@
export default defineEventHandler(async (event) => {
try {
const variables = await readBody<AuthLoginForm>(event);
const { data } = await useServerGraphQLMutation(event, "AuthLogin", variables);
const { data } = await useGraphQLOperation(event, "AuthLogin", variables);
if (!data?.login) {
throw new Error("INVALID_LOGIN");
}

View File

@@ -1,9 +1,9 @@
import type { H3Event } from "h3";
import { GraphQLClient } from "graphql-request";
import { jwtDecode } from "jwt-decode";
import type { User } from "#auth-utils";
import type { AuthUserFragment, AuthLoginMutationResult } from "#graphql/operations";
import { AuthRefreshTokenDocument } from "#graphql/operations";
import type { ResultOf } from "#graphql/registry";
// Handle login result and store user session
export async function handleLogin(event: H3Event, loginResult: AuthLoginMutationResult) {
@@ -42,9 +42,13 @@ function getAuthUser(user: AuthUserFragment): User {
// Refresh auth token by calling remote GraphQL endpoint directly
export async function refreshAuthToken(refreshToken: string): Promise<string | undefined> {
const client = new GraphQLClient(`${process.env.NUXT_WP_URL || "https://wp-headless.ledevsimple.ca"}/graphql`);
const data = await client.request(AuthRefreshTokenDocument, { refreshToken });
return data.refreshToken?.authToken || undefined;
// TODO: const { public: { graphql: { endpoint } } } = useRuntimeConfig();
const endpoint = `${process.env.NUXT_WP_URL || "https://cultureat.ledevsimple.ca"}/graphql`;
const { data } = await executeGraphQLHTTP<ResultOf<"AuthRefreshToken">>({
query: AuthRefreshTokenDocument,
variables: { refreshToken },
}, { endpoint });
return data?.refreshToken?.authToken || undefined;
}
// Get auth token from user session (refresh if needed)