better-auth-studio 1.0.19-beta.1 → 1.0.19-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/routes.js CHANGED
@@ -178,8 +178,10 @@ async function findAuthConfigPath() {
178
178
  }
179
179
  return null;
180
180
  }
181
- export function createRoutes(authConfig) {
181
+ export function createRoutes(authConfig, configPath) {
182
182
  const router = Router();
183
+ // Store the config path for use in adapter functions
184
+ const getAuthAdapterWithConfig = () => getAuthAdapter(configPath);
183
185
  router.get('/api/health', (req, res) => {
184
186
  const uptime = process.uptime();
185
187
  const hours = Math.floor(uptime / 3600);
@@ -346,7 +348,7 @@ export function createRoutes(authConfig) {
346
348
  });
347
349
  router.get('/api/stats', async (req, res) => {
348
350
  try {
349
- const stats = await getAuthData(authConfig, 'stats');
351
+ const stats = await getAuthData(authConfig, 'stats', undefined, configPath);
350
352
  res.json(stats);
351
353
  }
352
354
  catch (error) {
@@ -356,7 +358,7 @@ export function createRoutes(authConfig) {
356
358
  });
357
359
  router.get('/api/counts', async (req, res) => {
358
360
  try {
359
- const adapter = await getAuthAdapter();
361
+ const adapter = await getAuthAdapterWithConfig();
360
362
  let userCount = 0;
361
363
  let sessionCount = 0;
362
364
  let organizationCount = 0;
@@ -403,7 +405,7 @@ export function createRoutes(authConfig) {
403
405
  });
404
406
  router.get('/api/users/all', async (req, res) => {
405
407
  try {
406
- const adapter = await getAuthAdapter();
408
+ const adapter = await getAuthAdapterWithConfig();
407
409
  if (!adapter) {
408
410
  return res.status(500).json({ error: 'Auth adapter not available' });
409
411
  }
@@ -423,7 +425,7 @@ export function createRoutes(authConfig) {
423
425
  router.get('/api/users/:userId', async (req, res) => {
424
426
  try {
425
427
  const { userId } = req.params;
426
- const adapter = await getAuthAdapter();
428
+ const adapter = await getAuthAdapterWithConfig();
427
429
  if (!adapter || !adapter.findMany) {
428
430
  return res.status(500).json({ error: 'Auth adapter not available' });
429
431
  }
@@ -447,14 +449,14 @@ export function createRoutes(authConfig) {
447
449
  try {
448
450
  const { userId } = req.params;
449
451
  const { name, email } = req.body;
450
- const adapter = await getAuthAdapter();
452
+ const adapter = await getAuthAdapterWithConfig();
451
453
  if (!adapter || !adapter.update) {
452
454
  return res.status(500).json({ error: 'Auth adapter not available' });
453
455
  }
454
456
  const user = await adapter.update({
455
457
  model: 'user',
456
- id: userId,
457
- data: { name, email }
458
+ where: [{ field: 'id', value: userId }],
459
+ update: { name, email }
458
460
  });
459
461
  res.json({ success: true, user });
460
462
  }
@@ -466,11 +468,11 @@ export function createRoutes(authConfig) {
466
468
  router.delete('/api/users/:userId', async (req, res) => {
467
469
  try {
468
470
  const { userId } = req.params;
469
- const adapter = await getAuthAdapter();
471
+ const adapter = await getAuthAdapterWithConfig();
470
472
  if (!adapter || !adapter.delete) {
471
473
  return res.status(500).json({ error: 'Auth adapter not available' });
472
474
  }
473
- await adapter.delete({ model: 'user', id: userId });
475
+ await adapter.delete({ model: 'user', where: [{ field: 'id', value: userId }] });
474
476
  res.json({ success: true });
475
477
  }
476
478
  catch (error) {
@@ -481,7 +483,7 @@ export function createRoutes(authConfig) {
481
483
  router.get('/api/users/:userId/organizations', async (req, res) => {
482
484
  try {
483
485
  const { userId } = req.params;
484
- const adapter = await getAuthAdapter();
486
+ const adapter = await getAuthAdapterWithConfig();
485
487
  if (!adapter || !adapter.findMany) {
486
488
  return res.status(500).json({ error: 'Auth adapter not available' });
487
489
  }
@@ -520,7 +522,7 @@ export function createRoutes(authConfig) {
520
522
  router.get('/api/users/:userId/teams', async (req, res) => {
521
523
  try {
522
524
  const { userId } = req.params;
523
- const adapter = await getAuthAdapter();
525
+ const adapter = await getAuthAdapterWithConfig();
524
526
  if (!adapter || !adapter.findMany) {
525
527
  return res.status(500).json({ error: 'Auth adapter not available' });
526
528
  }
@@ -560,7 +562,7 @@ export function createRoutes(authConfig) {
560
562
  router.delete('/api/organizations/members/:membershipId', async (req, res) => {
561
563
  try {
562
564
  const { membershipId } = req.params;
563
- const adapter = await getAuthAdapter();
565
+ const adapter = await getAuthAdapterWithConfig();
564
566
  if (!adapter || !adapter.delete) {
565
567
  return res.status(500).json({ error: 'Auth adapter not available' });
566
568
  }
@@ -575,7 +577,7 @@ export function createRoutes(authConfig) {
575
577
  router.delete('/api/teams/members/:membershipId', async (req, res) => {
576
578
  try {
577
579
  const { membershipId } = req.params;
578
- const adapter = await getAuthAdapter();
580
+ const adapter = await getAuthAdapterWithConfig();
579
581
  if (!adapter || !adapter.delete) {
580
582
  return res.status(500).json({ error: 'Auth adapter not available' });
581
583
  }
@@ -590,7 +592,7 @@ export function createRoutes(authConfig) {
590
592
  router.post('/api/users/:userId/ban', async (req, res) => {
591
593
  try {
592
594
  const { userId } = req.params;
593
- const adapter = await getAuthAdapter();
595
+ const adapter = await getAuthAdapterWithConfig();
594
596
  if (!adapter || !adapter.update) {
595
597
  return res.status(500).json({ error: 'Auth adapter not available' });
596
598
  }
@@ -609,7 +611,7 @@ export function createRoutes(authConfig) {
609
611
  router.get('/api/users/:userId/sessions', async (req, res) => {
610
612
  try {
611
613
  const { userId } = req.params;
612
- const adapter = await getAuthAdapter();
614
+ const adapter = await getAuthAdapterWithConfig();
613
615
  if (!adapter || !adapter.findMany) {
614
616
  return res.status(500).json({ error: 'Auth adapter not available' });
615
617
  }
@@ -639,7 +641,7 @@ export function createRoutes(authConfig) {
639
641
  router.delete('/api/sessions/:sessionId', async (req, res) => {
640
642
  try {
641
643
  const { sessionId } = req.params;
642
- const adapter = await getAuthAdapter();
644
+ const adapter = await getAuthAdapterWithConfig();
643
645
  if (!adapter || !adapter.delete) {
644
646
  return res.status(500).json({ error: 'Auth adapter not available' });
645
647
  }
@@ -654,7 +656,7 @@ export function createRoutes(authConfig) {
654
656
  router.get('/api/teams/:teamId', async (req, res) => {
655
657
  try {
656
658
  const { teamId } = req.params;
657
- const adapter = await getAuthAdapter();
659
+ const adapter = await getAuthAdapterWithConfig();
658
660
  if (!adapter || !adapter.findMany) {
659
661
  return res.status(500).json({ error: 'Auth adapter not available' });
660
662
  }
@@ -701,11 +703,9 @@ export function createRoutes(authConfig) {
701
703
  }
702
704
  });
703
705
  router.get('/api/organizations/:orgId', async (req, res) => {
704
- console.log('DEBUG: Organization route hit!');
705
706
  try {
706
707
  const { orgId } = req.params;
707
- console.log('DEBUG: Organization route called with orgId:', orgId);
708
- const adapter = await getAuthAdapter();
708
+ const adapter = await getAuthAdapterWithConfig();
709
709
  if (!adapter || !adapter.findMany) {
710
710
  return res.status(500).json({ error: 'Auth adapter not available' });
711
711
  }
@@ -726,7 +726,6 @@ export function createRoutes(authConfig) {
726
726
  createdAt: organization.createdAt,
727
727
  updatedAt: organization.updatedAt,
728
728
  };
729
- console.log('DEBUG: Returning organization:', { success: true, organization: transformedOrganization });
730
729
  res.json({ success: true, organization: transformedOrganization });
731
730
  }
732
731
  catch (error) {
@@ -740,7 +739,7 @@ export function createRoutes(authConfig) {
740
739
  const limit = parseInt(req.query.limit) || 20;
741
740
  const search = req.query.search;
742
741
  try {
743
- const adapter = await getAuthAdapter();
742
+ const adapter = await getAuthAdapterWithConfig();
744
743
  if (adapter && typeof adapter.findMany === 'function') {
745
744
  const allUsers = await adapter.findMany({ model: 'user', limit: limit });
746
745
  let filteredUsers = allUsers || [];
@@ -767,7 +766,7 @@ export function createRoutes(authConfig) {
767
766
  catch (adapterError) {
768
767
  console.error('Error fetching users from adapter:', adapterError);
769
768
  }
770
- const result = await getAuthData(authConfig, 'users', { page, limit, search });
769
+ const result = await getAuthData(authConfig, 'users', { page, limit, search }, configPath);
771
770
  const transformedUsers = (result.data || []).map((user) => ({
772
771
  id: user.id,
773
772
  email: user.email,
@@ -788,7 +787,7 @@ export function createRoutes(authConfig) {
788
787
  try {
789
788
  const page = parseInt(req.query.page) || 1;
790
789
  const limit = parseInt(req.query.limit) || 20;
791
- const sessions = await getAuthData(authConfig, 'sessions', { page, limit });
790
+ const sessions = await getAuthData(authConfig, 'sessions', { page, limit }, configPath);
792
791
  res.json(sessions);
793
792
  }
794
793
  catch (error) {
@@ -798,7 +797,7 @@ export function createRoutes(authConfig) {
798
797
  });
799
798
  router.get('/api/providers', async (req, res) => {
800
799
  try {
801
- const providers = await getAuthData(authConfig, 'providers');
800
+ const providers = await getAuthData(authConfig, 'providers', undefined, configPath);
802
801
  res.json(providers);
803
802
  }
804
803
  catch (error) {
@@ -809,7 +808,7 @@ export function createRoutes(authConfig) {
809
808
  router.delete('/api/users/:id', async (req, res) => {
810
809
  try {
811
810
  const { id } = req.params;
812
- await getAuthData(authConfig, 'deleteUser', { id });
811
+ await getAuthData(authConfig, 'deleteUser', { id }, configPath);
813
812
  res.json({ success: true });
814
813
  }
815
814
  catch (error) {
@@ -819,7 +818,7 @@ export function createRoutes(authConfig) {
819
818
  });
820
819
  router.get('/api/plugins', async (req, res) => {
821
820
  try {
822
- const authConfigPath = await findAuthConfigPath();
821
+ const authConfigPath = configPath ? join(process.cwd(), configPath) : await findAuthConfigPath();
823
822
  if (!authConfigPath) {
824
823
  return res.json({
825
824
  plugins: [],
@@ -828,7 +827,22 @@ export function createRoutes(authConfig) {
828
827
  });
829
828
  }
830
829
  try {
831
- const authModule = await safeImportAuthConfig(authConfigPath);
830
+ let authModule;
831
+ try {
832
+ authModule = await safeImportAuthConfig(authConfigPath);
833
+ }
834
+ catch (importError) {
835
+ // Fallback: read file content directly
836
+ const content = readFileSync(authConfigPath, 'utf-8');
837
+ authModule = {
838
+ auth: {
839
+ options: {
840
+ _content: content,
841
+ plugins: []
842
+ }
843
+ }
844
+ };
845
+ }
832
846
  const auth = authModule.auth || authModule.default;
833
847
  if (!auth) {
834
848
  return res.json({
@@ -841,7 +855,6 @@ export function createRoutes(authConfig) {
841
855
  const pluginInfo = plugins.map((plugin) => ({
842
856
  id: plugin.id,
843
857
  name: plugin.name || plugin.id,
844
- version: plugin.version || 'unknown',
845
858
  description: plugin.description || `${plugin.id} plugin for Better Auth`,
846
859
  enabled: true
847
860
  }));
@@ -891,7 +904,7 @@ export function createRoutes(authConfig) {
891
904
  });
892
905
  router.get('/api/database/info', async (req, res) => {
893
906
  try {
894
- const authConfigPath = await findAuthConfigPath();
907
+ const authConfigPath = configPath || await findAuthConfigPath();
895
908
  if (!authConfigPath) {
896
909
  return res.json({
897
910
  database: null,
@@ -947,7 +960,7 @@ export function createRoutes(authConfig) {
947
960
  });
948
961
  router.get('/api/plugins/teams/status', async (req, res) => {
949
962
  try {
950
- const authConfigPath = await findAuthConfigPath();
963
+ const authConfigPath = configPath || await findAuthConfigPath();
951
964
  if (!authConfigPath) {
952
965
  return res.json({
953
966
  enabled: false,
@@ -956,7 +969,22 @@ export function createRoutes(authConfig) {
956
969
  });
957
970
  }
958
971
  try {
959
- const authModule = await safeImportAuthConfig(authConfigPath);
972
+ let authModule;
973
+ try {
974
+ authModule = await safeImportAuthConfig(authConfigPath);
975
+ }
976
+ catch (importError) {
977
+ // Fallback: read file content directly
978
+ const content = readFileSync(authConfigPath, 'utf-8');
979
+ authModule = {
980
+ auth: {
981
+ options: {
982
+ _content: content,
983
+ plugins: []
984
+ }
985
+ }
986
+ };
987
+ }
960
988
  const auth = authModule.auth || authModule.default;
961
989
  if (!auth) {
962
990
  return res.json({
@@ -1009,7 +1037,7 @@ export function createRoutes(authConfig) {
1009
1037
  router.get('/api/organizations/:orgId/invitations', async (req, res) => {
1010
1038
  try {
1011
1039
  const { orgId } = req.params;
1012
- const adapter = await getAuthAdapter();
1040
+ const adapter = await getAuthAdapterWithConfig();
1013
1041
  if (adapter && typeof adapter.findMany === 'function') {
1014
1042
  try {
1015
1043
  const invitations = await adapter.findMany({
@@ -1047,7 +1075,7 @@ export function createRoutes(authConfig) {
1047
1075
  router.get('/api/organizations/:orgId/members', async (req, res) => {
1048
1076
  try {
1049
1077
  const { orgId } = req.params;
1050
- const adapter = await getAuthAdapter();
1078
+ const adapter = await getAuthAdapterWithConfig();
1051
1079
  if (adapter && typeof adapter.findMany === 'function') {
1052
1080
  try {
1053
1081
  const members = await adapter.findMany({
@@ -1105,7 +1133,7 @@ export function createRoutes(authConfig) {
1105
1133
  try {
1106
1134
  const { orgId } = req.params;
1107
1135
  const { count = 5 } = req.body;
1108
- const adapter = await getAuthAdapter();
1136
+ const adapter = await getAuthAdapterWithConfig();
1109
1137
  if (!adapter) {
1110
1138
  return res.status(500).json({ error: 'Auth adapter not available' });
1111
1139
  }
@@ -1180,7 +1208,7 @@ export function createRoutes(authConfig) {
1180
1208
  try {
1181
1209
  const { orgId } = req.params;
1182
1210
  const { count = 3 } = req.body;
1183
- const adapter = await getAuthAdapter();
1211
+ const adapter = await getAuthAdapterWithConfig();
1184
1212
  if (!adapter) {
1185
1213
  return res.status(500).json({ error: 'Auth adapter not available' });
1186
1214
  }
@@ -1242,7 +1270,7 @@ export function createRoutes(authConfig) {
1242
1270
  router.delete('/api/members/:id', async (req, res) => {
1243
1271
  try {
1244
1272
  const { id } = req.params;
1245
- const adapter = await getAuthAdapter();
1273
+ const adapter = await getAuthAdapterWithConfig();
1246
1274
  if (!adapter) {
1247
1275
  return res.status(500).json({ error: 'Auth adapter not available' });
1248
1276
  }
@@ -1263,7 +1291,7 @@ export function createRoutes(authConfig) {
1263
1291
  router.post('/api/invitations/:id/resend', async (req, res) => {
1264
1292
  try {
1265
1293
  const { id } = req.params;
1266
- const adapter = await getAuthAdapter();
1294
+ const adapter = await getAuthAdapterWithConfig();
1267
1295
  if (!adapter) {
1268
1296
  return res.status(500).json({ error: 'Auth adapter not available' });
1269
1297
  }
@@ -1288,7 +1316,7 @@ export function createRoutes(authConfig) {
1288
1316
  router.delete('/api/invitations/:id', async (req, res) => {
1289
1317
  try {
1290
1318
  const { id } = req.params;
1291
- const adapter = await getAuthAdapter();
1319
+ const adapter = await getAuthAdapterWithConfig();
1292
1320
  if (!adapter) {
1293
1321
  return res.status(500).json({ error: 'Auth adapter not available' });
1294
1322
  }
@@ -1317,7 +1345,7 @@ export function createRoutes(authConfig) {
1317
1345
  if (!inviterId) {
1318
1346
  return res.status(400).json({ error: 'Inviter ID is required' });
1319
1347
  }
1320
- const adapter = await getAuthAdapter();
1348
+ const adapter = await getAuthAdapterWithConfig();
1321
1349
  if (!adapter) {
1322
1350
  return res.status(500).json({ error: 'Auth adapter not available' });
1323
1351
  }
@@ -1359,7 +1387,7 @@ export function createRoutes(authConfig) {
1359
1387
  router.get('/api/organizations/:orgId/teams', async (req, res) => {
1360
1388
  try {
1361
1389
  const { orgId } = req.params;
1362
- const adapter = await getAuthAdapter();
1390
+ const adapter = await getAuthAdapterWithConfig();
1363
1391
  if (adapter && typeof adapter.findMany === 'function') {
1364
1392
  try {
1365
1393
  const teams = await adapter.findMany({
@@ -1404,7 +1432,7 @@ export function createRoutes(authConfig) {
1404
1432
  try {
1405
1433
  const { orgId } = req.params;
1406
1434
  const { name } = req.body;
1407
- const adapter = await getAuthAdapter();
1435
+ const adapter = await getAuthAdapterWithConfig();
1408
1436
  if (!adapter) {
1409
1437
  return res.status(500).json({ error: 'Auth adapter not available' });
1410
1438
  }
@@ -1441,7 +1469,7 @@ export function createRoutes(authConfig) {
1441
1469
  router.get('/api/teams/:teamId/members', async (req, res) => {
1442
1470
  try {
1443
1471
  const { teamId } = req.params;
1444
- const adapter = await getAuthAdapter();
1472
+ const adapter = await getAuthAdapterWithConfig();
1445
1473
  if (adapter && typeof adapter.findMany === 'function') {
1446
1474
  try {
1447
1475
  const teamMembers = await adapter.findMany({
@@ -1502,7 +1530,7 @@ export function createRoutes(authConfig) {
1502
1530
  if (!Array.isArray(userIds) || userIds.length === 0) {
1503
1531
  return res.status(400).json({ error: 'userIds array is required' });
1504
1532
  }
1505
- const adapter = await getAuthAdapter();
1533
+ const adapter = await getAuthAdapterWithConfig();
1506
1534
  if (!adapter || !adapter.create) {
1507
1535
  return res.status(500).json({ error: 'Adapter not available' });
1508
1536
  }
@@ -1542,7 +1570,7 @@ export function createRoutes(authConfig) {
1542
1570
  router.delete('/api/team-members/:id', async (req, res) => {
1543
1571
  try {
1544
1572
  const { id } = req.params;
1545
- const adapter = await getAuthAdapter();
1573
+ const adapter = await getAuthAdapterWithConfig();
1546
1574
  if (!adapter || !adapter.delete) {
1547
1575
  return res.status(500).json({ error: 'Adapter not available' });
1548
1576
  }
@@ -1561,7 +1589,7 @@ export function createRoutes(authConfig) {
1561
1589
  try {
1562
1590
  const { id } = req.params;
1563
1591
  const { name } = req.body;
1564
- const adapter = await getAuthAdapter();
1592
+ const adapter = await getAuthAdapterWithConfig();
1565
1593
  if (!adapter) {
1566
1594
  return res.status(500).json({ error: 'Auth adapter not available' });
1567
1595
  }
@@ -1589,7 +1617,7 @@ export function createRoutes(authConfig) {
1589
1617
  router.delete('/api/teams/:id', async (req, res) => {
1590
1618
  try {
1591
1619
  const { id } = req.params;
1592
- const adapter = await getAuthAdapter();
1620
+ const adapter = await getAuthAdapterWithConfig();
1593
1621
  if (!adapter) {
1594
1622
  return res.status(500).json({ error: 'Auth adapter not available' });
1595
1623
  }
@@ -1609,7 +1637,7 @@ export function createRoutes(authConfig) {
1609
1637
  });
1610
1638
  router.get('/api/plugins/organization/status', async (req, res) => {
1611
1639
  try {
1612
- const authConfigPath = await findAuthConfigPath();
1640
+ const authConfigPath = configPath || await findAuthConfigPath();
1613
1641
  if (!authConfigPath) {
1614
1642
  return res.json({
1615
1643
  enabled: false,
@@ -1618,7 +1646,23 @@ export function createRoutes(authConfig) {
1618
1646
  });
1619
1647
  }
1620
1648
  try {
1621
- const authModule = await safeImportAuthConfig(authConfigPath);
1649
+ // Use the same logic as the /api/plugins endpoint
1650
+ let authModule;
1651
+ try {
1652
+ authModule = await safeImportAuthConfig(authConfigPath);
1653
+ }
1654
+ catch (importError) {
1655
+ // Fallback: read file content directly
1656
+ const content = readFileSync(authConfigPath, 'utf-8');
1657
+ authModule = {
1658
+ auth: {
1659
+ options: {
1660
+ _content: content,
1661
+ plugins: []
1662
+ }
1663
+ }
1664
+ };
1665
+ }
1622
1666
  const auth = authModule.auth || authModule.default;
1623
1667
  if (!auth) {
1624
1668
  return res.json({
@@ -1627,11 +1671,12 @@ export function createRoutes(authConfig) {
1627
1671
  configPath: authConfigPath
1628
1672
  });
1629
1673
  }
1630
- const hasOrganizationPlugin = auth.options?.plugins?.find((plugin) => plugin.id === "organization");
1674
+ const plugins = auth.options?.plugins || [];
1675
+ const hasOrganizationPlugin = plugins.find((plugin) => plugin.id === "organization");
1631
1676
  res.json({
1632
1677
  enabled: !!hasOrganizationPlugin,
1633
1678
  configPath: authConfigPath,
1634
- availablePlugins: auth.options?.plugins?.map((p) => p.id) || [],
1679
+ availablePlugins: plugins.map((p) => p.id) || [],
1635
1680
  organizationPlugin: hasOrganizationPlugin || null
1636
1681
  });
1637
1682
  }
@@ -1674,7 +1719,7 @@ export function createRoutes(authConfig) {
1674
1719
  const limit = parseInt(req.query.limit) || 20;
1675
1720
  const search = req.query.search;
1676
1721
  try {
1677
- const adapter = await getAuthAdapter();
1722
+ const adapter = await getAuthAdapterWithConfig();
1678
1723
  if (adapter && typeof adapter.findMany === 'function') {
1679
1724
  const allOrganizations = await adapter.findMany({ model: 'organization' });
1680
1725
  let filteredOrganizations = allOrganizations || [];
@@ -1727,7 +1772,7 @@ export function createRoutes(authConfig) {
1727
1772
  });
1728
1773
  router.post('/api/organizations', async (req, res) => {
1729
1774
  try {
1730
- const adapter = await getAuthAdapter();
1775
+ const adapter = await getAuthAdapterWithConfig();
1731
1776
  if (!adapter) {
1732
1777
  return res.status(500).json({ error: 'Auth adapter not available' });
1733
1778
  }
@@ -1747,7 +1792,7 @@ export function createRoutes(authConfig) {
1747
1792
  try {
1748
1793
  const { id } = req.params;
1749
1794
  const orgData = req.body;
1750
- const adapter = await getAuthAdapter();
1795
+ const adapter = await getAuthAdapterWithConfig();
1751
1796
  if (!adapter) {
1752
1797
  return res.status(500).json({ error: 'Auth adapter not available' });
1753
1798
  }
@@ -1776,7 +1821,7 @@ export function createRoutes(authConfig) {
1776
1821
  router.delete('/api/organizations/:id', async (req, res) => {
1777
1822
  try {
1778
1823
  const { id } = req.params;
1779
- const adapter = await getAuthAdapter();
1824
+ const adapter = await getAuthAdapterWithConfig();
1780
1825
  if (!adapter) {
1781
1826
  return res.status(500).json({ error: 'Auth adapter not available' });
1782
1827
  }
@@ -1795,7 +1840,7 @@ export function createRoutes(authConfig) {
1795
1840
  });
1796
1841
  router.post('/api/users', async (req, res) => {
1797
1842
  try {
1798
- const adapter = await getAuthAdapter();
1843
+ const adapter = await getAuthAdapterWithConfig();
1799
1844
  if (!adapter) {
1800
1845
  return res.status(500).json({ error: 'Auth adapter not available' });
1801
1846
  }
@@ -1812,7 +1857,7 @@ export function createRoutes(authConfig) {
1812
1857
  try {
1813
1858
  const { id } = req.params;
1814
1859
  const userData = req.body;
1815
- const updatedUser = await getAuthData(authConfig, 'updateUser', { id, userData });
1860
+ const updatedUser = await getAuthData(authConfig, 'updateUser', { id, userData }, configPath);
1816
1861
  res.json({ success: true, user: updatedUser });
1817
1862
  }
1818
1863
  catch (error) {
@@ -1823,7 +1868,7 @@ export function createRoutes(authConfig) {
1823
1868
  router.post('/api/seed/users', async (req, res) => {
1824
1869
  try {
1825
1870
  const { count = 1 } = req.body;
1826
- const adapter = await getAuthAdapter();
1871
+ const adapter = await getAuthAdapterWithConfig();
1827
1872
  if (!adapter) {
1828
1873
  return res.status(500).json({ error: 'Auth adapter not available' });
1829
1874
  }
@@ -1867,7 +1912,7 @@ export function createRoutes(authConfig) {
1867
1912
  router.post('/api/seed/sessions', async (req, res) => {
1868
1913
  try {
1869
1914
  const { count = 1 } = req.body;
1870
- const adapter = await getAuthAdapter();
1915
+ const adapter = await getAuthAdapterWithConfig();
1871
1916
  if (!adapter) {
1872
1917
  return res.status(500).json({ error: 'Auth adapter not available' });
1873
1918
  }
@@ -1917,7 +1962,7 @@ export function createRoutes(authConfig) {
1917
1962
  router.post('/api/seed/accounts', async (req, res) => {
1918
1963
  try {
1919
1964
  const { count = 1 } = req.body;
1920
- const adapter = await getAuthAdapter();
1965
+ const adapter = await getAuthAdapterWithConfig();
1921
1966
  if (!adapter) {
1922
1967
  return res.status(500).json({ error: 'Auth adapter not available' });
1923
1968
  }
@@ -1968,7 +2013,7 @@ export function createRoutes(authConfig) {
1968
2013
  router.post('/api/seed/verifications', async (req, res) => {
1969
2014
  try {
1970
2015
  const { count = 1 } = req.body;
1971
- const adapter = await getAuthAdapter();
2016
+ const adapter = await getAuthAdapterWithConfig();
1972
2017
  if (!adapter) {
1973
2018
  return res.status(500).json({ error: 'Auth adapter not available' });
1974
2019
  }
@@ -2011,7 +2056,7 @@ export function createRoutes(authConfig) {
2011
2056
  router.post('/api/seed/organizations', async (req, res) => {
2012
2057
  try {
2013
2058
  const { count = 1 } = req.body;
2014
- const adapter = await getAuthAdapter();
2059
+ const adapter = await getAuthAdapterWithConfig();
2015
2060
  if (!adapter) {
2016
2061
  return res.status(500).json({ error: 'Auth adapter not available' });
2017
2062
  }