Skip to content

Commit fd0b903

Browse files
Copilothotlong
andcommitted
Add verification scripts for organization plugin
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 54d115b commit fd0b903

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Detailed inspection of Better-Auth organization plugin
4+
*/
5+
6+
async function inspectOrganization() {
7+
console.log('🔍 Detailed Better-Auth Organization Plugin Inspection...\n');
8+
9+
try {
10+
const { getAuth } = require('../dist/auth/auth.client');
11+
const auth = await getAuth();
12+
13+
console.log('Auth instance keys:', Object.keys(auth));
14+
console.log('\nAPI endpoints:');
15+
16+
if (auth.api) {
17+
const apiKeys = Object.keys(auth.api);
18+
console.log(`Total endpoints: ${apiKeys.length}\n`);
19+
20+
// Group endpoints by prefix
21+
const groups = {};
22+
apiKeys.forEach(key => {
23+
const prefix = key.split(/[A-Z]/)[0] || 'other';
24+
if (!groups[prefix]) groups[prefix] = [];
25+
groups[prefix].push(key);
26+
});
27+
28+
Object.keys(groups).sort().forEach(group => {
29+
console.log(`\n${group}:`);
30+
groups[group].forEach(ep => console.log(` - ${ep}`));
31+
});
32+
}
33+
34+
console.log('\n\nPlugin options:');
35+
if (auth.options && auth.options.plugins) {
36+
auth.options.plugins.forEach((plugin, i) => {
37+
console.log(`\nPlugin ${i + 1}:`);
38+
console.log(' Keys:', Object.keys(plugin));
39+
if (plugin.id) console.log(' ID:', plugin.id);
40+
if (plugin.endpoints) {
41+
console.log(' Endpoints:', Object.keys(plugin.endpoints));
42+
}
43+
if (plugin.schema) {
44+
console.log(' Schema:', Object.keys(plugin.schema));
45+
}
46+
});
47+
}
48+
49+
} catch (error) {
50+
console.error('❌ Inspection failed:', error.message);
51+
console.error(error.stack);
52+
process.exit(1);
53+
}
54+
}
55+
56+
inspectOrganization();
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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

Comments
 (0)