mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-05-05 14:43:07 +03:00
Initial commit
This commit is contained in:
commit
2b9390a0a1
53 changed files with 9135 additions and 0 deletions
scripts
23
scripts/fetch-instances-list.js
Normal file
23
scripts/fetch-instances-list.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import fs from 'fs';
|
||||
|
||||
const { INSTANCES_SOCIAL_SECRET_TOKEN } = process.env;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
count: 200,
|
||||
sort_by: 'active_users',
|
||||
sort_order: 'desc',
|
||||
});
|
||||
|
||||
const url = `https://instances.social/api/1.0/instances/list?${params.toString()}`;
|
||||
const results = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${INSTANCES_SOCIAL_SECRET_TOKEN}`,
|
||||
},
|
||||
});
|
||||
|
||||
const json = await results.json();
|
||||
const names = json.instances.map((instance) => instance.name);
|
||||
|
||||
// Write to file
|
||||
const path = './src/data/instances.json';
|
||||
fs.writeFileSync(path, JSON.stringify(names, null, '\t'), 'utf8');
|
Loading…
Add table
Add a link
Reference in a new issue