Files
AnimeTV-Backend/src/modules/auth/controllers/googleCallback.controller.ts
2025-09-03 15:34:11 +07:00

24 lines
830 B
TypeScript

import { Context } from "elysia";
import { returnReadResponse } from "../../../helpers/callback/httpResponse";
import { mainErrorHandler } from "../../../helpers/error/handler";
import { googleCallbackService } from "../services/http/googleCallback.service";
import { getUserHeaderInformation } from "../../../helpers/http/userHeader/getUserHeaderInformation";
export const googleCallbackController = async (
ctx: Context & { query: { code: string; state: string; callbackURI: string } }
) => {
try {
const userHeaderInfo = getUserHeaderInformation(ctx);
const userData = await googleCallbackService(ctx.query, userHeaderInfo);
return returnReadResponse(
ctx.set,
200,
"Authenticated successfully!",
userData
);
} catch (error) {
return mainErrorHandler(ctx.set, error);
}
};