@bhooai/nexus-core 2.0.18 → 2.0.21

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.
@@ -25,6 +25,57 @@ describe('configFromEnv', () => {
25
25
  expect((cfg as any).ai?.serverUrl).toBe('http://ai:8000');
26
26
  expect((cfg as any).ai?.server?.url).toBeUndefined();
27
27
  });
28
+
29
+ it('accepts a numeric Meta App ID for auth.facebook.clientId', () => {
30
+ // Env coercion turns all-digit values into numbers; the schema must
31
+ // coerce them back so boot does not crash (ZodError on auth.facebook.clientId).
32
+ const partial = configFromEnv({ NEXUS_AUTH_FACEBOOK_CLIENT_ID: '123456789012345' });
33
+ expect((partial as any).auth?.facebook?.clientId).toBe(123456789012345);
34
+ const cfg = mergeConfig({
35
+ auth: {
36
+ facebook: {
37
+ clientId: (partial as any).auth.facebook.clientId,
38
+ clientSecret: 's3cret',
39
+ callbackPath: '/auth/facebook/callback',
40
+ scope: 'email',
41
+ },
42
+ },
43
+ });
44
+ expect(cfg.auth.facebook?.clientId).toBe('123456789012345');
45
+ });
46
+ });
47
+
48
+ describe('app identity derivation', () => {
49
+ it('derives auth/redis/mongo/email identity from app.name', () => {
50
+ const cfg = mergeConfig({ app: { name: 'my-app' } });
51
+ expect(cfg.app.name).toBe('my-app');
52
+ expect(cfg.auth.jwt.issuer).toBe('my-app');
53
+ expect(cfg.auth.jwt.audience).toBe('my-app-client');
54
+ expect(cfg.auth.cookieName).toBe('my-app_sid');
55
+ expect(cfg.auth.refreshCookieName).toBe('my-app_rid');
56
+ expect(cfg.redis.keyPrefix).toBe('my-app:');
57
+ expect(cfg.db.mongodb.uri).toBe('mongodb://localhost:27017/my-app');
58
+ expect(cfg.email.from).toBe('no-reply@my-app.local');
59
+ });
60
+
61
+ it('lets an explicit mongo uri override the derived one', () => {
62
+ const cfg = mergeConfig({
63
+ app: { name: 'my-app' },
64
+ db: { mongodb: { uri: 'mongodb://remote:27017/custom' } },
65
+ });
66
+ expect(cfg.db.mongodb.uri).toBe('mongodb://remote:27017/custom');
67
+ });
68
+
69
+ it('lets an explicit value override the derived default', () => {
70
+ const cfg = mergeConfig({ app: { name: 'my-app' }, auth: { cookieName: 'custom_sid' } });
71
+ expect(cfg.auth.cookieName).toBe('custom_sid');
72
+ expect(cfg.auth.jwt.issuer).toBe('my-app');
73
+ });
74
+
75
+ it('defaults app.name to nexus when unset', () => {
76
+ const cfg = mergeConfig({});
77
+ expect(cfg.app.name).toBe('nexus');
78
+ });
28
79
  });
29
80
 
30
81
  describe('mergeConfig', () => {