Skip to content

Commit 609f88f

Browse files
authored
Merge pull request #1 from MrTalon63/nightly
Push nightly to master
2 parents 6b236ca + d41b7ae commit 609f88f

File tree

9 files changed

+377
-167
lines changed

9 files changed

+377
-167
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"start": "bun run src/main.ts",
1313
"dev": "bun run --watch src/main.ts"
1414
},
15-
"version": "0.2.0",
15+
"version": "0.3.0",
1616
"devDependencies": {
1717
"@types/bun": "latest"
1818
},

src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { wrap } from "@bogeychan/elysia-logger";
44

55
import tleRoute from "./routes/tle";
66
import jsonRoute from "./routes/json";
7+
import csvRoute from "./routes/csv";
78
import noradRoute from "./routes/norad";
89

910
import index from "./pub/index.tsx";
@@ -24,16 +25,19 @@ new Elysia()
2425
for (const group of config.allowedGroups) {
2526
const tleTimestamp = await kv.get(`${group}_timestamp_tle`);
2627
const jsonTimestamp = await kv.get(`${group}_timestamp_json`);
28+
const csvTimestamp = await kv.get(`${group}_timestamp_csv`);
2729
const lastUpdateTle = tleTimestamp ? new Date(tleTimestamp).toISOString() : "Never";
2830
const lastUpdateJson = jsonTimestamp ? new Date(jsonTimestamp).toISOString() : "Never";
29-
activeGroups.push({ name: group, lastUpdateTle, lastUpdateJson });
31+
const lastUpdateCsv = csvTimestamp ? new Date(csvTimestamp).toISOString() : "Never";
32+
activeGroups.push({ name: group, lastUpdateTle, lastUpdateJson, lastUpdateCsv });
3033
}
3134
return index({ activeGroups, cacheDuration: config.cacheDuration, maxReq: config.rateLimitMaxRequests, maxReqWindow: config.rateLimitWindow, version });
3235
})
3336

3437
// Subroutes registers
3538
.use(tleRoute) // Import TLE routes
3639
.use(jsonRoute) // Import JSON routes
40+
.use(csvRoute) // Import CSV routes
3741
.use(noradRoute) // Import NORAD routes
3842

3943
.listen(config.port, () => {

src/pub/index.tsx

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const index = ({ activeGroups, cacheDuration, maxReq, maxReqWindow, version }: { activeGroups: { name: string; lastUpdateTle: string; lastUpdateJson: string }[]; cacheDuration: number; maxReq: number; maxReqWindow: number; version: string }) => (
1+
const index = ({ activeGroups, cacheDuration, maxReq, maxReqWindow, version }: { activeGroups: { name: string; lastUpdateTle: string; lastUpdateJson: string; lastUpdateCsv: string }[]; cacheDuration: number; maxReq: number; maxReqWindow: number; version: string }) => (
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
@@ -22,47 +22,70 @@ const index = ({ activeGroups, cacheDuration, maxReq, maxReqWindow, version }: {
2222
<link rel="stylesheet" href="/styles.css" />
2323
</head>
2424
<body>
25-
<h1>Welcome to ReTLEctor</h1>
26-
<p>This is a simple web app to cache and return TLEs from Celestrak, so you can avoid getting blocked by their servers when you need to get TLEs for a large number of satellites (Or you testing shit).</p>
25+
<header>
26+
<div class="header-inner">
27+
<div>
28+
<h1>ReTLEctor</h1>
29+
<p>Celestrak TLE caching proxy - v{version}</p>
30+
</div>
31+
<a class="header-gh" href="https://github.com/MrTalon63/ReTLEctor" target="_blank">
32+
GitHub repository
33+
</a>
34+
</div>
35+
</header>
36+
<main>
37+
<div class="card">
38+
<h2>About</h2>
39+
<p>A lightweight proxy that caches TLEs from Celestrak to prevent rate-limiting when fetching a lot of data.</p>
40+
<p>
41+
Supported formats: <br />
42+
<strong>3LE</strong> - <code>/tle/[group]</code> <br />
43+
<strong>JSON CCSDS OMM</strong> - <code>/json/[group]</code> <br />
44+
<strong>CSV</strong> - <code>/csv/[group]</code>
45+
</p>
46+
<p>
47+
Custom NORAD ID lookup (experimental, 3LE only): <code>/norad/[NORAD_ID]</code>
48+
</p>
49+
</div>
2750

28-
<p>
29-
Currently supported formats are <strong>3LE</strong> under <code>/tle/[group]</code> and <strong>JSON CCSDS OMM</strong> under <code>/json/[group]</code>
30-
</p>
51+
<div class="card table-card">
52+
<h2>Cached Groups</h2>
53+
<div class="table-wrap">
54+
<table>
55+
<thead>
56+
<tr>
57+
<th>Group</th>
58+
<th>Last Update (TLE)</th>
59+
<th>Last Update (JSON)</th>
60+
<th>Last Update (CSV)</th>
61+
</tr>
62+
</thead>
63+
<tbody>
64+
{activeGroups.map((group) => (
65+
<tr>
66+
<td data-label="Group">
67+
<code>{group.name}</code>
68+
</td>
69+
<td data-label="Last Update (TLE)">{group.lastUpdateTle}</td>
70+
<td data-label="Last Update (JSON)">{group.lastUpdateJson}</td>
71+
<td data-label="Last Update (CSV)">{group.lastUpdateCsv}</td>
72+
</tr>
73+
))}
74+
</tbody>
75+
</table>
76+
</div>
77+
</div>
3178

32-
<p>
33-
Custom NORAD ID requests are supported via <code>/norad/[NORAD_ID]</code>.<br />
34-
Please note that this is very experimental and currently only in <strong>3LE</strong> format.
35-
</p>
36-
37-
<h3>Table below represents the cached TLEs and their URIs as well as last update time:</h3>
38-
39-
<table>
40-
<tr>
41-
<th>TLE (group)</th>
42-
<th>Last Update (TLE)</th>
43-
<th>Last Update (JSON)</th>
44-
</tr>
45-
{activeGroups.map((group) => (
46-
<tr>
47-
<td>{group.name}</td>
48-
<td>{group.lastUpdateTle}</td>
49-
<td>{group.lastUpdateJson}</td>
50-
</tr>
51-
))}
52-
</table>
53-
54-
<p>Data is updated every ~{cacheDuration / 1000 / 60} minutes.</p>
55-
<p>
56-
Current rate limit is {maxReq} requests per {maxReqWindow / 1000} seconds. That might change in the future, pay attention to the headers returned by the server.
57-
</p>
58-
<p>
59-
Source code is available on{" "}
60-
<a href="https://github.com/MrTalon63/retlector" target="_blank">
61-
GitHub
79+
<div class="meta">
80+
<span>Cache refresh: ~{cacheDuration / 1000 / 60} min</span>
81+
<span>
82+
Rate limit: {maxReq} req / {maxReqWindow / 1000}s (Follow http headers for accurate rate limit info)
83+
</span>
84+
</div>
85+
<a class="btn" href="https://github.com/MrTalon63/ReTLEctor" target="_blank">
86+
View Source on GitHub
6287
</a>
63-
. Feel free to contribute!
64-
</p>
65-
<p>ReTLEctor version: {version}</p>
88+
</main>
6689
</body>
6790
</html>
6891
);

0 commit comments

Comments
 (0)