Disabled various small island countries, added hint to Geo.

This commit is contained in:
Niels Simenon
2022-11-02 20:46:47 +01:00
parent 72aed56485
commit 210155305c
228 changed files with 1166 additions and 1243 deletions
+6 -7
View File
@@ -1,18 +1,17 @@
'use strict';
const fs = require('fs').promises;
const bhttp = require('bhttp');
const crypto = require('crypto');
const countries = require('./countries.json');
async function init() {
const countryImgs = await fs.readdir('./assets/countries');
const res = await bhttp.get('http://localhost:3000/api/countries');
const countries = res.body;
const countriesByCode = Object.fromEntries(countries.map((country) => [country.alpha2, country]));
const imgCountries = await Promise.all(countryImgs.filter((file) => file !== 'encoded').map(async (file) => {
const imgCountries = await Promise.all(countryImgs.filter((file) => !['encoded', 'disabled'].includes(file)).map(async (file) => {
const code = file.match(/(\w+).png/)[1];
const filename = `${Buffer.from(code).toString('base64')}.png`;
const filename = `${crypto.createHash('md5').update(code).digest('hex').slice(0, 4)}.png`;
await fs.copyFile(`./assets/countries/${file}`, `./assets/countries/encoded/${filename}`);
@@ -23,7 +22,7 @@ async function init() {
};
}));
await fs.writeFile('./assets/countries.json', JSON.stringify(imgCountries, null, 4));
await fs.writeFile('./assets/countries-curated.json', JSON.stringify(imgCountries, null, 4));
console.log('Done!');
}