mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
refactor: move airports.json out of server/data into server/assets
server/data is for runtime state (SQLite, backups, logs, tmp) — the airports snapshot is a shipped dataset, not user data, and it being in there forced us to poke a hole in both .dockerignore and .gitignore. Move it to server/assets/ and drop the exceptions; service and build script point at the new path.
This commit is contained in:
@@ -3,7 +3,6 @@ client/node_modules
|
|||||||
server/node_modules
|
server/node_modules
|
||||||
client/dist
|
client/dist
|
||||||
data
|
data
|
||||||
!server/data/airports.json
|
|
||||||
uploads
|
uploads
|
||||||
.git
|
.git
|
||||||
.github
|
.github
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ client/public/icons/*.png
|
|||||||
|
|
||||||
# User data
|
# User data
|
||||||
server/data/*
|
server/data/*
|
||||||
!server/data/airports.json
|
|
||||||
server/uploads/
|
server/uploads/
|
||||||
|
|
||||||
# Environment
|
# Environment
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
// Build server/data/airports.json from OurAirports (davidmegginson.github.io/ourairports-data).
|
// Build server/assets/airports.json from OurAirports (davidmegginson.github.io/ourairports-data).
|
||||||
// License: Public Domain. Keeps large/medium airports with an IATA code; timezone derived from coords via tz-lookup.
|
// License: Public Domain. Keeps large/medium airports with an IATA code; timezone derived from coords via tz-lookup.
|
||||||
|
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url'
|
|||||||
import tzLookup from 'tz-lookup'
|
import tzLookup from 'tz-lookup'
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
const OUT = path.join(__dirname, '..', 'data', 'airports.json')
|
const OUT = path.join(__dirname, '..', 'assets', 'airports.json')
|
||||||
const SRC = 'https://davidmegginson.github.io/ourairports-data/airports.csv'
|
const SRC = 'https://davidmegginson.github.io/ourairports-data/airports.csv'
|
||||||
|
|
||||||
function fetchText(url) {
|
function fetchText(url) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let byIata: Map<string, Airport> | null = null;
|
|||||||
|
|
||||||
function load(): Airport[] {
|
function load(): Airport[] {
|
||||||
if (cache) return cache;
|
if (cache) return cache;
|
||||||
const file = path.join(__dirname, '..', '..', 'data', 'airports.json');
|
const file = path.join(__dirname, '..', '..', 'assets', 'airports.json');
|
||||||
if (!fs.existsSync(file)) {
|
if (!fs.existsSync(file)) {
|
||||||
console.warn('[airports] airports.json missing — run `node scripts/build-airports.mjs`');
|
console.warn('[airports] airports.json missing — run `node scripts/build-airports.mjs`');
|
||||||
cache = [];
|
cache = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user