Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mimonelu committed Jun 6, 2024
1 parent 1eb0133 commit e746d45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Klearlist is ATProtocol's PDS list. Note, this list is a partial, not an all.

JSON file is [here](./list.json) .

Updated at 6/6/2024, 3:05:43 AM
Updated at 2024/6/6 14:50:48

* https://conocybe.us-west.host.bsky.network
* https://agaric.us-west.host.bsky.network
Expand All @@ -26,6 +26,7 @@ Updated at 6/6/2024, 3:05:43 AM
* https://shiitake.us-east.host.bsky.network
* https://russula.us-west.host.bsky.network
* https://shimeji.us-east.host.bsky.network
* https://kiichigo.cloud
* https://bluesky.whiz.social 🎫
* https://bsky-pds.h3z.jp 🎫
* https://atproto.brid.gy
Expand Down
2 changes: 1 addition & 1 deletion list.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"startedAt":"2024-06-06T03:05:43.737Z","endpoints":[{"url":"https://conocybe.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:51.017Z"},{"url":"https://agaric.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:13.927Z"},{"url":"https://hydnum.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:11.895Z"},{"url":"https://chaga.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:01.460Z"},{"url":"https://lepista.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:01.293Z"},{"url":"https://verpa.us-west.host.bsky.network","createdAt":"2024-06-05T12:55:45.550Z"},{"url":"https://boletus.us-west.host.bsky.network","createdAt":"2024-06-05T12:54:01.682Z"},{"url":"https://maitake.us-west.host.bsky.network","createdAt":"2024-06-05T12:53:02.419Z"},{"url":"https://blewit.us-west.host.bsky.network","createdAt":"2024-06-05T12:49:36.433Z"},{"url":"https://amanita.us-east.host.bsky.network","createdAt":"2024-06-05T12:36:06.830Z"},{"url":"https://porcini.us-east.host.bsky.network","createdAt":"2024-06-05T12:30:09.582Z"},{"url":"https://puffball.us-east.host.bsky.network","createdAt":"2024-06-05T12:16:54.207Z"},{"url":"https://oyster.us-east.host.bsky.network","createdAt":"2024-06-05T12:03:35.411Z"},{"url":"https://lionsmane.us-east.host.bsky.network","createdAt":"2024-06-05T12:02:44.236Z"},{"url":"https://enoki.us-east.host.bsky.network","createdAt":"2024-06-05T11:13:05.069Z"},{"url":"https://morel.us-east.host.bsky.network","createdAt":"2024-06-05T11:00:48.514Z"},{"url":"https://inkcap.us-east.host.bsky.network","createdAt":"2024-06-05T10:25:17.497Z"},{"url":"https://shiitake.us-east.host.bsky.network","createdAt":"2024-06-05T10:24:59.611Z"},{"url":"https://russula.us-west.host.bsky.network","createdAt":"2024-06-05T09:43:58.246Z"},{"url":"https://shimeji.us-east.host.bsky.network","createdAt":"2024-06-05T06:50:25.181Z"},{"url":"https://bluesky.whiz.social","createdAt":"2024-06-06T02:53:20.014Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://bsky-pds.h3z.jp","createdAt":"2024-06-05T15:53:51.971Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://atproto.brid.gy","createdAt":"2024-06-05T12:43:31.011Z","alive":true,"inviteCodeRequired":false,"phoneVerificationRequired":false},{"url":"https://mitexleo.one","createdAt":"2024-06-05T12:36:11.317Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://pds.mattobs.com","createdAt":"2024-06-05T08:13:28.595Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://pds.tom-sherman.com","createdAt":"2024-06-04T22:24:14.681Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false}]}
{"startedAt":"2024-06-06T05:50:48.139Z","endpoints":[{"url":"https://conocybe.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:51.017Z"},{"url":"https://agaric.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:13.927Z"},{"url":"https://hydnum.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:11.895Z"},{"url":"https://chaga.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:01.460Z"},{"url":"https://lepista.us-west.host.bsky.network","createdAt":"2024-06-05T12:56:01.293Z"},{"url":"https://verpa.us-west.host.bsky.network","createdAt":"2024-06-05T12:55:45.550Z"},{"url":"https://boletus.us-west.host.bsky.network","createdAt":"2024-06-05T12:54:01.682Z"},{"url":"https://maitake.us-west.host.bsky.network","createdAt":"2024-06-05T12:53:02.419Z"},{"url":"https://blewit.us-west.host.bsky.network","createdAt":"2024-06-05T12:49:36.433Z"},{"url":"https://amanita.us-east.host.bsky.network","createdAt":"2024-06-05T12:36:06.830Z"},{"url":"https://porcini.us-east.host.bsky.network","createdAt":"2024-06-05T12:30:09.582Z"},{"url":"https://puffball.us-east.host.bsky.network","createdAt":"2024-06-05T12:16:54.207Z"},{"url":"https://oyster.us-east.host.bsky.network","createdAt":"2024-06-05T12:03:35.411Z"},{"url":"https://lionsmane.us-east.host.bsky.network","createdAt":"2024-06-05T12:02:44.236Z"},{"url":"https://enoki.us-east.host.bsky.network","createdAt":"2024-06-05T11:13:05.069Z"},{"url":"https://morel.us-east.host.bsky.network","createdAt":"2024-06-05T11:00:48.514Z"},{"url":"https://inkcap.us-east.host.bsky.network","createdAt":"2024-06-05T10:25:17.497Z"},{"url":"https://shiitake.us-east.host.bsky.network","createdAt":"2024-06-05T10:24:59.611Z"},{"url":"https://russula.us-west.host.bsky.network","createdAt":"2024-06-05T09:43:58.246Z"},{"url":"https://shimeji.us-east.host.bsky.network","createdAt":"2024-06-05T06:50:25.181Z"},{"url":"https://kiichigo.cloud","createdAt":"2024-06-06T03:42:49.631Z","alive":true,"inviteCodeRequired":false,"phoneVerificationRequired":false},{"url":"https://bluesky.whiz.social","createdAt":"2024-06-06T02:53:20.014Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://bsky-pds.h3z.jp","createdAt":"2024-06-05T15:53:51.971Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://atproto.brid.gy","createdAt":"2024-06-05T12:43:31.011Z","alive":true,"inviteCodeRequired":false,"phoneVerificationRequired":false},{"url":"https://mitexleo.one","createdAt":"2024-06-05T12:36:11.317Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://pds.mattobs.com","createdAt":"2024-06-05T08:13:28.595Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false},{"url":"https://pds.tom-sherman.com","createdAt":"2024-06-04T22:24:14.681Z","alive":true,"inviteCodeRequired":true,"phoneVerificationRequired":false}]}
24 changes: 11 additions & 13 deletions main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@ import * as fs from "fs"
import * as path from "path"
import { fileURLToPath } from "url"

const TERM_DAYS = 1
const MAX_ITERATIONS = 10
const TERM_DAYS = 2
const MAX_ITERATIONS = 20
const OFFICIAL_URL_SUFFIX = ".bsky.network"

const now = new Date()

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const NOW = new Date()

async function main () {
const currentData = await makeCurrentData()
createLogFolder("./log")
createDirectory("./log")
createLogFile(currentData)
const entireData = makeEntireData("./log")
createJsonFile(entireData)
createReadMe(entireData)
}

async function makeCurrentData() {
const startedAt = new Date(now)
const startedAt = new Date(NOW)
startedAt.setDate(startedAt.getDate() - TERM_DAYS)
const currentLogs = await fetchCurrentLogs(startedAt, MAX_ITERATIONS)
const endpoints = makeEndpoints(currentLogs)
Expand Down Expand Up @@ -171,15 +167,17 @@ function sortEndpoints (endpoints) {
})
}

function createLogFolder (dirPath) {
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
function createDirectory (dirPath) {
const directoryPath = path.join(__dirname, dirPath)
if (!fs.existsSync(directoryPath)) {
fs.mkdirSync(directoryPath)
}
}

function createLogFile (currentData) {
const suffix = now.getTime()
const suffix = NOW.getTime()
fs.writeFileSync(`./log/list-${suffix}.json`, JSON.stringify(currentData), "utf8")
}

Expand Down Expand Up @@ -227,7 +225,7 @@ function makeEntireData (dirPath) {
sortEndpoints(endpoints)
removeDeadEndpoints(endpoints)
return {
startedAt: now.toISOString(),
startedAt: NOW.toISOString(),
endpoints,
}
}
Expand All @@ -245,7 +243,7 @@ function createJsonFile (entireData) {
}

function createReadMe (currentData) {
const updatedAt = now.toLocaleString()
const updatedAt = NOW.toLocaleString()
const list = currentData.endpoints.map((endpoint) => {
return `* ${endpoint.url} ${endpoint.inviteCodeRequired ? "🎫" : ""} ${endpoint.phoneVerificationRequired ? "📞" : ""}`.trim()
}).join("\n")
Expand Down

0 comments on commit e746d45

Please sign in to comment.