@zodic/shared 0.0.118 → 0.0.119
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/app/api/astrology/index.ts +22 -23
- package/app/api/index.ts +37 -5
- package/db/schema.ts +0 -3
- package/package.json +1 -1
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import { BackendBindings } from '
|
|
1
|
+
import { BackendBindings } from '../../../types';
|
|
2
2
|
|
|
3
3
|
export async function makeAstrologyApiCall(
|
|
4
4
|
path: string,
|
|
5
|
-
payload: any
|
|
6
|
-
env: BackendBindings
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)}`;
|
|
5
|
+
payload: any,
|
|
6
|
+
env: BackendBindings,
|
|
7
|
+
language: string
|
|
8
|
+
) {
|
|
9
|
+
const shortLanguage = language.slice(0, 2); // Extracts only "en" or "pt"
|
|
11
10
|
|
|
12
|
-
const
|
|
11
|
+
const endpoint = `https://astrologyapi.com/api/${path}`;
|
|
12
|
+
const headers = {
|
|
13
|
+
Authorization: `Bearer ${env.ASTROLOGY_WESTERN_API_KEY}`,
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
'Accept-Language': shortLanguage, // Sends "en" or "pt"
|
|
16
|
+
};
|
|
13
17
|
|
|
14
18
|
try {
|
|
15
|
-
const response = await fetch(
|
|
16
|
-
method:
|
|
17
|
-
headers
|
|
18
|
-
|
|
19
|
-
Authorization: auth,
|
|
20
|
-
'Accept-Language': 'en',
|
|
21
|
-
},
|
|
22
|
-
body: payload ? JSON.stringify(payload) : undefined,
|
|
19
|
+
const response = await fetch(endpoint, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers,
|
|
22
|
+
body: JSON.stringify(payload),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
if (!response.ok) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
26
|
+
const error = await response.json();
|
|
27
|
+
console.error('Astrology API Error:', error);
|
|
28
|
+
throw new Error(`Astrology API Error: ${response.status}`);
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
return await response.json();
|
|
33
|
-
} catch (
|
|
34
|
-
console.error(
|
|
35
|
-
throw
|
|
32
|
+
} catch (err: any) {
|
|
33
|
+
console.error('Error calling Astrology API:', err.message);
|
|
34
|
+
throw err;
|
|
36
35
|
}
|
|
37
36
|
}
|
package/app/api/index.ts
CHANGED
|
@@ -390,6 +390,7 @@ export const Api = (env: BackendBindings) => ({
|
|
|
390
390
|
lat,
|
|
391
391
|
lon,
|
|
392
392
|
tzone,
|
|
393
|
+
language = 'en-us', // Default to English
|
|
393
394
|
}: {
|
|
394
395
|
day: number;
|
|
395
396
|
month: number;
|
|
@@ -399,11 +400,17 @@ export const Api = (env: BackendBindings) => ({
|
|
|
399
400
|
lat: number;
|
|
400
401
|
lon: number;
|
|
401
402
|
tzone: number;
|
|
403
|
+
language?: 'en-us' | 'pt-br';
|
|
402
404
|
}): Promise<NatalChartInterpretation> => {
|
|
403
405
|
const path = `natal_chart_interpretation`;
|
|
404
406
|
const payload = { day, month, year, hour, min, lat, lon, tzone };
|
|
405
407
|
|
|
406
|
-
return makeAstrologyApiCall(
|
|
408
|
+
return (await makeAstrologyApiCall(
|
|
409
|
+
path,
|
|
410
|
+
payload,
|
|
411
|
+
env,
|
|
412
|
+
language
|
|
413
|
+
)) as NatalChartInterpretation;
|
|
407
414
|
},
|
|
408
415
|
|
|
409
416
|
getHouseCuspsReport: async ({
|
|
@@ -415,6 +422,7 @@ export const Api = (env: BackendBindings) => ({
|
|
|
415
422
|
lat,
|
|
416
423
|
lon,
|
|
417
424
|
tzone,
|
|
425
|
+
language = 'en-us',
|
|
418
426
|
}: {
|
|
419
427
|
day: number;
|
|
420
428
|
month: number;
|
|
@@ -424,11 +432,17 @@ export const Api = (env: BackendBindings) => ({
|
|
|
424
432
|
lat: number;
|
|
425
433
|
lon: number;
|
|
426
434
|
tzone: number;
|
|
435
|
+
language?: 'en-us' | 'pt-br';
|
|
427
436
|
}): Promise<HouseCuspsReport[]> => {
|
|
428
437
|
const path = `house_cusps_report/tropical`;
|
|
429
438
|
const payload = { day, month, year, hour, min, lat, lon, tzone };
|
|
430
439
|
|
|
431
|
-
return makeAstrologyApiCall(
|
|
440
|
+
return (await makeAstrologyApiCall(
|
|
441
|
+
path,
|
|
442
|
+
payload,
|
|
443
|
+
env,
|
|
444
|
+
language
|
|
445
|
+
)) as HouseCuspsReport[];
|
|
432
446
|
},
|
|
433
447
|
|
|
434
448
|
getNatalHouseCuspReports: async ({
|
|
@@ -440,6 +454,7 @@ export const Api = (env: BackendBindings) => ({
|
|
|
440
454
|
lat,
|
|
441
455
|
lon,
|
|
442
456
|
tzone,
|
|
457
|
+
language = 'en-us',
|
|
443
458
|
}: {
|
|
444
459
|
day: number;
|
|
445
460
|
month: number;
|
|
@@ -449,11 +464,17 @@ export const Api = (env: BackendBindings) => ({
|
|
|
449
464
|
lat: number;
|
|
450
465
|
lon: number;
|
|
451
466
|
tzone: number;
|
|
467
|
+
language?: 'en-us' | 'pt-br';
|
|
452
468
|
}): Promise<NatalHouseCuspReport[]> => {
|
|
453
469
|
const path = `natal_house_cusp_report`;
|
|
454
470
|
const payload = { day, month, year, hour, min, lat, lon, tzone };
|
|
455
471
|
|
|
456
|
-
return makeAstrologyApiCall(
|
|
472
|
+
return (await makeAstrologyApiCall(
|
|
473
|
+
path,
|
|
474
|
+
payload,
|
|
475
|
+
env,
|
|
476
|
+
language
|
|
477
|
+
)) as NatalHouseCuspReport[];
|
|
457
478
|
},
|
|
458
479
|
|
|
459
480
|
getPlanetSignReport: async ({
|
|
@@ -466,6 +487,7 @@ export const Api = (env: BackendBindings) => ({
|
|
|
466
487
|
lat,
|
|
467
488
|
lon,
|
|
468
489
|
tzone,
|
|
490
|
+
language = 'en-us',
|
|
469
491
|
}: {
|
|
470
492
|
planetName: string;
|
|
471
493
|
day: number;
|
|
@@ -476,11 +498,16 @@ export const Api = (env: BackendBindings) => ({
|
|
|
476
498
|
lat: number;
|
|
477
499
|
lon: number;
|
|
478
500
|
tzone: number;
|
|
501
|
+
language?: 'en-us' | 'pt-br';
|
|
479
502
|
}): Promise<{ planet_name: string; sign: string; report: string }> => {
|
|
480
503
|
const path = `general_sign_report/tropical/${planetName}`;
|
|
481
504
|
const payload = { day, month, year, hour, min, lat, lon, tzone };
|
|
482
505
|
|
|
483
|
-
return makeAstrologyApiCall(path, payload, env)
|
|
506
|
+
return (await makeAstrologyApiCall(path, payload, env, language)) as {
|
|
507
|
+
planet_name: string;
|
|
508
|
+
sign: string;
|
|
509
|
+
report: string;
|
|
510
|
+
};
|
|
484
511
|
},
|
|
485
512
|
|
|
486
513
|
getAscendantReport: async ({
|
|
@@ -492,6 +519,7 @@ export const Api = (env: BackendBindings) => ({
|
|
|
492
519
|
lat,
|
|
493
520
|
lon,
|
|
494
521
|
tzone,
|
|
522
|
+
language = 'en-us',
|
|
495
523
|
}: {
|
|
496
524
|
day: number;
|
|
497
525
|
month: number;
|
|
@@ -501,11 +529,15 @@ export const Api = (env: BackendBindings) => ({
|
|
|
501
529
|
lat: number;
|
|
502
530
|
lon: number;
|
|
503
531
|
tzone: number;
|
|
532
|
+
language?: 'en-us' | 'pt-br';
|
|
504
533
|
}): Promise<{ ascendant: string; report: string }> => {
|
|
505
534
|
const path = `general_ascendant_report/tropical`;
|
|
506
535
|
const payload = { day, month, year, hour, min, lat, lon, tzone };
|
|
507
536
|
|
|
508
|
-
return makeAstrologyApiCall(path, payload, env)
|
|
537
|
+
return (await makeAstrologyApiCall(path, payload, env, language)) as {
|
|
538
|
+
ascendant: string;
|
|
539
|
+
report: string;
|
|
540
|
+
};
|
|
509
541
|
},
|
|
510
542
|
},
|
|
511
543
|
|
package/db/schema.ts
CHANGED
|
@@ -98,8 +98,6 @@ export const astroPlanets = sqliteTable(
|
|
|
98
98
|
normDegree: real('norm_degree'), // Degree within the sign (0-29°)
|
|
99
99
|
speed: real('speed'), // Speed of the planet
|
|
100
100
|
isRetro: integer('is_retro'), // 0 (false) or 1 (true) for retrograde
|
|
101
|
-
signReport: text('sign_report'), // NEW: Report for the planet's sign
|
|
102
|
-
houseReport: text('house_report'), // NEW: Report for the planet's house
|
|
103
101
|
},
|
|
104
102
|
(t) => [index('astro_planets_user_id_idx').on(t.userId)]
|
|
105
103
|
);
|
|
@@ -114,7 +112,6 @@ export const astroHouses = sqliteTable(
|
|
|
114
112
|
house: integer('house').notNull(), // House number (1-12)
|
|
115
113
|
sign: text('sign').notNull(), // Sign ruling the house (e.g., "Sagittarius")
|
|
116
114
|
degree: real('degree').notNull(), // Starting degree of the house
|
|
117
|
-
signReport: text('sign_report'), // NEW: Report for the house's sign
|
|
118
115
|
},
|
|
119
116
|
(t) => [index('astro_houses_user_id_idx').on(t.userId)]
|
|
120
117
|
);
|