Skip to content

Commit

Permalink
Merge pull request #2 from nobrainr/fix/npm-package
Browse files Browse the repository at this point in the history
Fix/npm package
  • Loading branch information
emyann authored Nov 15, 2018
2 parents 6d69491 + 3eeab81 commit 880fe2f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@
### Installation

```sh

npm install --save axios
npm install --save axios-morphism

```

### Example

```typescript
import { apply, AxiosMorphismConfiguration } from './axios-morphism';

const peopleSchema = { name: 'name', firstName: 'firstName' };
const peopleSchema = {
name: 'name',
height: 'height',
weight: 'mass'
};

const configuration: AxiosMorphismConfiguration = {
url: 'https://api.com',
url: 'https://swapi.co/api/',
interceptors: {
responses: [{ matcher: '/people/:id', schema: peopleSchema }]
}
};

const client = axios.create({baseURL: 'https://swapi.co/api/'});
apply(client, configuration);
await client.get(`https://api.com/people/1`);

await client.get('/people/1');
// {
// name: 'Smith',
// firstName: 'John'
// name: 'Luke Skywalker'
// }
```

Expand Down
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
{
"author": "Yann renaudin",
"name": "axios-morphism",
"description": "",
"version": "1.0.0",
"main": "./dist/axios-morphism.js",
"types": "./dist/axios-morphism.d.ts",
"scripts": {
"build": "npm run build:prod",
"build:dev": "webpack --mode development --config ./webpack.config.js --progress --color --display-error-details",
"build:prod": "cross-env NODE_ENV=production webpack --mode production --config ./webpack.config.js --progress --color --display-error-details --bail",
"clean": "npm cache clear && rimraf -- dist",
"server": "npm run server:dev",
"server:dev": "webpack-dev-server --mode development --config ./webpack.config.js --hot --inline --progress --watch --open",
"server:prod": "cross-env NODE_ENV=production webpack-dev-server --mode production --config ./webpack.config.js --port 3000 --host 0.0.0.0 --hot --inline --progress --watch --open --content-base dist/",
"start": "npm run server:dev",
"test": "karma start",
"semantic-release": "semantic-release"
},
"dependencies": {
"morphism": "^1.6.1",
"path-to-regexp": "^2.4.0",
Expand Down Expand Up @@ -44,19 +58,6 @@
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5"
},
"license": "MIT",
"main": "src/index.ts",
"name": "axios-morphism",
"scripts": {
"build": "npm run build:prod",
"build:dev": "webpack --mode development --config ./webpack.config.js --progress --color --display-error-details",
"build:prod": "cross-env NODE_ENV=production webpack --mode production --config ./webpack.config.js --progress --color --display-error-details --bail",
"clean": "npm cache clear && rimraf -- dist",
"server": "npm run server:dev",
"server:dev": "webpack-dev-server --mode development --config ./webpack.config.js --hot --inline --progress --watch --open",
"server:prod": "cross-env NODE_ENV=production webpack-dev-server --mode production --config ./webpack.config.js --port 3000 --host 0.0.0.0 --hot --inline --progress --watch --open --content-base dist/",
"start": "npm run server:dev",
"test": "karma start",
"semantic-release": "semantic-release"
}
"author": "Yann renaudin",
"license": "MIT"
}

0 comments on commit 880fe2f

Please sign in to comment.