Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat typescript mirror #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions .circleci/config.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Continuous Integration
on:
push:
branches:
- master
pull_request:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false

- name: Validate commit messages
if: ${{ github.ref != 'refs/heads/master' }}
uses: wagoid/commitlint-github-action@v3

- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Install packages & build & run tests
run: |
npm ci
npm test
- name: Compile typescript
run: npm run build

- name: Semantic Release
id: semantic_release
if: ${{ github.ref == 'refs/heads/master' }}
uses: cycjimmy/semantic-release-action@v2
env:
GITHUB_TOKEN: ${{ secrets.SAGA_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
semantic_version: 17
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.vscode
.nyc_output
build
node_modules
coverage
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!build/src/**/*
!LICENSE
!README.md
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

ApiReader is a NodeJS & Browser package meant to simplify your requests to any Api.
Browser version is based on native fetch to be as tiny as possible if you use treechecking in your toolbelt (like webpack, create-react-app, ...).
Node version use node-fetch package under the hood to mmaximize code base and ease maintenance.

It features:

- API base url recording at constuction for smaller calls
- automatic query string stringification (based on qs)
- automatic request body JSON stringifying based body type (objects are stringified)
- automatic request body JSON stringifying by default
- automatic response body JSON parsing based on the Content-Type of the Api response
- automatic base64 encoding on Basic Authentication
- custom http error handling hook
Expand Down Expand Up @@ -75,6 +77,7 @@ main();

- **baseUrl**: the base url of the api (e.g.: <https://api.twitter.com/2/>)
- **options**:
- **json**: automatically JSON stringifying and Content-Type set to `application/json` (default: true)
- **auth**:
- **username**: the username of the Basic Authentication
- **password**: the password of the Basic Authentication
Expand All @@ -91,11 +94,9 @@ main();
}
```

> Note: if the final fetchOptions.body is an objet, it will be JSON stringified automatically and the Content-Type will set to "application/json"

- **httpErrorHandler**: an http error handler function which recieve the request object.
- **httpErrorHandler**: an http error handler function which recieve the request object:

The reponse object is a simplified plain version of [Response](https://developer.mozilla.org/fr/docs/Web/API/Request):
The request object is a simplified plain version of [Request](https://developer.mozilla.org/fr/docs/Web/API/Request):

```js
{
Expand All @@ -106,7 +107,7 @@ main();
}
```

and the response object
and the response object:
The reponse object is a simplified plain version of [Response](https://developer.mozilla.org/fr/docs/Web/API/Response):

```js
Expand Down Expand Up @@ -235,7 +236,6 @@ $ npm test:all

### To do

- [ ] improve automatique response parsing, for now buffer are not managed
- [ ] add browser unit tests

## Reporting bugs and contributing
Expand Down
Loading