Added Geo game.
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs').promises;
|
||||
const bhttp = require('bhttp');
|
||||
|
||||
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 code = file.match(/(\w+).png/)[1];
|
||||
const filename = `${Buffer.from(code).toString('base64')}.png`;
|
||||
|
||||
await fs.copyFile(`./assets/countries/${file}`, `./assets/countries/encoded/${filename}`);
|
||||
|
||||
return {
|
||||
file: filename,
|
||||
code,
|
||||
...countriesByCode[code],
|
||||
};
|
||||
}));
|
||||
|
||||
await fs.writeFile('./assets/countries.json', JSON.stringify(imgCountries, null, 4));
|
||||
|
||||
console.log('Done!');
|
||||
}
|
||||
|
||||
init();
|
After Width: | Height: | Size: 252 KiB |
After Width: | Height: | Size: 164 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 187 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 300 KiB |
After Width: | Height: | Size: 164 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 133 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 158 KiB |
After Width: | Height: | Size: 181 KiB |
After Width: | Height: | Size: 142 KiB |
After Width: | Height: | Size: 174 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 125 KiB |
After Width: | Height: | Size: 142 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 364 KiB |
After Width: | Height: | Size: 160 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 146 KiB |
After Width: | Height: | Size: 262 KiB |
After Width: | Height: | Size: 125 KiB |
After Width: | Height: | Size: 251 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 230 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 357 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 225 KiB |
After Width: | Height: | Size: 231 KiB |
After Width: | Height: | Size: 168 KiB |
After Width: | Height: | Size: 125 KiB |
After Width: | Height: | Size: 168 KiB |
After Width: | Height: | Size: 351 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 231 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 177 KiB |
After Width: | Height: | Size: 132 KiB |
After Width: | Height: | Size: 185 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 325 KiB |
After Width: | Height: | Size: 237 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 179 KiB |
After Width: | Height: | Size: 368 KiB |
After Width: | Height: | Size: 183 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 219 KiB |
After Width: | Height: | Size: 178 KiB |
After Width: | Height: | Size: 155 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 286 KiB |
After Width: | Height: | Size: 233 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 226 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 443 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 231 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 174 KiB |
After Width: | Height: | Size: 175 KiB |
After Width: | Height: | Size: 262 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 148 KiB |
After Width: | Height: | Size: 171 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 202 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 175 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 427 KiB |
After Width: | Height: | Size: 305 KiB |