Skip to content

feat: create js-pinning-service-http-client #1

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

Merged
merged 19 commits into from
Mar 21, 2022
Merged
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
33 changes: 33 additions & 0 deletions .aegir.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
// import { MockServer } from './test/MockServer'

// let mockServer = new MockServer()
require('ts-node').register({
project: 'tsconfig.json',
})

const { MockServerController } = require('./test/MockServerController')


/** @type {import('aegir').PartialOptions} */
module.exports = {
docs: {
publish: true,
entryPoint: './'
},
tsRepo: true,
build: {
config: {
platform: 'node'
},
bundlesizeMax: '44KB'
},
test: {
cov: false,
async before () {
return {
env: {
MOCK_PINNING_SERVER_SECRET: 'ci',
},
controller: new MockServerController(),
}
},
/**
*
* @param {GlobalOptions & TestOptions} _
* @param {MockServerController} controller
*/
async after (_, {controller}) {
await controller.shutdown()
}
}
}
2 changes: 1 addition & 1 deletion .envrc → .envrc-copy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use asdf

export PATH=$(npm bin):${PATH}
export MOCK_PINNING_SERVER_PORT=3000
export MOCK_PINNING_SERVER_SECRET=secret
export DEBUG=0
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
generated/** linguist-generated
53 changes: 41 additions & 12 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,32 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present lint
- run: npm run --if-present dep-check
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- name: lint
run: npm run --if-present lint
- name: dependency check
run: npm run --if-present dep-check

test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [16]
node: ['lts/*']
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- run: npm run --if-present test:node
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
Expand All @@ -48,7 +56,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- run: npm run --if-present test:chrome
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
Expand All @@ -63,7 +74,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- run: npm run --if-present test:chrome-webworker
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
Expand All @@ -78,7 +92,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- run: npm run --if-present test:firefox
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
Expand All @@ -93,7 +110,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- run: npm run --if-present test:firefox-webworker
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
Expand All @@ -108,7 +128,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- run: npx xvfb-maybe npm run --if-present test:electron-main
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
Expand All @@ -123,7 +146,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
Expand All @@ -141,7 +167,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- name: Install dependencies
run: npm install
- name: Generate client files
run: npm run gen
- uses: ipfs/aegir/actions/docker-login@master
with:
docker-token: ${{ secrets.DOCKER_TOKEN }}
Expand Down
60 changes: 0 additions & 60 deletions .github/workflows/test-and-release.yml

This file was deleted.

9 changes: 8 additions & 1 deletion .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ jobs:
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
- name: Use Java for openapi generator
uses: actions/setup-java@v2 # https://github.com/actions/setup-java#basic
with:
distribution: 'temurin'
java-version: '17'
- name: Install dependencies
run: npm install
- name: Generate client from openapi spec
run: npm run gen
- name: Typecheck
uses: gozala/[email protected]
with:
project: test/tsconfig.json
project: tsconfig.json
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ yarn.lock
test/ts-use/tsconfig.tsbuildinfo
test/tsconfig.tsbuildinfo
package-lock.json
*.bak
.swc
.envrc
.nyc_output
generated/fetch/package.json
generated/fetch/tsconfig.json
4 changes: 4 additions & 0 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
require: ['./fixtures.js'],
extensions: ['ts', 'tsx'],
}
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Contributing guidelines

IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md).

We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS.

We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question.

Thank you.
65 changes: 52 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
## @ipfs-shipyard/[email protected]
## IPFS Pinning Service API Client for JS

This generator creates TypeScript/JavaScript client that utilizes fetch-api.
This client was generated using [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) from the [IPFS Pinning Service API spec](https://ipfs.github.io/pinning-services-api-spec/).

You can see the commands used to generate the client in the `gen:fetch` npm script.

### Usage

```
npm install @ipfs-shipyard/pinning-service-client --save
```

This client only has a programmatic API at the moment (no CLI). You use it like so:

```ts

import { Configuration, PinsApi, Status } from '@ipfs-shipyard/pinning-service-client'
import type { PinsGetRequest, PinResults } from '@ipfs-shipyard/pinning-service-client'

const config = new Configuration({
basePath, // the URI for your pinning provider, e.g. `http://localhost:3000`
accessToken, // the secret token/key given to you by your pinning provider
// fetchApi: fetch, // You can pass your own fetchApi implementation, but we use fetch-ponyfill by default.
})

const client = new PinsApi(config)

(async () => {
// Get 10 failed Pins
const pinsGetOptions: PinsGetRequest = {
limit: 10,
status: new Set([Status.Failed]) // requires a set, and not an array
}
const {count, results}: PinResults = await client.pinsGet(pinsGetOptions)

console.log(count, results)

})()

```

## Developing

### Building

Expand All @@ -10,21 +49,21 @@ npm install
npm run build
```

### Publishing
### Contributing

First build the package then run ```npm publish```
See [CONTRIBUTING.md](CONTRIBUTING.md).

### Consuming
### Publishing

navigate to the folder of your consuming project and run one of the following commands.
First build the package then run ```npm publish```

_published:_
## License

```
npm install @ipfs-shipyard/[email protected] --save
```
Licensed under either of

_unPublished (not recommended):_
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)

```
npm install PATH_TO_GENERATED_PACKAGE --save
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.
9 changes: 9 additions & 0 deletions fixtures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

// @ts-check
// export async function mochaGlobalSetup () {

// }

// export async function mochaGlobalTeardown () {

// }
4 changes: 4 additions & 0 deletions generated/fetch/.gitignore

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

1 change: 1 addition & 0 deletions generated/fetch/.npmignore

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

Loading