@contactlab/appy
Advanced tools
Comparing version 3.0.0-0 to 3.0.0-1
# Changelog | ||
## [3.0.0](https://github.com/contactlab/appy/releases/tag/3.0.0) | ||
[REF: [Milestone 3.0.0](https://github.com/contactlab/appy/milestone/5)] | ||
This version introduces another **big** breaking change with previous API. | ||
Motivations and guide-lines can be found in the related [issue](https://github.com/contactlab/appy/issues/298) and in the [new documentation site](https://contactlab.github.io/appy). | ||
**Breaking:** | ||
- More agnostic API ([#298](https://github.com/contactlab/appy/issues/298)) | ||
## [2.0.1](https://github.com/contactlab/appy/releases/tag/2.0.1) | ||
@@ -131,3 +143,3 @@ | ||
**Breaking Change:** | ||
**Breaking:** | ||
@@ -134,0 +146,0 @@ - Moving from Flow type checker to `Typescript` ([#11](https://github.com/contactlab/appy/issues/11)) |
@@ -1,1 +0,1 @@ | ||
{"name":"@contactlab/appy","version":"3.0.0-0","description":"A functional wrapper around Fetch API","main":"./index.js","module":"./_es6/index.js","typings":"./index.d.ts","sideEffects":false,"author":"Contactlab","license":"Apache-2.0","homepage":"https://contactlab.github.io/appy","bugs":"https://github.com/contactlab/appy/issues","repository":"contactlab/appy","keywords":["contactlab","appy","fetch","fp","fp-ts","typescript"],"engines":{"node":">= 8.10 <13.0","npm":">= 6.0"},"peerDependencies":{"fp-ts":"^2.0.5"},"devDependencies":{"@types/fetch-mock":"^7.3.2","@types/jest":"^25.1.1","@types/node":"^12.12.25","cross-fetch":"^3.0.4","docs-ts":"^0.3.4","eslint":"^6.8.0","eslint-config-contactlab":"^4.2.2","eslint-config-prettier":"^6.10.0","fetch-mock":"^8.3.2","fp-ts":"^2.0.5","husky":"^4.2.1","io-ts":"^2.0.1","jest":"^25.1.0","prettier":"^1.19.1","pretty-quick":"^2.0.1","ts-jest":"^25.2.0","ts-node":"^8.6.2","typescript":"^3.2.2"}} | ||
{"name":"@contactlab/appy","version":"3.0.0-1","description":"A functional wrapper around Fetch API","main":"./index.js","module":"./_es6/index.js","typings":"./index.d.ts","sideEffects":false,"author":"Contactlab","license":"Apache-2.0","homepage":"https://contactlab.github.io/appy","bugs":"https://github.com/contactlab/appy/issues","repository":"contactlab/appy","keywords":["contactlab","appy","fetch","fp","fp-ts","typescript"],"engines":{"node":">= 8.10 <13.0","npm":">= 6.0"},"peerDependencies":{"fp-ts":"^2.0.5"},"devDependencies":{"@types/fetch-mock":"^7.3.2","@types/jest":"^25.1.1","@types/node":"^12.12.25","cross-fetch":"^3.0.4","docs-ts":"^0.3.4","eslint":"^6.8.0","eslint-config-contactlab":"^4.2.2","eslint-config-prettier":"^6.10.0","fetch-mock":"^8.3.2","fp-ts":"^2.0.5","husky":"^4.2.1","io-ts":"^2.0.1","jest":"^25.1.0","prettier":"^1.19.1","pretty-quick":"^2.0.1","ts-jest":"^25.2.0","ts-node":"^8.6.2","typescript":"^3.2.2"}} |
@@ -49,3 +49,3 @@ # @contactlab/appy | ||
// Just an alias for a tuple of `RequesInfo` and `RequestInit` (a.k.a. the `fetch()` parameters) | ||
// Just an alias for a tuple of `RequesInfo` and `RequestInit` (namely the `fetch()` parameters) | ||
type RequestInfoInit = [RequestInfo, RequestInit]; | ||
@@ -91,8 +91,8 @@ ``` | ||
const posts = get('http://jsonplaceholder.typicode.com/posts'); | ||
const users = get('https://reqres.in/api/users'); | ||
posts().then( | ||
users().then( | ||
fold( | ||
err => console.error(err), | ||
data => console.log(data) | ||
resp => console.log(resp.data) | ||
) | ||
@@ -115,14 +115,15 @@ ); | ||
interface Post { | ||
interface User { | ||
id: number; | ||
userId: number; | ||
title: string; | ||
body: string; | ||
email: string; | ||
first_name: string; | ||
last_name: string; | ||
avatar: string; | ||
} | ||
declare const decoder: Decoder<Post>; | ||
declare const userDec: Decoder<User>; | ||
const getPost = pipe(withDecoder(decoder), get); | ||
const getUser = pipe(get, withDecoder(userDec)); | ||
const singlePost = getPost('http://jsonplaceholder.typicode.com/posts/1'); | ||
const singleUser = getUser('https://reqres.in/api/users/1'); | ||
``` | ||
@@ -136,5 +137,5 @@ | ||
const asJson = withHeaders({'Content-Type': 'application/json'})(get); | ||
const asJson = pipe(get, withHeaders({'Content-Type': 'application/json'})); | ||
const posts = asJson('http://jsonplaceholder.typicode.com/posts'); | ||
const users = asJson('https://reqres.in/api/users'); | ||
``` | ||
@@ -150,9 +151,24 @@ | ||
const send = pipe( | ||
withBody({userId: 1234, title: 'My post title', body: 'My post body'}), | ||
post | ||
post, | ||
withBody({email: 'foo.bar@mail.com', first_name: 'Foo', last_name: 'Bar'}) | ||
); | ||
const addPost = send('http://jsonplaceholder.typicode.com/posts'); | ||
const addUser = send('https://reqres.in/api/users'); | ||
``` | ||
### `io-ts` integration | ||
[`io-ts`](https://github.com/gcanti/io-ts) is recommended but is not automatically installed as dependency. | ||
In order to use it with the `Decoder` combinator you can write a simple helper like: | ||
```ts | ||
import * as t from 'io-ts'; | ||
import {failure} from 'io-ts/lib/PathReporter'; | ||
import {Decoder, toDecoder} from '@contactlab/appy/combinators/decoder'; | ||
export const fromIots = <A>(d: t.Decoder<unknown, A>): Decoder<A> => | ||
toDecoder(d.decode, e => new Error(failure(e).join('\n'))); | ||
``` | ||
## About `fetch()` compatibility | ||
@@ -170,4 +186,14 @@ | ||
### Publish a new version | ||
In order to keep the package's file structure as flat as possible, the "usual" npm `publish` command was disabled (via a `prepublishOnly` script) in favour of a `release` script: | ||
```sh | ||
$ npm run release | ||
``` | ||
This command will execute `npm publish` directly in the `/dist` folder, where the `postbuild` script previously copied the `package.json` and other usefull files (`LICENSE`, `CHANGELOG.md`, etc...). | ||
## License | ||
Released under the [Apache 2.0](LICENSE) license. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
72047
29
899
194
2