Skip to content

Commit

Permalink
feat(request): remove axios and use native fetch instead (#396)
Browse files Browse the repository at this point in the history
Removes Axios as it was quite heavy on the install size and overkill for
this lib.

BREAKING CHANGE: Since Axios has been removed, error handling with
`AxiosError` will no longer work and should be done in accordance with
the native Node `fetch`.
  • Loading branch information
TiagoGrosso authored Aug 8, 2024
1 parent c9d6372 commit 6036fea
Show file tree
Hide file tree
Showing 73 changed files with 494 additions and 630 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ This package is made by independent contributors and is in no way officially rel

You can find what changed in each version by checking the [Changelog](changelog/changelog.md).

## New since 6.1
## New since 7.0

You can now use this lib to publish stories to your page! Check out the [Publishing media](#publishing-media) section.
This lib is now dependency free 🎉

Axios has been removed as a dependency. `execute()` and `config()` methods still work exactly the same on the outside.

Error handling using `AxiosError` is essentially the major change.

## Installation

Expand Down Expand Up @@ -53,7 +57,7 @@ const pageMediaRequest: GetPageMediaRequest = client.newGetPageMediaRequest();
You can also build each request yourself, and that won't be hard at all. You'll just have to pass the Access Token and the Page ID to each new request. Here's an example:

```typescript
const request: GetPageInfoRequest = new GetPageInfoRequest(ACCESS_TOKEN, PAGE_ID);
const request: GetPageInfoRequest = new GetPageInfoRequest(ACCESS_TOKEN, PAGE_ID);
```

### Executing the requests
Expand Down Expand Up @@ -93,12 +97,12 @@ const config: RequestConfig = request.config();
Publishing Media through the Instagram Graph API, and conversely through this lib, follows these steps:

1. Create an IG Container object. The request will return the container id.
- For photos use `PostPagePhotoMediaRequest`.
- ~~For videos use `PostPageVideoMediaRequest`.~~ Instagram has removed the ability to publish normal/legacy videos through their API. Videos are now always reels.
- For reels use `PostPageReelMediaRequest`.
- For carousels check the [Publishing Carousels section below](#publishing-carousels).
- For Story videos use `PostPageStoryPhotoMediaRequest`
- For Story videos use `PostPageStoryVideoMediaRequest`
- For photos use `PostPagePhotoMediaRequest`.
- ~~For videos use `PostPageVideoMediaRequest`.~~ Instagram has removed the ability to publish normal/legacy videos through their API. Videos are now always reels.
- For reels use `PostPageReelMediaRequest`.
- For carousels check the [Publishing Carousels section below](#publishing-carousels).
- For Story videos use `PostPageStoryPhotoMediaRequest`
- For Story videos use `PostPageStoryVideoMediaRequest`
2. Wait for the IG Container status to move to `FINISHED` (check the status through the `GetContainerRequest`).
3. Publish the IG Container (through the `PostPublishMediaRequest`).

Expand Down Expand Up @@ -224,4 +228,4 @@ request.execute().then((response: GetAuthorizedFacebookPagesResponse) => {

## Release Process

This project follows [Semantic Release](https://github.com/semantic-release/) with a publish on every commit to `master`.
This project follows [Semantic Release](https://github.com/semantic-release/) with a publish on every commit to `master`.
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ const config: Config.InitialOptions = {
statements: 95,
},
},
setupFiles: ['./src/test/SetupJest.ts'],
};
export default config;
187 changes: 68 additions & 119 deletions package-lock.json

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

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"author": "Tiago Grosso <tiagogrosso99@gmail.com>",
"license": "MIT",
"description": "A library to help perform requests to the Instagram Graph API.",
"dependencies": {
"axios": "^0.28.0"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-angular": "^19.3.0",
Expand All @@ -43,13 +40,13 @@
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"axios-mock-adapter": "^1.19.0",
"create-ts-index": "^1.14.0",
"dotenv": "^16.0.3",
"eslint": "^8.27.0",
"eslint-config-google": "^0.14.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"prettier": "3.3.3",
"retry": "^0.13.1",
"rollup": "^2.52.2",
Expand Down
3 changes: 1 addition & 2 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import typescript from 'rollup-plugin-typescript2';
import { terser } from 'rollup-plugin-terser';

const packageJson = require('./package.json');
import packageJson from './package.json';

export default {
input: 'src/Index.ts',
Expand All @@ -14,7 +14,6 @@ export default {
format: 'cjs',
sourcemap: process.env.NODE_ENV === 'dev' ? true : false,
},
external: ['axios'],
plugins: [
peerDepsExternal(),
resolve(),
Expand Down
Loading

0 comments on commit 6036fea

Please sign in to comment.