Skip to content
This repository was archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #114 from data-provider/release
Browse files Browse the repository at this point in the history
Release v3.0.0
  • Loading branch information
javierbrea authored Jan 9, 2021
2 parents 5516563 + 310f5ff commit 9ea70ed
Show file tree
Hide file tree
Showing 34 changed files with 206 additions and 3,745 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
### Fixed
### Removed
### BREAKING CHANGES

## [3.0.0] - 2021-01-09

### Added
- chore: Add data-provider addons recommended tags to package.json

### Changed
- docs: Adapt docs to data-provider v3 API
- chore(deps): Update dependencies

### BREAKING CHANGES
- feat: Remove v2 compatibility

## [2.2.0] - 2021-01-07

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ When querying providers created with this addon, the query object can have one o
```javascript
import { Axios } from "@data-provider/axios";

const booksModel = new Axios("books-model", {
const booksModel = new Axios({
id: "books-model",
url: "/books/:id",
baseUrl: "http://foo.api.com"
});
Expand All @@ -87,7 +88,8 @@ booksModel.query({
```javascript
import { Axios } from "@data-provider/axios";

const booksCollection = new Axios("books-collection", {
const booksCollection = new Axios({
id: "books-collection",
url: "/books/:id",
baseUrl: "http://foo.api.com"
});
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "@data-provider/axios",
"version": "2.2.0",
"version": "3.0.0",
"description": "REST API Data Provider origin addon using Axios",
"keywords": [
"data-provider",
"data-provider-addon",
"data-provider-origin",
"addon",
"origin",
"axios",
Expand Down Expand Up @@ -43,7 +45,7 @@
"test:mutation": "start-server-and-test mocks:silent tcp:3100 stryker:run"
},
"peerDependencies": {
"@data-provider/core": ">=2.10.0"
"@data-provider/core": "3.x"
},
"dependencies": {
"axios": "0.21.0",
Expand All @@ -53,7 +55,7 @@
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"@data-provider/core": "2.10.0",
"@data-provider/core": "3.0.0",
"@mocks-server/admin-api-paths": "1.0.8",
"@mocks-server/main": "1.8.7",
"@rollup/plugin-babel": "5.2.1",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.organization=data-provider
sonar.projectKey=data-provider-axios
sonar.projectVersion=2.2.0
sonar.projectVersion=3.0.0

sonar.javascript.file.suffixes=.js
sonar.sourceEncoding=UTF-8
Expand Down
7 changes: 3 additions & 4 deletions src/Axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

import { Provider, providerArgsV3 } from "@data-provider/core";
import { Provider } from "@data-provider/core";
import { compile } from "path-to-regexp";
import axios from "axios";
import axiosRetry from "axios-retry";
Expand All @@ -26,9 +26,8 @@ import {
import { defaultConfig } from "./defaultConfig";

export class Axios extends Provider {
constructor(...args) {
const [id, options, queryValue] = providerArgsV3(args);
super({ id, ...defaultConfig, ...options }, queryValue);
constructor(options, queryValue) {
super({ ...defaultConfig, ...options }, queryValue);
}

_addOnceBeforeRequest(onceBeforeRequest) {
Expand Down
115 changes: 0 additions & 115 deletions test/apis-add-headers-v3.spec.js

This file was deleted.

16 changes: 5 additions & 11 deletions test/apis-add-headers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe("apis addHeaders method", () => {
describe("when creating api", () => {
describe("if apis addHeaders method is not called", () => {
it("should not set any header", () => {
const api = new Axios("foo-1", {
const api = new Axios({
id: "foo-1",
url: "/foo-1",
});
testsAxios.push(api);
Expand All @@ -41,19 +42,15 @@ describe("apis addHeaders method", () => {
foo: "foo",
},
});
const api = new Axios("foo-2", {
url: "/foo-2",
});
const api = new Axios({ id: "foo-2", url: "/foo-2" });
testsAxios.push(api);
expect(api.headers).toEqual({
foo: "foo",
});
});

it("should apply added headers", () => {
const api = new Axios("foo-2b", {
url: "/foo-2",
});
const api = new Axios({ id: "foo-2b", url: "/foo-2" });
providers.call("addHeaders", {
foo2: "foo2",
});
Expand All @@ -65,10 +62,7 @@ describe("apis addHeaders method", () => {
});

it("should inherit common headers previously defined even when api is tagged", () => {
const api = new Axios("foo-3", {
url: "/foo-3",
tags: ["foo-tag-1"],
});
const api = new Axios({ id: "foo-3", url: "/foo-3", tags: ["foo-tag-1"] });
testsAxios.push(api);
expect(api.headers).toEqual({
foo: "foo",
Expand Down
92 changes: 0 additions & 92 deletions test/apis-clean-v3.spec.js

This file was deleted.

10 changes: 3 additions & 7 deletions test/apis-clean.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ describe("providers clean method", () => {
beforeAll(() => {
providers.clear();
allAxiosSources = providers.getByTag(TAG);
api_1 = new Axios("foo-1");
api_2 = new Axios("foo-2", {
tags: ["tag-1"],
});
api_3 = new Axios("foo-3", {
tags: ["tag-1", "tag-2"],
});
api_1 = new Axios({ id: "foo-1" });
api_2 = new Axios({ id: "foo-2", tags: ["tag-1"] });
api_3 = new Axios({ id: "foo-3", tags: ["tag-1", "tag-2"] });
});

beforeEach(() => {
Expand Down
Loading

0 comments on commit 9ea70ed

Please sign in to comment.