mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 05:41:22 +02:00
Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from '../src/app.module';
|
|
import { AuthService } from '../src/core/services/auth.service';
|
|
|
|
async function testSupabaseAuthIntegration() {
|
|
// Create a NestJS application instance
|
|
const app = await NestFactory.createApplicationContext(AppModule);
|
|
|
|
try {
|
|
// Get the AuthService
|
|
const authService = app.get(AuthService);
|
|
|
|
// Test user data
|
|
const userId = 'test-user-id';
|
|
const email = 'test@example.com';
|
|
|
|
// Generate a Supabase-compatible token
|
|
const token = await authService.generateSupabaseCompatibleToken(
|
|
userId,
|
|
email,
|
|
);
|
|
console.log('Generated Supabase-compatible token:', token);
|
|
|
|
// Create an authenticated Supabase client
|
|
const supabaseClient = authService.getAuthenticatedClient(token);
|
|
|
|
// Test a simple query to verify authentication
|
|
const { data, error } = await supabaseClient
|
|
.from('your_table_name')
|
|
.select('*')
|
|
.limit(1);
|
|
|
|
if (error) {
|
|
console.error('Error querying Supabase with the token:', error);
|
|
} else {
|
|
console.log(
|
|
'Successfully authenticated with Supabase! Sample data:',
|
|
data,
|
|
);
|
|
}
|
|
} catch (error) {
|
|
console.error('Test failed:', error);
|
|
} finally {
|
|
await app.close();
|
|
}
|
|
}
|
|
|
|
// Run the test
|
|
testSupabaseAuthIntegration()
|
|
.then(() => console.log('Test completed'))
|
|
.catch((err) => console.error('Test error:', err));
|