diff --git a/.nvmrc b/.nvmrc index 620c5e1..bb8c76c 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v22.9.0 +v22.11.0 diff --git a/README.md b/README.md index d33e4f8..7f2b3be 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ DID=did:plc:xxx SIGNING_KEY=xxx BSKY_IDENTIFIER=xxx BSKY_PASSWORD=xxx -PORT=4002 -METRICS_PORT=4102 +PORT=4100 +METRICS_PORT=4101 FIREHOSE_URL=wss://jetstream.atproto.tools/subscribe CURSOR_UPDATE_INTERVAL=10000 ``` @@ -47,7 +47,7 @@ The server needs to be reachable outside your local network using the URL you pr ```Caddyfile labeler.example.com { - reverse_proxy 127.0.0.1:4002 + reverse_proxy 127.0.0.1:4100 } ``` diff --git a/package.json b/package.json index dc5d1ee..f7f26ac 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,11 @@ "@types/eslint__js": "^8.42.3", "@types/express": "^4.17.21", "@types/node": "^22.9.0", - "@types/ws": "^8.5.13", "eslint": "^9.14.0", "prettier": "^3.3.3", "tsx": "^4.19.2", "typescript": "^5.6.3", - "typescript-eslint": "^8.13.0" + "typescript-eslint": "^8.14.0" }, "dependencies": { "@atproto/api": "^0.13.15", @@ -38,7 +37,7 @@ "husky": "^9.1.6", "lint-staged": "^15.2.10", "pino": "^9.5.0", - "pino-pretty": "^12.1.0", + "pino-pretty": "^13.0.0", "prom-client": "^15.1.3" } } diff --git a/src/config.ts b/src/config.ts index 982ec54..6234978 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,11 +2,11 @@ import 'dotenv/config'; export const DID = process.env.DID ?? ''; export const SIGNING_KEY = process.env.SIGNING_KEY ?? ''; -export const PORT = process.env.PORT ? Number(process.env.PORT) : 4002; -export const METRICS_PORT = process.env.METRICS_PORT ? Number(process.env.METRICS_PORT) : 4102; +export const PORT = process.env.PORT ? Number(process.env.PORT) : 4100; +export const METRICS_PORT = process.env.METRICS_PORT ? Number(process.env.METRICS_PORT) : 4101; export const FIREHOSE_URL = process.env.FIREHOSE_URL ?? 'wss://jetstream.atproto.tools/subscribe'; export const WANTED_COLLECTION = 'app.bsky.feed.like'; export const BSKY_IDENTIFIER = process.env.BSKY_IDENTIFIER ?? ''; export const BSKY_PASSWORD = process.env.BSKY_PASSWORD ?? ''; export const CURSOR_UPDATE_INTERVAL = - process.env.CURSOR_UPDATE_INTERVAL ? Number(process.env.CURSOR_UPDATE_INTERVAL) : 10000; + process.env.CURSOR_UPDATE_INTERVAL ? Number(process.env.CURSOR_UPDATE_INTERVAL) : 60000; diff --git a/src/label.ts b/src/label.ts index 633306a..b237d25 100644 --- a/src/label.ts +++ b/src/label.ts @@ -63,7 +63,11 @@ function deleteAllLabels(did: string, labels: Set) { function addOrUpdateLabel(did: string, rkey: string, labels: Set) { const newLabel = LABELS.find((label) => label.rkey === rkey); - logger.info(`New label: ${newLabel?.identifier}`); + if (!newLabel) { + logger.warn(`New label not found: ${rkey}. Likely liked a post that's not one for labels.`); + return; + } + logger.info(`New label: ${newLabel.identifier}`); if (labels.size >= LABEL_LIMIT) { try { @@ -75,8 +79,8 @@ function addOrUpdateLabel(did: string, rkey: string, labels: Set) { } try { - labelerServer.createLabel({ uri: did, val: newLabel!.identifier }); - logger.info(`Successfully labeled ${did} with ${newLabel?.identifier}`); + labelerServer.createLabel({ uri: did, val: newLabel.identifier }); + logger.info(`Successfully labeled ${did} with ${newLabel.identifier}`); } catch (error) { logger.error(`Error adding new label: ${error}`); } diff --git a/src/main.ts b/src/main.ts index 8450db3..fb45f22 100644 --- a/src/main.ts +++ b/src/main.ts @@ -60,9 +60,7 @@ jetstream.on('error', (error) => { jetstream.onCreate(WANTED_COLLECTION, (event: CommitCreateEvent) => { // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (event.commit?.record?.subject?.uri?.includes(DID)) { - label(event.did, event.commit.record.subject.uri.split('/').pop()!).catch((error: unknown) => { - logger.error(`Unexpected error labeling ${event.did}: ${error}`); - }); + label(event.did, event.commit.record.subject.uri.split('/').pop()!); } });