Skip to content

Commit b59202f

Browse files
authored
feat: create js-pinning-service-http-client
2 parents 4f02ac0 + a0ebdd6 commit b59202f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2023
-111
lines changed

.aegir.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
1+
// import { MockServer } from './test/MockServer'
2+
3+
// let mockServer = new MockServer()
4+
require('ts-node').register({
5+
project: 'tsconfig.json',
6+
})
7+
8+
const { MockServerController } = require('./test/MockServerController')
9+
10+
111
/** @type {import('aegir').PartialOptions} */
212
module.exports = {
13+
docs: {
14+
publish: true,
15+
entryPoint: './'
16+
},
317
tsRepo: true,
418
build: {
519
config: {
620
platform: 'node'
721
},
822
bundlesizeMax: '44KB'
23+
},
24+
test: {
25+
cov: false,
26+
async before () {
27+
return {
28+
env: {
29+
MOCK_PINNING_SERVER_SECRET: 'ci',
30+
},
31+
controller: new MockServerController(),
32+
}
33+
},
34+
/**
35+
*
36+
* @param {GlobalOptions & TestOptions} _
37+
* @param {MockServerController} controller
38+
*/
39+
async after (_, {controller}) {
40+
await controller.shutdown()
41+
}
942
}
1043
}

.envrc renamed to .envrc-copy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use asdf
22

33
export PATH=$(npm bin):${PATH}
4-
export MOCK_PINNING_SERVER_PORT=3000
54
export MOCK_PINNING_SERVER_SECRET=secret
5+
export DEBUG=0

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
generated/** linguist-generated

.github/workflows/js-test-and-release.yml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,32 @@ jobs:
1616
- uses: actions/setup-node@v2
1717
with:
1818
node-version: lts/*
19-
- uses: ipfs/aegir/actions/cache-node-modules@master
20-
- run: npm run --if-present lint
21-
- run: npm run --if-present dep-check
19+
- name: Install dependencies
20+
run: npm install
21+
- name: Generate client files
22+
run: npm run gen
23+
- name: lint
24+
run: npm run --if-present lint
25+
- name: dependency check
26+
run: npm run --if-present dep-check
2227

2328
test-node:
2429
needs: check
2530
runs-on: ${{ matrix.os }}
2631
strategy:
2732
matrix:
2833
os: [windows-latest, ubuntu-latest, macos-latest]
29-
node: [16]
34+
node: ['lts/*']
3035
fail-fast: true
3136
steps:
3237
- uses: actions/checkout@v2
3338
- uses: actions/setup-node@v2
3439
with:
3540
node-version: ${{ matrix.node }}
36-
- uses: ipfs/aegir/actions/cache-node-modules@master
41+
- name: Install dependencies
42+
run: npm install
43+
- name: Generate client files
44+
run: npm run gen
3745
- run: npm run --if-present test:node
3846
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
3947
with:
@@ -48,7 +56,10 @@ jobs:
4856
- uses: actions/setup-node@v2
4957
with:
5058
node-version: lts/*
51-
- uses: ipfs/aegir/actions/cache-node-modules@master
59+
- name: Install dependencies
60+
run: npm install
61+
- name: Generate client files
62+
run: npm run gen
5263
- run: npm run --if-present test:chrome
5364
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
5465
with:
@@ -63,7 +74,10 @@ jobs:
6374
- uses: actions/setup-node@v2
6475
with:
6576
node-version: lts/*
66-
- uses: ipfs/aegir/actions/cache-node-modules@master
77+
- name: Install dependencies
78+
run: npm install
79+
- name: Generate client files
80+
run: npm run gen
6781
- run: npm run --if-present test:chrome-webworker
6882
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
6983
with:
@@ -78,7 +92,10 @@ jobs:
7892
- uses: actions/setup-node@v2
7993
with:
8094
node-version: lts/*
81-
- uses: ipfs/aegir/actions/cache-node-modules@master
95+
- name: Install dependencies
96+
run: npm install
97+
- name: Generate client files
98+
run: npm run gen
8299
- run: npm run --if-present test:firefox
83100
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
84101
with:
@@ -93,7 +110,10 @@ jobs:
93110
- uses: actions/setup-node@v2
94111
with:
95112
node-version: lts/*
96-
- uses: ipfs/aegir/actions/cache-node-modules@master
113+
- name: Install dependencies
114+
run: npm install
115+
- name: Generate client files
116+
run: npm run gen
97117
- run: npm run --if-present test:firefox-webworker
98118
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
99119
with:
@@ -108,7 +128,10 @@ jobs:
108128
- uses: actions/setup-node@v2
109129
with:
110130
node-version: lts/*
111-
- uses: ipfs/aegir/actions/cache-node-modules@master
131+
- name: Install dependencies
132+
run: npm install
133+
- name: Generate client files
134+
run: npm run gen
112135
- run: npx xvfb-maybe npm run --if-present test:electron-main
113136
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
114137
with:
@@ -123,7 +146,10 @@ jobs:
123146
- uses: actions/setup-node@v2
124147
with:
125148
node-version: lts/*
126-
- uses: ipfs/aegir/actions/cache-node-modules@master
149+
- name: Install dependencies
150+
run: npm install
151+
- name: Generate client files
152+
run: npm run gen
127153
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
128154
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
129155
with:
@@ -141,7 +167,10 @@ jobs:
141167
- uses: actions/setup-node@v2
142168
with:
143169
node-version: lts/*
144-
- uses: ipfs/aegir/actions/cache-node-modules@master
170+
- name: Install dependencies
171+
run: npm install
172+
- name: Generate client files
173+
run: npm run gen
145174
- uses: ipfs/aegir/actions/docker-login@master
146175
with:
147176
docker-token: ${{ secrets.DOCKER_TOKEN }}

.github/workflows/test-and-release.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/typecheck.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ jobs:
2121
uses: actions/[email protected]
2222
with:
2323
node-version: ${{ matrix.node-version }}
24+
- name: Use Java for openapi generator
25+
uses: actions/setup-java@v2 # https://github.com/actions/setup-java#basic
26+
with:
27+
distribution: 'temurin'
28+
java-version: '17'
2429
- name: Install dependencies
2530
run: npm install
31+
- name: Generate client from openapi spec
32+
run: npm run gen
2633
- name: Typecheck
2734
uses: gozala/[email protected]
2835
with:
29-
project: test/tsconfig.json
36+
project: tsconfig.json

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ yarn.lock
99
test/ts-use/tsconfig.tsbuildinfo
1010
test/tsconfig.tsbuildinfo
1111
package-lock.json
12+
*.bak
13+
.swc
14+
.envrc
15+
.nyc_output
16+
generated/fetch/package.json
17+
generated/fetch/tsconfig.json

.mocharc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
require: ['./fixtures.js'],
3+
extensions: ['ts', 'tsx'],
4+
}

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Contributing guidelines
2+
3+
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).
4+
5+
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.
6+
7+
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.
8+
9+
Thank you.

README.md

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
1-
## @ipfs-shipyard/pinning-service-client@1.0.0
1+
## IPFS Pinning Service API Client for JS
22

3-
This generator creates TypeScript/JavaScript client that utilizes fetch-api.
3+
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/).
4+
5+
You can see the commands used to generate the client in the `gen:fetch` npm script.
6+
7+
### Usage
8+
9+
```
10+
npm install @ipfs-shipyard/pinning-service-client --save
11+
```
12+
13+
This client only has a programmatic API at the moment (no CLI). You use it like so:
14+
15+
```ts
16+
17+
import { Configuration, PinsApi, Status } from '@ipfs-shipyard/pinning-service-client'
18+
import type { PinsGetRequest, PinResults } from '@ipfs-shipyard/pinning-service-client'
19+
20+
const config = new Configuration({
21+
basePath, // the URI for your pinning provider, e.g. `http://localhost:3000`
22+
accessToken, // the secret token/key given to you by your pinning provider
23+
// fetchApi: fetch, // You can pass your own fetchApi implementation, but we use fetch-ponyfill by default.
24+
})
25+
26+
const client = new PinsApi(config)
27+
28+
(async () => {
29+
// Get 10 failed Pins
30+
const pinsGetOptions: PinsGetRequest = {
31+
limit: 10,
32+
status: new Set([Status.Failed]) // requires a set, and not an array
33+
}
34+
const {count, results}: PinResults = await client.pinsGet(pinsGetOptions)
35+
36+
console.log(count, results)
37+
38+
})()
39+
40+
```
41+
42+
## Developing
443

544
### Building
645

@@ -10,21 +49,21 @@ npm install
1049
npm run build
1150
```
1251

13-
### Publishing
52+
### Contributing
1453

15-
First build the package then run ```npm publish```
54+
See [CONTRIBUTING.md](CONTRIBUTING.md).
1655

17-
### Consuming
56+
### Publishing
1857

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

21-
_published:_
60+
## License
2261

23-
```
24-
npm install @ipfs-shipyard/[email protected] --save
25-
```
62+
Licensed under either of
2663

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

29-
```
30-
npm install PATH_TO_GENERATED_PACKAGE --save
67+
Unless you explicitly state otherwise, any contribution intentionally submitted
68+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
69+
be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)