|
| 1 | +# ipfs-core-types <!-- omit in toc --> |
| 2 | + |
| 3 | +[](http://ipn.io) |
| 4 | +[](http://webchat.freenode.net/?channels=%23ipfs) |
| 5 | +[](http://ipfs.io/) |
| 6 | +[](https://github.com/RichardLitt/standard-readme) |
| 7 | +[](https://david-dm.org/ipfs/js-ipfs?path=packages/interface-ipfs-core) |
| 8 | + |
| 9 | +> IPFS interface definitions used by implementations for API compatibility. |
| 10 | +
|
| 11 | +## Lead Maintainer <!-- omit in toc --> |
| 12 | + |
| 13 | +[Alex Potsides](http://github.com/achingbrain) |
| 14 | + |
| 15 | +## Table of Contents <!-- omit in toc --> |
| 16 | + |
| 17 | +- [Background](#background) |
| 18 | +- [Install](#install) |
| 19 | +- [Usage](#usage) |
| 20 | +- [Validation](#validation) |
| 21 | +- [Contribute](#contribute) |
| 22 | + - [Want to hack on IPFS?](#want-to-hack-on-ipfs) |
| 23 | +- [License](#license) |
| 24 | + |
| 25 | +## Background |
| 26 | + |
| 27 | +The primary goal of this module is to define and ensure that IPFS core implementations and their respective HTTP client libraries implement the same interface, so that developers can quickly change between a local and a remote node without having to change their applications. |
| 28 | + |
| 29 | +It offers set of typescript interface definitions that implementations can claim compatibility with and use typescript to validate those claims. |
| 30 | + |
| 31 | +## Install |
| 32 | + |
| 33 | +In JavaScript land: |
| 34 | + |
| 35 | +```console |
| 36 | +$ npm install ipfs-core-types |
| 37 | +``` |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +Install `ipfs-core-types` as one of the dependencies of your project and use it to ensure your implementations API compatibility: |
| 42 | + |
| 43 | +### In [JSDoc syntax](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) |
| 44 | + |
| 45 | +```js |
| 46 | +/** |
| 47 | + * @implements {import('ipfs-core-types').RootAPI} |
| 48 | + */ |
| 49 | +class Root { |
| 50 | + // your implementation goes here |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +### In Typescript |
| 55 | + |
| 56 | +```ts |
| 57 | +import { RootAPI } from 'ipfs-core-types' |
| 58 | +class Root implements RootAPI { |
| 59 | + // your implementation goes here |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +## Validation |
| 64 | + |
| 65 | +In order to validate API compatibility you can run [typescript](https://www.typescriptlang.org/) over your implementation which will point out all the API compatibilities if there are some. |
| 66 | + |
| 67 | + |
| 68 | +## Contribute |
| 69 | + |
| 70 | +Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs/issues)! |
| 71 | + |
| 72 | +This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). |
| 73 | + |
| 74 | +### Want to hack on IPFS? |
| 75 | + |
| 76 | +[](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) |
| 77 | + |
| 78 | +## License |
| 79 | + |
| 80 | +[](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) |
| 81 | + |
| 82 | +[](https://github.com/ipfs/js-ipfs/tree/master/ipfs-core-types) |
0 commit comments