astrology-insights 1.1.2 → 2.0.0

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.
Files changed (46) hide show
  1. package/Readme.md +208 -144
  2. package/api/panchang.js +56 -0
  3. package/dist/panchang/src/core/constants.d.ts +26 -0
  4. package/dist/panchang/src/core/constants.js +165 -0
  5. package/dist/panchang/src/core/karana.d.ts +6 -0
  6. package/dist/panchang/src/core/karana.js +23 -0
  7. package/dist/panchang/src/core/nakshatra.d.ts +10 -0
  8. package/dist/panchang/src/core/nakshatra.js +21 -0
  9. package/dist/panchang/src/core/rashi.d.ts +2 -0
  10. package/dist/panchang/src/core/rashi.js +17 -0
  11. package/dist/panchang/src/core/tithi.d.ts +8 -0
  12. package/dist/panchang/src/core/tithi.js +36 -0
  13. package/dist/panchang/src/core/yoga.d.ts +6 -0
  14. package/dist/panchang/src/core/yoga.js +16 -0
  15. package/dist/panchang/src/monthly.d.ts +12 -0
  16. package/dist/panchang/src/monthly.js +110 -0
  17. package/dist/panchang/src/panchang-v2.d.ts +2 -0
  18. package/dist/panchang/src/panchang-v2.js +296 -0
  19. package/dist/panchang/src/timings/kalam.d.ts +21 -0
  20. package/dist/panchang/src/timings/kalam.js +114 -0
  21. package/dist/panchang/src/timings/muhurat.d.ts +21 -0
  22. package/dist/panchang/src/timings/muhurat.js +134 -0
  23. package/dist/panchang/src/types.d.ts +123 -0
  24. package/dist/panchang/src/types.js +7 -0
  25. package/index.js +17 -1
  26. package/index.rn.js +64 -0
  27. package/lib/abhijeetMuhurt.js +4 -8
  28. package/lib/durMuhurtam.js +3 -3
  29. package/lib/gulikaKalam.js +35 -14
  30. package/package.json +40 -7
  31. package/panchang/src/core/constants.ts +181 -0
  32. package/panchang/src/core/karana.ts +27 -0
  33. package/panchang/src/core/nakshatra.ts +28 -0
  34. package/panchang/src/core/rashi.ts +15 -0
  35. package/panchang/src/core/tithi.ts +42 -0
  36. package/panchang/src/core/yoga.ts +19 -0
  37. package/panchang/src/index.ts +10 -0
  38. package/panchang/src/monthly.ts +117 -0
  39. package/panchang/src/panchang-v2.ts +315 -0
  40. package/panchang/src/timings/kalam.ts +135 -0
  41. package/panchang/src/timings/muhurat.ts +156 -0
  42. package/panchang/src/types.ts +124 -0
  43. package/assets/constants.js +0 -22
  44. package/assets/utils.js +0 -16
  45. package/assets/weekdays.js +0 -4
  46. package/test.js +0 -99
package/Readme.md CHANGED
@@ -1,218 +1,282 @@
1
- ---
1
+ # Astrology Insights v2.0.0
2
2
 
3
- ## Astrology Insights for JavaScript 🌌
4
-
5
- **Astrology Insights** is a Node.js library for computing astrological and astronomical events. It includes:
6
-
7
- - **Biorhythm Calculations** for physical, emotional, intellectual, and intuitive cycles
8
- - **Sunrise/Sunset** times for any date and location
9
- - **Abhijit Muhurat** (auspicious period of the day)
10
- - **Choghadiya** segments for day and night (Vedic astrology)
3
+ A comprehensive Node.js library for Vedic Panchang, astronomical calculations, and astrological insights. Uses Swiss Ephemeris for precision and is validated against Drik Panchang.
11
4
 
12
5
  ## Installation
13
6
 
14
- Install via npm:
15
7
  ```bash
16
8
  npm install astrology-insights
17
9
  ```
18
10
 
19
- ## Usage
20
-
21
- ### Biorhythm Calculations
22
- ```js
23
- const { calculateBioRhythms } = require('astrology-insights');
11
+ **Requirements:** Node.js >= 16
24
12
 
25
- const timezone = 'UTC';
26
- const dob = '1994-11-11';
27
- const today = '2024-12-06';
28
- const days = 30;
13
+ ## Quick Start
29
14
 
30
- const rhythms = calculateBioRhythms(today, dob, timezone, days);
31
- console.log(rhythms);
15
+ ```javascript
16
+ const { calculateFullPanchang } = require("astrology-insights");
17
+
18
+ const result = calculateFullPanchang("2026-03-21", 28.6139, 77.209, "Asia/Kolkata");
19
+ console.log(result.tithi[0].name); // "Shukla Tritiya"
20
+ console.log(result.nakshatra[0].name); // "Ashwini"
21
+ console.log(result.yoga[0].name); // "Indra"
22
+ console.log(result.karana[0].name); // "Taitila"
23
+ console.log(result.vara.name); // "Saturday"
24
+ console.log(result.moonSign.name); // "Aries"
25
+ console.log(result.sunSign.name); // "Pisces"
26
+ console.log(result.paksha); // "Shukla"
27
+ console.log(result.sunrise); // "06:25"
28
+ console.log(result.sunset); // "18:33"
29
+ console.log(result.ayana); // "Uttarayana"
30
+ console.log(result.ritu); // { vedic: "Vasanta", english: "Spring" }
31
+ console.log(result.samvatsar); // "Siddharthi"
32
+ console.log(result.vikramSamvat); // 2083
33
+ console.log(result.dinamana); // "12h 08m"
32
34
  ```
33
35
 
34
- ### Sunrise and Sunset
35
- ```js
36
- const { calculateSunriseSunset } = require('astrology-insights');
36
+ ## Features
37
+
38
+ ### Full Panchang (`calculateFullPanchang`)
37
39
 
38
- const date = '2024-11-24';
39
- const lat = 28.6139;
40
- const lon = 77.2090;
41
- const tz = 'Asia/Kolkata';
40
+ Computes the complete daily Panchang for any date and location.
42
41
 
43
- const { sunrise, sunset } = calculateSunriseSunset(date, lat, lon, tz);
44
- console.log(`Sunrise: ${sunrise}, Sunset: ${sunset}`);
42
+ ```javascript
43
+ calculateFullPanchang(date, latitude, longitude, timezone)
45
44
  ```
46
45
 
47
- ---
46
+ **Parameters:**
47
+ | Param | Type | Example |
48
+ |---|---|---|
49
+ | `date` | `string \| Date` | `"2026-03-21"` |
50
+ | `latitude` | `number` | `28.6139` |
51
+ | `longitude` | `number` | `77.209` |
52
+ | `timezone` | `string` | `"Asia/Kolkata"` |
53
+
54
+ **Returns `PanchangResult` with:**
55
+
56
+ | Field | Description |
57
+ |---|---|
58
+ | `tithi` | Lunar day: name, number, paksha, progress % |
59
+ | `nakshatra` | Lunar mansion: name, pada (1-4), lord, deity, progress % |
60
+ | `yoga` | Sun-Moon conjunction: name, number (1-27), progress % |
61
+ | `karana` | Half-tithi: name, number, progress % |
62
+ | `vara` | Weekday: name and number |
63
+ | `moonSign` / `sunSign` | Zodiac sign with lord and degree |
64
+ | `moonPhase` | Phase name and illumination % |
65
+ | `paksha` | Shukla or Krishna |
66
+ | `sunrise` / `sunset` | HH:mm format |
67
+ | `moonrise` / `moonset` | HH:mm format |
68
+ | `auspiciousMuhurats` | Array of Brahma, Pratah Sandhya, Abhijit, Vijaya, Godhuli, Sayahna Sandhya, Nishita |
69
+ | `inauspiciousKalams` | Array of Rahu Kalam, Gulika Kalam, Yamaganda, Varjyam, Dur Muhurtam |
70
+ | `sunNakshatra` | Sun's nakshatra with pada, lord, deity |
71
+ | `ayana` | Uttarayana or Dakshinayana |
72
+ | `ritu` | Season: vedic name and English translation |
73
+ | `solarMonth` | Solar month name (Mesha, Vrishabha, etc.) |
74
+ | `dinamana` / `ratrimana` | Day/night duration |
75
+ | `madhyahna` | Solar noon |
76
+ | `samvatsar` | Name of the 60-year cycle year |
77
+ | `vikramSamvat` / `shakaSamvat` | Calendar years |
78
+
79
+ ### Monthly Panchang (`calculateMonthlyPanchang`)
80
+
81
+ Compute Panchang for every day in a month.
48
82
 
49
- ## Installation 📦
83
+ ```javascript
84
+ const { calculateMonthlyPanchang } = require("astrology-insights");
50
85
 
51
- Install the package using npm:
86
+ const month = calculateMonthlyPanchang(2026, 3, 28.6139, 77.209, "Asia/Kolkata");
87
+ // Returns: { year, month, location, days: PanchangResult[] }
52
88
 
53
- ```bash
54
- npm install astrology-insights
89
+ month.days.forEach(day => {
90
+ console.log(`${day.date}: ${day.tithi[0].name} | ${day.nakshatra[0].name}`);
91
+ });
55
92
  ```
56
93
 
57
- ---
94
+ ### Individual Core Modules
58
95
 
59
- ## Usage 🛠️
96
+ For direct calculation from raw sidereal longitudes:
60
97
 
61
- Here’s how you can use the features of this toolkit:
98
+ ```javascript
99
+ const {
100
+ calculateTithi,
101
+ calculateNakshatraV2,
102
+ calculateYoga,
103
+ calculateKarana,
104
+ calculateRashi,
105
+ } = require("astrology-insights");
62
106
 
63
- ### 1. Biorhythm Calculations
107
+ const tithi = calculateTithi(335.5, 359.8);
108
+ // { name: "Shukla Tritiya", number: 3, paksha: "Shukla", progress: 2.5 }
64
109
 
65
- ```javascript
66
- const { calculateBioRhythms } = require("astrology-insights");
110
+ const nakshatra = calculateNakshatraV2(355.0);
111
+ // { name: "Revati", number: 27, pada: 3, lord: "Mercury", deity: "Pushan" }
67
112
 
68
- const timezone = "UTC";
69
- const dob = "1994-11-11";
70
- const currentDate = "2024-12-06";
71
- const daysToDisplay = 30;
113
+ const yoga = calculateYoga(335.5, 359.8);
114
+ // { name: "Indra", number: 26, progress: 14.8 }
72
115
 
73
- const biorhythms = calculateBioRhythms(currentDate, dob, timezone, daysToDisplay);
74
- console.log(biorhythms);
75
- ```
116
+ const karana = calculateKarana(335.5, 359.8);
117
+ // { name: "Kaulava", number: 3, progress: 5.0 }
76
118
 
77
- **Output**:
78
- ```json
79
- {
80
- "survivalDays": 12058,
81
- "data": [
82
- {
83
- "label": "Physical",
84
- "borderColor": "#FF0000",
85
- "description": "Represents your physical energy, strength, and stamina.",
86
- "data": [
87
- { "dayOffset": 0, "value": 89 },
88
- ...
89
- ]
90
- },
91
- ...
92
- ]
93
- }
119
+ const rashi = calculateRashi(355.0);
120
+ // { name: "Pisces", lord: "Jupiter", degree: 25 }
94
121
  ```
95
122
 
123
+ ### Legacy Functions
124
+
125
+ These functions remain available and work with `HH:mm:ss` time strings.
96
126
 
97
- ### Importing the Library for Astrology Numbers
127
+ #### `calculateSunriseSunset(date, latitude, longitude, timezone)`
98
128
 
99
129
  ```javascript
100
- const {
101
- calculateSunriseSunset,
102
- calculateMoonriseMoonset,
103
- calculateMoonPosition,
104
- calculateNakshatras,
105
- calculateAbhijeetMuhurt,
106
- calculateChoghadiya
107
- } = require("astrology-insights");
130
+ const { calculateSunriseSunset } = require("astrology-insights");
131
+ const { sunrise, sunset } = calculateSunriseSunset("2026-03-21", 28.6139, 77.209, "Asia/Kolkata");
132
+ // sunrise: "06:25:46", sunset: "18:33:45"
108
133
  ```
109
134
 
110
- ### 1. **Calculate Sunrise and Sunset**
135
+ #### `calculateChoghadiya(date, sunrise, sunset, timezone)`
111
136
 
112
137
  ```javascript
113
- const date = "2024-11-24";
114
- const latitude = 28.6139; // Example: New Delhi
115
- const longitude = 77.2090;
116
- const timezone = "Asia/Kolkata";
117
-
118
- const { sunrise, sunset } = calculateSunriseSunset(date, latitude, longitude, timezone);
119
- console.log(`Sunrise: ${sunrise}, Sunset: ${sunset}`);
138
+ const { calculateChoghadiya } = require("astrology-insights");
139
+ const result = calculateChoghadiya("2026-03-21", sunrise, sunset, "Asia/Kolkata");
140
+ // result.daytimeChoghadiyas: 8 periods
141
+ // result.nighttimeChoghadiyas: 8 periods
142
+ // result.auspicious: ["Amrit", "Shubh", "Labh"]
120
143
  ```
121
144
 
122
- ### 2. **Calculate Abhijit Muhurat**
145
+ #### `calculateAbhijeetMuhurt(date, sunrise, sunset, lat, lon, tz)`
123
146
 
124
147
  ```javascript
125
- const abhijitMuhurat = calculateAbhijeetMuhurt(date, sunrise, sunset, latitude, longitude, timezone);
126
-
127
- console.log(`Abhijit Muhurat Start: ${abhijitMuhurat.start_time}, End: ${abhijitMuhurat.end_time}`);
148
+ const { calculateAbhijeetMuhurt } = require("astrology-insights");
149
+ const muhurt = calculateAbhijeetMuhurt("2026-03-21", sunrise, sunset, 28.6139, 77.209, "Asia/Kolkata");
150
+ // { start: "12:05:29", end: "12:54:01" }
128
151
  ```
129
152
 
130
- ### 3. **Calculate Day and Night Choghadiya**
153
+ #### `calculateRahuKalam(date, sunrise, sunset, timezone)`
131
154
 
132
155
  ```javascript
133
- const choghadiyas = calculateChoghadiya(date, sunrise, sunset, timezone);
156
+ const { calculateRahuKalam } = require("astrology-insights");
157
+ const rahu = calculateRahuKalam("2026-03-21", sunrise, sunset, "Asia/Kolkata");
158
+ // { start: "09:27:45", end: "10:58:45" }
159
+ ```
134
160
 
135
- choghadiyas.day.forEach(({ type, start_time, end_time }) => {
136
- console.log(`${type}: ${start_time} - ${end_time}`);
137
- });
161
+ #### `calculateGulikaKalam(date, sunrise, sunset, timezone)`
138
162
 
163
+ **Breaking change in v2.0.0:** Previously accepted a date string only. Now requires `(date, sunrise, sunset, timezone)` — the same signature as Rahu Kalam.
139
164
 
140
- choghadiyas.night.forEach(({ type, start_time, end_time }) => {
141
- console.log(`${type}: ${start_time} - ${end_time}`);
142
- });
165
+ ```javascript
166
+ const { calculateGulikaKalam } = require("astrology-insights");
167
+ const gulika = calculateGulikaKalam("2026-03-21", sunrise, sunset, "Asia/Kolkata");
168
+ // { start: "06:25:46", end: "07:56:45" }
143
169
  ```
144
170
 
145
- ### 4. **Calculate Moon Position**
171
+ #### `calculateMoonPosition(date, latitude, longitude, timezone)`
146
172
 
147
173
  ```javascript
148
- const { getMoonPosition, getMoonIllumination, getMoonTimes } = calculateMoonPosition(
149
- date,
150
- latitude,
151
- longitude,
152
- timezone
153
- );
154
- console.log(getMoonPosition);
155
- console.log(getMoonIllumination);
156
- console.log(getMoonTimes);
174
+ const { calculateMoonPosition } = require("astrology-insights");
175
+ const moon = calculateMoonPosition("2026-03-21", 28.6139, 77.209, "Asia/Kolkata");
176
+ // moon.getMoonPosition: { azimuth, altitude, distance, parallacticAngle }
177
+ // moon.getMoonIllumination: { fraction, phase, angle }
178
+ // moon.getMoonTimes: { rise: "07:27:08", set: "21:07:18" }
157
179
  ```
158
180
 
159
- ### 5. **Calculate Nakshatras**
181
+ #### `calculateBioRhythms(dob, date)`
160
182
 
161
183
  ```javascript
162
- const nakshatras = calculateNakshatras(date, latitude, longitude, timezone);
163
- nakshatras.forEach(({ name, start, end, planet, deity, motivation }) => {
164
- console.log(`${name}: ${start} - ${end} (${planet}, deity: ${deity}, motivation: ${motivation})`);
165
- });
184
+ const { calculateBioRhythms } = require("astrology-insights");
185
+ const bio = calculateBioRhythms("1991-12-10", "2026-03-21");
186
+ // bio.data: Physical, Emotional, Intellectual, Intuitive cycles
166
187
  ```
167
188
 
168
- ## Output Examples
189
+ ## Validation Against Drik Panchang
190
+
191
+ Cross-validated for March 21, 2026 (Delhi, 28.6139N, 77.209E):
192
+
193
+ | Field | Our Value | Drik Panchang | Match |
194
+ |---|---|---|---|
195
+ | Tithi | Shukla Tritiya | Shukla Tritiya | YES |
196
+ | Nakshatra | Ashwini | Ashwini | YES |
197
+ | Yoga | Indra | Indra | YES |
198
+ | Karana | Taitila | Taitila | YES |
199
+ | Vara | Saturday | Saturday | YES |
200
+ | Sunrise | 06:25 | 06:24 | ~1 min |
201
+ | Sunset | 18:33 | 18:33 | YES |
202
+ | Moon Sign | Aries | Aries | YES |
203
+ | Sun Sign | Pisces | Pisces | YES |
204
+ | Paksha | Shukla | Shukla | YES |
205
+ | Brahma Muhurta | 04:48-05:36 | 04:49-05:37 | ~1 min |
206
+ | Pratah Sandhya | 05:14-06:25 | 05:13-06:24 | ~1 min |
207
+ | Abhijit Muhurat | 12:04-12:53 | 12:04-12:53 | YES |
208
+ | Vijaya Muhurat | 14:30-15:19 | 14:30-15:18 | ~1 min |
209
+ | Godhuli Muhurat | 18:32-18:55 | 18:32-18:55 | YES |
210
+ | Sayahna Sandhya | 18:33-19:44 | 18:33-19:44 | YES |
211
+ | Nishita Muhurat | 00:05-00:53 | 00:04-00:52 | ~1 min |
212
+ | Rahu Kalam | 09:27-10:58 | 09:26-10:57 | ~1 min |
213
+ | Yamaganda | 14:00-15:30 | 14:00-15:31 | ~1 min |
214
+ | Gulika Kalam | 06:25-07:56 | 06:24-07:55 | ~1 min |
215
+ | Dur Muhurtam | 06:25-07:13 | 06:24-07:13 | ~1 min |
216
+ | Vikram Samvat | 2083 | 2083 | YES |
217
+ | Shaka Samvat | 1948 | 1948 | YES |
218
+ | Samvatsar | Siddharthi | Siddharthi | YES |
219
+ | Ritu | Vasanta | Vasanta | YES |
220
+ | Ayana | Uttarayana | Uttarayana | YES |
221
+ | Dinamana | 12h 08m | 12h 08m | YES |
222
+
223
+ **Score: 28/29 fields match** (moonrise has ~8 min variance due to SunCalc library limitation for lunar calculations).
224
+
225
+ Also validated against multiple historical dates:
226
+ - October 20, 2025 (Diwali) -- Chaturdashi, Hasta, Shakuni confirmed
227
+ - January 14, 2026 (Makar Sankranti) -- Ekadashi, Anuradha confirmed
228
+ - August 15, 1947 (Independence Day) -- historical accuracy verified
229
+
230
+ ## React Native
231
+
232
+ On React Native, `calculateFullPanchang` uses a local fallback (Jean Meeus + SunCalc) that gives correct Tithi/Nakshatra/Yoga/Karana names and signs. For Swiss Ephemeris precision, use `fetchPanchang()` to call your API:
169
233
 
170
- ### Sunrise and Sunset
171
- ```
172
- Sunrise: 06:50:59, Sunset: 17:24:33
173
- ```
234
+ ```javascript
235
+ const { fetchPanchang } = require("astrology-insights");
174
236
 
175
- ### Abhijit Muhurat
176
- ```
177
- Abhijit Muhurat Start: 11:27:46, End: 12:07:46
237
+ const result = await fetchPanchang(
238
+ "2026-03-21", 28.6139, 77.209, "Asia/Kolkata",
239
+ "https://your-app.vercel.app/api/panchang"
240
+ );
178
241
  ```
179
242
 
180
- ### Day and Night Choghadiya
181
- **Day Choghadiya**
182
- ```
183
- Udveg: 06:50:59 - 08:10:11
184
- Char: 08:10:11 - 09:29:23
185
- Labh: 09:29:23 - 10:48:35
186
- Amrit: 10:48:35 - 12:07:46
187
- Kaal: 12:07:46 - 13:26:58
188
- Shubh: 13:26:58 - 14:46:10
189
- Rog: 14:46:10 - 16:05:22
190
- Udveg: 16:05:22 - 17:24:33
191
- ```
243
+ ## Deploying the Panchang API (Vercel)
244
+
245
+ The package includes a ready-to-deploy Vercel Serverless Function at `api/panchang.js`.
192
246
 
193
- **Night Choghadiya**
247
+ ```bash
248
+ cd astrology-insights
249
+ npx vercel
194
250
  ```
195
- Shubh: 17:24:33 - 18:54:44
196
- Rog: 18:54:44 - 20:24:55
197
- Kaal: 20:24:55 - 21:55:06
198
- Labh: 21:55:06 - 23:25:17
199
- Udveg: 23:25:17 - 00:55:28
200
- Amrit: 00:55:28 - 02:25:39
201
- Char: 02:25:39 - 03:55:50
202
- Rog: 03:55:50 - 05:26:01
251
+
252
+ **Test the endpoint:**
253
+ ```bash
254
+ curl "https://your-app.vercel.app/api/panchang?date=2026-03-21&lat=28.6139&lon=77.209&tz=Asia/Kolkata"
203
255
  ```
204
256
 
205
- ## Contributing
257
+ | Param | Type | Required | Example |
258
+ |---|---|---|---|
259
+ | `date` | string | Yes | `2026-03-21` |
260
+ | `lat` | number | Yes | `28.6139` |
261
+ | `lon` | number | Yes | `77.209` |
262
+ | `tz` | string | Yes | `Asia/Kolkata` |
206
263
 
207
- Contributions are welcome! Please fork this repository and submit a pull request.
264
+ Responses are cached for 1 hour (`s-maxage=3600`) with stale-while-revalidate for 24 hours.
265
+
266
+ ## Testing
267
+
268
+ ```bash
269
+ npm run test # Legacy test (node test.js)
270
+ npm run test:unit # Jest unit tests (62 tests)
271
+ ```
208
272
 
209
273
  ## License
210
274
 
211
- This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
275
+ MIT License. See [LICENSE](LICENSE) for details.
212
276
 
213
277
  ## Acknowledgments
214
278
 
279
+ - **Swiss Ephemeris** (swisseph) for high-precision planetary positions
215
280
  - **Luxon** for date-time utilities
216
- - Inspired by Wilhelm Fliess’s work on biorhythm theory
217
-
218
- Happy coding and stargazing! 🌠
281
+ - **SunCalc** for sunrise/sunset and moon calculations
282
+ - Vedic astrology principles for Panchang, Choghadiya, and Muhurat calculations
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Vercel Serverless Function — Full Panchang API
3
+ *
4
+ * Endpoint: GET /api/panchang?date=2026-03-20&lat=28.6139&lon=77.209&tz=Asia/Kolkata
5
+ *
6
+ * Returns: PanchangResult JSON (Swiss Ephemeris precision)
7
+ *
8
+ * Deploy: Push to Vercel with the astrology-insights package as the root.
9
+ * Vercel auto-detects the api/ directory and deploys as serverless functions.
10
+ */
11
+
12
+ require('ts-node').register({ transpileOnly: true });
13
+ const { calculateFullPanchang } = require('../panchang/src/panchang-v2');
14
+
15
+ module.exports = (req, res) => {
16
+ // CORS
17
+ res.setHeader('Access-Control-Allow-Origin', '*');
18
+ res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
19
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
20
+ res.setHeader('Cache-Control', 's-maxage=3600, stale-while-revalidate=86400');
21
+
22
+ if (req.method === 'OPTIONS') {
23
+ return res.status(200).end();
24
+ }
25
+
26
+ const { date, lat, lon, tz } = req.query;
27
+
28
+ if (!date || !lat || !lon || !tz) {
29
+ return res.status(400).json({
30
+ error: 'Missing required parameters',
31
+ usage: '/api/panchang?date=2026-03-20&lat=28.6139&lon=77.209&tz=Asia/Kolkata',
32
+ params: {
33
+ date: 'YYYY-MM-DD (required)',
34
+ lat: 'Latitude in degrees (required)',
35
+ lon: 'Longitude in degrees (required)',
36
+ tz: 'IANA timezone string (required)',
37
+ },
38
+ });
39
+ }
40
+
41
+ try {
42
+ const result = calculateFullPanchang(
43
+ date,
44
+ parseFloat(lat),
45
+ parseFloat(lon),
46
+ decodeURIComponent(tz),
47
+ );
48
+
49
+ return res.status(200).json(result);
50
+ } catch (error) {
51
+ return res.status(500).json({
52
+ error: 'Panchang calculation failed',
53
+ message: error.message,
54
+ });
55
+ }
56
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Panchang constants — astronomical degrees, names, and lookup tables.
3
+ */
4
+ export declare const DEGREES_PER_TITHI = 12;
5
+ export declare const DEGREES_PER_NAKSHATRA = 13.333333;
6
+ export declare const DEGREES_PER_PADA = 3.333333;
7
+ export declare const DEGREES_PER_YOGA = 13.333333;
8
+ export declare const DEGREES_PER_RASHI = 30;
9
+ export declare function normalizeAngle(angle: number): number;
10
+ export declare const TITHI_NAMES: string[];
11
+ export declare const NAKSHATRAS: Array<{
12
+ name: string;
13
+ lord: string;
14
+ deity: string;
15
+ }>;
16
+ export declare const YOGA_NAMES: string[];
17
+ /** 7 movable (repeating) karanas */
18
+ export declare const KARANA_NAMES_REPEATING: string[];
19
+ /** 4 fixed karanas (occur once per lunar month at the end) */
20
+ export declare const KARANA_NAMES_FIXED: string[];
21
+ export declare const RASHIS: Array<{
22
+ name: string;
23
+ sanskritName: string;
24
+ lord: string;
25
+ element: string;
26
+ }>;
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ /**
3
+ * Panchang constants — astronomical degrees, names, and lookup tables.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RASHIS = exports.KARANA_NAMES_FIXED = exports.KARANA_NAMES_REPEATING = exports.YOGA_NAMES = exports.NAKSHATRAS = exports.TITHI_NAMES = exports.normalizeAngle = exports.DEGREES_PER_RASHI = exports.DEGREES_PER_YOGA = exports.DEGREES_PER_PADA = exports.DEGREES_PER_NAKSHATRA = exports.DEGREES_PER_TITHI = void 0;
7
+ // ---------------------------------------------------------------------------
8
+ // Degree constants
9
+ // ---------------------------------------------------------------------------
10
+ exports.DEGREES_PER_TITHI = 12;
11
+ exports.DEGREES_PER_NAKSHATRA = 13.333333;
12
+ exports.DEGREES_PER_PADA = 3.333333;
13
+ exports.DEGREES_PER_YOGA = 13.333333;
14
+ exports.DEGREES_PER_RASHI = 30;
15
+ // ---------------------------------------------------------------------------
16
+ // Helper
17
+ // ---------------------------------------------------------------------------
18
+ function normalizeAngle(angle) {
19
+ let normalized = angle % 360;
20
+ if (normalized < 0) {
21
+ normalized += 360;
22
+ }
23
+ return normalized;
24
+ }
25
+ exports.normalizeAngle = normalizeAngle;
26
+ // ---------------------------------------------------------------------------
27
+ // Tithi names (30 total: 15 Shukla + 15 Krishna)
28
+ // Index 0-14 = Shukla Paksha; index 15-29 = Krishna Paksha
29
+ // The 15th tithi of each paksha is Purnima / Amavasya respectively.
30
+ // ---------------------------------------------------------------------------
31
+ exports.TITHI_NAMES = [
32
+ // Shukla Paksha (1–15)
33
+ 'Shukla Pratipada',
34
+ 'Shukla Dwitiya',
35
+ 'Shukla Tritiya',
36
+ 'Shukla Chaturthi',
37
+ 'Shukla Panchami',
38
+ 'Shukla Shashthi',
39
+ 'Shukla Saptami',
40
+ 'Shukla Ashtami',
41
+ 'Shukla Navami',
42
+ 'Shukla Dashami',
43
+ 'Shukla Ekadashi',
44
+ 'Shukla Dwadashi',
45
+ 'Shukla Trayodashi',
46
+ 'Shukla Chaturdashi',
47
+ 'Purnima',
48
+ // Krishna Paksha (1–15)
49
+ 'Krishna Pratipada',
50
+ 'Krishna Dwitiya',
51
+ 'Krishna Tritiya',
52
+ 'Krishna Chaturthi',
53
+ 'Krishna Panchami',
54
+ 'Krishna Shashthi',
55
+ 'Krishna Saptami',
56
+ 'Krishna Ashtami',
57
+ 'Krishna Navami',
58
+ 'Krishna Dashami',
59
+ 'Krishna Ekadashi',
60
+ 'Krishna Dwadashi',
61
+ 'Krishna Trayodashi',
62
+ 'Krishna Chaturdashi',
63
+ 'Amavasya',
64
+ ];
65
+ // ---------------------------------------------------------------------------
66
+ // Nakshatras (27)
67
+ // ---------------------------------------------------------------------------
68
+ exports.NAKSHATRAS = [
69
+ { name: 'Ashwini', lord: 'Ketu', deity: 'Ashwini Kumaras' },
70
+ { name: 'Bharani', lord: 'Venus', deity: 'Yama' },
71
+ { name: 'Krittika', lord: 'Sun', deity: 'Agni' },
72
+ { name: 'Rohini', lord: 'Moon', deity: 'Brahma' },
73
+ { name: 'Mrigashira', lord: 'Mars', deity: 'Soma' },
74
+ { name: 'Ardra', lord: 'Rahu', deity: 'Rudra' },
75
+ { name: 'Punarvasu', lord: 'Jupiter', deity: 'Aditi' },
76
+ { name: 'Pushya', lord: 'Saturn', deity: 'Brihaspati' },
77
+ { name: 'Ashlesha', lord: 'Mercury', deity: 'Nagas' },
78
+ { name: 'Magha', lord: 'Ketu', deity: 'Pitrs' },
79
+ { name: 'Purva Phalguni', lord: 'Venus', deity: 'Bhaga' },
80
+ { name: 'Uttara Phalguni', lord: 'Sun', deity: 'Aryaman' },
81
+ { name: 'Hasta', lord: 'Moon', deity: 'Savitar' },
82
+ { name: 'Chitra', lord: 'Mars', deity: 'Vishvakarma' },
83
+ { name: 'Swati', lord: 'Rahu', deity: 'Vayu' },
84
+ { name: 'Vishakha', lord: 'Jupiter', deity: 'Indragni' },
85
+ { name: 'Anuradha', lord: 'Saturn', deity: 'Mitra' },
86
+ { name: 'Jyeshtha', lord: 'Mercury', deity: 'Indra' },
87
+ { name: 'Mula', lord: 'Ketu', deity: 'Nirriti' },
88
+ { name: 'Purva Ashadha', lord: 'Venus', deity: 'Apah' },
89
+ { name: 'Uttara Ashadha', lord: 'Sun', deity: 'Vishvedevas' },
90
+ { name: 'Shravana', lord: 'Moon', deity: 'Vishnu' },
91
+ { name: 'Dhanishtha', lord: 'Mars', deity: 'Vasus' },
92
+ { name: 'Shatabhisha', lord: 'Rahu', deity: 'Varuna' },
93
+ { name: 'Purva Bhadrapada', lord: 'Jupiter', deity: 'Ajaikapat' },
94
+ { name: 'Uttara Bhadrapada', lord: 'Saturn', deity: 'Ahirbudhnya' },
95
+ { name: 'Revati', lord: 'Mercury', deity: 'Pushan' },
96
+ ];
97
+ // ---------------------------------------------------------------------------
98
+ // Yoga names (27)
99
+ // ---------------------------------------------------------------------------
100
+ exports.YOGA_NAMES = [
101
+ 'Vishkumbha',
102
+ 'Preeti',
103
+ 'Ayushman',
104
+ 'Saubhagya',
105
+ 'Shobhana',
106
+ 'Atiganda',
107
+ 'Sukarman',
108
+ 'Dhriti',
109
+ 'Shoola',
110
+ 'Ganda',
111
+ 'Vriddhi',
112
+ 'Dhruva',
113
+ 'Vyaghata',
114
+ 'Harshana',
115
+ 'Vajra',
116
+ 'Siddhi',
117
+ 'Vyatipata',
118
+ 'Variyan',
119
+ 'Parigha',
120
+ 'Shiva',
121
+ 'Siddha',
122
+ 'Sadhya',
123
+ 'Shubha',
124
+ 'Shukla',
125
+ 'Brahma',
126
+ 'Indra',
127
+ 'Vaidhriti',
128
+ ];
129
+ // ---------------------------------------------------------------------------
130
+ // Karana names
131
+ // ---------------------------------------------------------------------------
132
+ /** 7 movable (repeating) karanas */
133
+ exports.KARANA_NAMES_REPEATING = [
134
+ 'Bava',
135
+ 'Balava',
136
+ 'Kaulava',
137
+ 'Taitila',
138
+ 'Garija',
139
+ 'Vanija',
140
+ 'Vishti',
141
+ ];
142
+ /** 4 fixed karanas (occur once per lunar month at the end) */
143
+ exports.KARANA_NAMES_FIXED = [
144
+ 'Shakuni',
145
+ 'Chatushpad',
146
+ 'Naga',
147
+ 'Kimstughna',
148
+ ];
149
+ // ---------------------------------------------------------------------------
150
+ // Rashis (12)
151
+ // ---------------------------------------------------------------------------
152
+ exports.RASHIS = [
153
+ { name: 'Aries', sanskritName: 'Mesha', lord: 'Mars', element: 'Fire' },
154
+ { name: 'Taurus', sanskritName: 'Vrishabha', lord: 'Venus', element: 'Earth' },
155
+ { name: 'Gemini', sanskritName: 'Mithuna', lord: 'Mercury', element: 'Air' },
156
+ { name: 'Cancer', sanskritName: 'Karka', lord: 'Moon', element: 'Water' },
157
+ { name: 'Leo', sanskritName: 'Simha', lord: 'Sun', element: 'Fire' },
158
+ { name: 'Virgo', sanskritName: 'Kanya', lord: 'Mercury', element: 'Earth' },
159
+ { name: 'Libra', sanskritName: 'Tula', lord: 'Venus', element: 'Air' },
160
+ { name: 'Scorpio', sanskritName: 'Vrishchika', lord: 'Mars', element: 'Water' },
161
+ { name: 'Sagittarius', sanskritName: 'Dhanu', lord: 'Jupiter', element: 'Fire' },
162
+ { name: 'Capricorn', sanskritName: 'Makara', lord: 'Saturn', element: 'Earth' },
163
+ { name: 'Aquarius', sanskritName: 'Kumbha', lord: 'Saturn', element: 'Air' },
164
+ { name: 'Pisces', sanskritName: 'Meena', lord: 'Jupiter', element: 'Water' },
165
+ ];