removed readme
This commit is contained in:
parent
91c3266d86
commit
815f0e2736
@ -1,33 +0,0 @@
|
||||
# client-arangodb
|
||||
|
||||
ArangoDB-Variante des Ringstats-Clients. Gleicher Aufbau wie `client-redit`.
|
||||
ArangoDB ist multimodal, wir nutzen es hier bewusst als reinen Key-Value-Store,
|
||||
damit der Vergleich direkt zu Redis passt. Alles liegt in einer Collection `kv`,
|
||||
jedes Dokument hat den Redis-Key als `_key` und den Wert im Feld `value`.
|
||||
|
||||
To install dependencies:
|
||||
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
Datenbank starten:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Datenbank befüllen (~100 statische Entitäten):
|
||||
|
||||
```bash
|
||||
bun run db/init.ts
|
||||
```
|
||||
|
||||
Live-Client starten:
|
||||
|
||||
```bash
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
ArangoDB läuft auf Port `48529`, damit es parallel zu Redis und Memcached laufen kann.
|
||||
Beim ersten Start braucht ArangoDB kurz, bis es bereit ist. Die Skripte warten automatisch.
|
||||
@ -1,31 +0,0 @@
|
||||
# client-memcached
|
||||
|
||||
Memcached-Variante des Ringstats-Clients. Gleicher Aufbau wie `client-redit`,
|
||||
nur mit Memcached statt Redis. Da Memcached keine Hashes oder Sets kennt, liegt
|
||||
jedes Objekt als flacher Key mit einem JSON-String als Value.
|
||||
|
||||
To install dependencies:
|
||||
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
Datenbank starten:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Datenbank befüllen (~100 statische Entitäten):
|
||||
|
||||
```bash
|
||||
bun run db/init.ts
|
||||
```
|
||||
|
||||
Live-Client starten:
|
||||
|
||||
```bash
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
Memcached läuft auf Port `41211`, damit es parallel zu Redis und ArangoDB laufen kann.
|
||||
@ -1,15 +0,0 @@
|
||||
# client-redit
|
||||
|
||||
To install dependencies:
|
||||
|
||||
```bash
|
||||
bun install
|
||||
```
|
||||
|
||||
To run:
|
||||
|
||||
```bash
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
This project was created using `bun init` in bun v1.3.3. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,125 +0,0 @@
|
||||
import { write } from "bun";
|
||||
|
||||
const API_BASE = "https://eldenring.fanapis.com/api";
|
||||
|
||||
async function fetchAll(endpoint: string) {
|
||||
let allData: any[] = [];
|
||||
let page = 0;
|
||||
const limit = 100;
|
||||
|
||||
while (true) {
|
||||
const res = await fetch(`${API_BASE}/${endpoint}?limit=${limit}&page=${page}`);
|
||||
if (!res.ok) {
|
||||
console.error(`Error fetching ${endpoint}:`, res.status);
|
||||
break;
|
||||
}
|
||||
const data = await res.json();
|
||||
if (!data.data || data.data.length === 0) {
|
||||
break;
|
||||
}
|
||||
allData = allData.concat(data.data);
|
||||
console.log(`Fetched ${allData.length} ${endpoint}...`);
|
||||
if (data.data.length < limit) {
|
||||
break;
|
||||
}
|
||||
page++;
|
||||
}
|
||||
return allData;
|
||||
}
|
||||
|
||||
function extractRegion(entityRegion: string | null | undefined, locationStr: string | null | undefined, locationLookup: Map<string, string>, uniqueRegions: Set<string>): string | null {
|
||||
// 1. If the entity has a region, use it (and clean up typos from API)
|
||||
if (entityRegion) {
|
||||
let r = entityRegion;
|
||||
if (r === "Liunia of the Lakes") r = "Liurnia of the Lakes";
|
||||
if (r === "Mountaintop of the Giants") r = "Mountaintops of the Giants";
|
||||
if (r === "Altus Pleateau") r = "Altus Plateau";
|
||||
uniqueRegions.add(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// 2. Lookup via locations map
|
||||
if (locationStr) {
|
||||
for (const [locName, regionName] of locationLookup.entries()) {
|
||||
if (locationStr.toLowerCase().includes(locName.toLowerCase())) {
|
||||
return regionName;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Fallback: check if the location string itself contains a known dynamic region
|
||||
for (const region of uniqueRegions) {
|
||||
if (locationStr.toLowerCase().includes(region.toLowerCase())) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log("Fetching locations...");
|
||||
const locations = await fetchAll("locations");
|
||||
const uniqueRegions = new Set<string>();
|
||||
const locationLookup = new Map<string, string>();
|
||||
|
||||
// Normalize regions and build a lookup map: LocationName -> Region
|
||||
for (const loc of locations) {
|
||||
if (loc.region) {
|
||||
let r = loc.region;
|
||||
if (r === "Liunia of the Lakes" || r === "Liurnia") r = "Liurnia of the Lakes";
|
||||
if (r === "Mountaintop of the Giants") r = "Mountaintops of the Giants";
|
||||
if (r === "Altus Pleateau") r = "Altus Plateau";
|
||||
uniqueRegions.add(r);
|
||||
locationLookup.set(loc.name, r);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Fetching bosses...");
|
||||
const bosses = await fetchAll("bosses");
|
||||
|
||||
console.log("Fetching creatures...");
|
||||
const creatures = await fetchAll("creatures");
|
||||
|
||||
console.log("Fetching npcs...");
|
||||
const npcs = await fetchAll("npcs");
|
||||
|
||||
const livingEntities = [
|
||||
...bosses.map(b => ({ ...b, _type: "boss" })),
|
||||
...creatures.map(c => ({ ...c, _type: "creature" })),
|
||||
...npcs.map(n => ({ ...n, _type: "npc" }))
|
||||
];
|
||||
|
||||
const cleanedEntities = livingEntities.map(entity => {
|
||||
// combine all possible location info
|
||||
const cleanRegion = extractRegion(entity.region, entity.location, locationLookup, uniqueRegions);
|
||||
|
||||
return {
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
type: entity._type,
|
||||
cleanRegion: cleanRegion || "Unknown",
|
||||
originalLocation: entity.location,
|
||||
drops: entity.drops || []
|
||||
};
|
||||
});
|
||||
|
||||
// Save regions based on what was dynamically found in the API
|
||||
const regionsData = Array.from(uniqueRegions).map((r, i) => ({ id: i + 1, name: r }));
|
||||
|
||||
console.log("Fetching items...");
|
||||
const items = await fetchAll("items");
|
||||
// you might also want weapons, armors etc depending on what "items" means to the user.
|
||||
// The fan API separates items, weapons, armors, etc. Let's just fetch items for now.
|
||||
|
||||
const output = {
|
||||
regions: regionsData,
|
||||
entities: cleanedEntities,
|
||||
items: items.map(i => ({ id: i.id, name: i.name, type: i.type, effect: i.effect }))
|
||||
};
|
||||
|
||||
await write("./db/fanapi_data.json", JSON.stringify(output, null, 2));
|
||||
console.log("Saved to db/fanapi_data.json");
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Loading…
x
Reference in New Issue
Block a user