Skip to content

Commit

Permalink
feat: Switch Bluesky to custom API implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Nov 19, 2024
1 parent 2d16b2a commit 7c07e90
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 148 deletions.
95 changes: 2 additions & 93 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"version": "0.0.0",
"description": "A utility to retry failed async methods.",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"exports": {
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
}
},
"files": [
Expand All @@ -39,10 +39,10 @@
},
"scripts": {
"build:cts-types": "node -e \"fs.copyFileSync('dist/index.d.ts', 'dist/index.d.cts')\"",
"build": "rollup -c && tsc && npm run build:cts-types",
"build": "rollup -c && tsc -p tsconfig.esm.json && npm run build:cts-types",
"lint": "eslint src/ tests/",
"pretest": "npm run build",
"test:unit": "mocha tests/index.test.js",
"test:unit": "mocha tests/**/*.*",
"test:build": "node tests/pkg.test.cjs && node tests/pkg.test.mjs",
"test:jsr": "npx jsr@latest publish --dry-run",
"test:emfile": "node tools/check-emfile-handling.js",
Expand Down Expand Up @@ -77,7 +77,6 @@
"yorkie": "2.0.0"
},
"dependencies": {
"@atproto/api": "^0.13.15",
"twitter-api-v2": "^1.18.1"
}
}
8 changes: 2 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ export default [
input: "src/index.js",
output: [
{
file: "dist/index.cjs",
file: "dist/cjs/index.cjs",
format: "cjs"
},
{
file: "dist/index.mjs",
format: "esm"
},
{
file: "dist/index.js",
file: "dist/esm/index.js",
format: "esm",
banner: "// @ts-self-types=\"./index.d.ts\""
}
Expand Down
5 changes: 3 additions & 2 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* @typedef {Object} ClientOptions
* @property {Array} strategies An array of strategies to use.
* @property {Array<Strategy>} strategies An array of strategies to use.
*/

/**
Expand Down Expand Up @@ -59,6 +59,7 @@ export class Client {
const results = await Promise.allSettled(this.#strategies.map(strategy => strategy.post(message)));

// find any failed results
/** @type {Array<number>} */
const failedIndices = [];
const failed = /** @type {Array<PromiseRejectedResult>} */ (results.filter((result, i) => {
if (result.status === "rejected") {
Expand All @@ -79,6 +80,6 @@ export class Client {
}

// otherwise return the response payloads keyed by strategy name
return Object.fromEntries(results.map((result, i) => [this.#strategies[i].name, /** @type {PromiseFulfilledResult} */ (result).value]));
return Object.fromEntries(results.map((result, i) => [this.#strategies[i].name, /** @type {PromiseFulfilledResult<Object>} */ (result).value]));
}
}
Loading

0 comments on commit 7c07e90

Please sign in to comment.