lib sources restructuring

This commit is contained in:
Roman Krček
2025-07-02 23:56:11 +02:00
parent 878198fabd
commit 81e2e53cc5
19 changed files with 391 additions and 115 deletions

View File

@@ -1,6 +1,6 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { getOAuthClient } from '$lib/google-server.js';
import { authServer } from '$lib/google/index.js';
export const POST: RequestHandler = async ({ request }) => {
try {
@@ -10,7 +10,7 @@ export const POST: RequestHandler = async ({ request }) => {
return json({ error: 'Refresh token is required' }, { status: 400 });
}
const oauth = getOAuthClient();
const oauth = authServer.getOAuthClient();
oauth.setCredentials({ refresh_token: refreshToken });
const { credentials } = await oauth.refreshAccessToken();

View File

@@ -1,6 +1,6 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { getOAuthClient } from '$lib/google-server.js';
import { authServer } from '$lib/google/index.js';
import { google } from 'googleapis';
export const GET: RequestHandler = async ({ request }) => {
@@ -14,7 +14,7 @@ export const GET: RequestHandler = async ({ request }) => {
const accessToken = authHeader.slice(7);
// Create OAuth client with the token
const oauth = getOAuthClient();
const oauth = authServer.getOAuthClient();
oauth.setCredentials({ access_token: accessToken });
// Call the userinfo endpoint to get user details