diff options
author | Julien Dessaux | 2024-03-27 15:20:14 +0100 |
---|---|---|
committer | Julien Dessaux | 2024-03-27 15:21:37 +0100 |
commit | a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9 (patch) | |
tree | 1566c60bf1155e62821d9561ba1cc998b04b8ea5 /nodejs/automation/exploration.ts | |
parent | [all] fixed erroneous contracts index (diff) | |
download | spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.tar.gz spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.tar.bz2 spacetraders-a1d6b03ec98abbc073b5b73b631da6ea3eae4eb9.zip |
[node] finished the great typescript rewrite
Diffstat (limited to 'nodejs/automation/exploration.ts')
-rw-r--r-- | nodejs/automation/exploration.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/nodejs/automation/exploration.ts b/nodejs/automation/exploration.ts new file mode 100644 index 0000000..67fbfe4 --- /dev/null +++ b/nodejs/automation/exploration.ts @@ -0,0 +1,9 @@ +import db from '../database/db.ts'; +import * as dbSystems from '../database/systems.ts'; +import { System } from '../model/system.ts'; +import * as api from '../lib/api.ts'; + +export async function init(): Promise<void> { + const response = await api.sendPaginated<System>({endpoint: `/systems`, page: Math.max(1, Math.floor(dbSystems.getSystemsCount()/20)), priority: 100}); + db.transaction(() => response.forEach(function(system) { try { dbSystems.addSystem(system); } catch {} }))(); +} |