Initial commit: Complete NodeJS-native setup

- Migrated from Python pre-commit to NodeJS-native solution
- Reorganized documentation structure
- Set up Husky + lint-staged for efficient pre-commit hooks
- Fixed Dockerfile healthcheck issue
- Added comprehensive documentation index
This commit is contained in:
William Valentin
2025-09-06 01:42:48 -07:00
commit e48adbcb00
159 changed files with 24405 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
// Simple test to verify auth database functionality
// Run this in browser console at http://localhost:5174
console.log('Testing Authentication Database...');
// Test the mock database service
async function testDatabase() {
try {
// Import the services (this would work in browser context)
const { dbService } = await import('./services/couchdb.ts');
const { authService } = await import('./services/auth/auth.service.ts');
console.log('1. Testing user creation with password...');
// Test creating a user with password
const testEmail = 'test@example.com';
const testPassword = 'password123';
try {
const newUser = await dbService.createUserWithPassword(
testEmail,
testPassword
);
console.log('✅ User created successfully:', newUser);
} catch (error) {
if (error.message.includes('already exists')) {
console.log(' User already exists, testing login...');
} else {
console.error('❌ User creation failed:', error);
return;
}
}
console.log('2. Testing password login...');
// Test login with password
try {
const loginResult = await authService.login({
email: testEmail,
password: testPassword,
});
console.log('✅ Password login successful:', loginResult);
} catch (error) {
console.error('❌ Password login failed:', error);
}
console.log('3. Testing OAuth user creation...');
// Test OAuth user creation
const oauthData = {
email: 'oauth@example.com',
username: 'oauth_user',
avatar: 'https://example.com/avatar.jpg',
};
try {
const oauthUser = await dbService.createUserFromOAuth(oauthData);
console.log('✅ OAuth user created successfully:', oauthUser);
} catch (error) {
if (error.message.includes('already exists')) {
console.log(' OAuth user already exists');
} else {
console.error('❌ OAuth user creation failed:', error);
}
}
console.log('4. Testing user lookup by email...');
// Test finding users
const foundUser = await dbService.findUserByEmail(testEmail);
console.log('✅ User found by email:', foundUser);
console.log('🎉 All database tests completed!');
} catch (error) {
console.error('💥 Test setup failed:', error);
}
}
// Export for manual testing
if (typeof window !== 'undefined') {
window.testAuthDB = testDatabase;
console.log('Run window.testAuthDB() to test the authentication database');
}