|
| 1 | +#!/usr/bin/env node |
| 2 | +/** |
| 3 | + * Verification script for Better-Auth organization plugin |
| 4 | + * |
| 5 | + * This script checks that the organization plugin is properly initialized |
| 6 | + * and the expected endpoints are available. |
| 7 | + */ |
| 8 | + |
| 9 | +async function verifyOrganizationPlugin() { |
| 10 | + console.log('🔍 Verifying Better-Auth Organization Plugin Setup...\n'); |
| 11 | + |
| 12 | + try { |
| 13 | + // Import the auth client |
| 14 | + const { getAuth } = require('../dist/auth/auth.client'); |
| 15 | + |
| 16 | + console.log('✓ Successfully imported auth client'); |
| 17 | + |
| 18 | + // Get the auth instance |
| 19 | + const auth = await getAuth(); |
| 20 | + |
| 21 | + console.log('✓ Successfully initialized Better-Auth instance'); |
| 22 | + |
| 23 | + // Check if organization plugin is loaded |
| 24 | + if (auth && auth.options && auth.options.plugins) { |
| 25 | + console.log(`✓ Plugins loaded: ${auth.options.plugins.length} plugin(s)`); |
| 26 | + |
| 27 | + // Check for organization endpoints |
| 28 | + const endpoints = auth.api || {}; |
| 29 | + const organizationEndpoints = Object.keys(endpoints).filter(key => |
| 30 | + key.includes('organization') || |
| 31 | + key.includes('member') || |
| 32 | + key.includes('invitation') |
| 33 | + ); |
| 34 | + |
| 35 | + if (organizationEndpoints.length > 0) { |
| 36 | + console.log(`✓ Organization endpoints detected: ${organizationEndpoints.length} endpoints`); |
| 37 | + console.log('\nSample endpoints:'); |
| 38 | + organizationEndpoints.slice(0, 10).forEach(ep => { |
| 39 | + console.log(` - ${ep}`); |
| 40 | + }); |
| 41 | + if (organizationEndpoints.length > 10) { |
| 42 | + console.log(` ... and ${organizationEndpoints.length - 10} more`); |
| 43 | + } |
| 44 | + } else { |
| 45 | + console.log('⚠ No organization-specific endpoints found in API'); |
| 46 | + console.log('Available endpoints:', Object.keys(endpoints).slice(0, 5).join(', '), '...'); |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + console.log('\n✅ Organization plugin verification complete!'); |
| 51 | + console.log('\nExpected organization features:'); |
| 52 | + console.log(' • Multi-tenant organization management'); |
| 53 | + console.log(' • Role-based access control (owner, admin, member)'); |
| 54 | + console.log(' • Team support'); |
| 55 | + console.log(' • Invitation system'); |
| 56 | + console.log('\nEndpoints should be available at: /api/auth/organization/*'); |
| 57 | + |
| 58 | + process.exit(0); |
| 59 | + } catch (error) { |
| 60 | + console.error('❌ Verification failed:', error.message); |
| 61 | + console.error('\nStack trace:', error.stack); |
| 62 | + process.exit(1); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +verifyOrganizationPlugin(); |
0 commit comments