@0xsequence/builder 0.0.0-20241216114019
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +219 -0
- package/README.md +4 -0
- package/dist/0xsequence-builder.cjs.d.ts +2 -0
- package/dist/0xsequence-builder.cjs.dev.js +492 -0
- package/dist/0xsequence-builder.cjs.js +7 -0
- package/dist/0xsequence-builder.cjs.prod.js +492 -0
- package/dist/0xsequence-builder.esm.js +454 -0
- package/dist/declarations/src/builder.gen.d.ts +222 -0
- package/dist/declarations/src/index.d.ts +7 -0
- package/package.json +22 -0
- package/src/builder.gen.ts +713 -0
- package/src/index.ts +30 -0
package/src/index.ts
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
export * from './builder.gen'
|
2
|
+
|
3
|
+
import { Builder as BuilderRpc } from './builder.gen'
|
4
|
+
|
5
|
+
export class SequenceBuilderClient extends BuilderRpc {
|
6
|
+
constructor(
|
7
|
+
public projectAccessKey: string,
|
8
|
+
apiUrl?: string
|
9
|
+
) {
|
10
|
+
const hostname = apiUrl ?? 'https://api.sequence.build'
|
11
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
|
12
|
+
this.fetch = this._fetch
|
13
|
+
}
|
14
|
+
|
15
|
+
_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
|
16
|
+
// automatically include access key auth header to requests
|
17
|
+
// if its been set on the api client
|
18
|
+
const headers: { [key: string]: any } = {}
|
19
|
+
|
20
|
+
const projectAccessKey = this.projectAccessKey
|
21
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
22
|
+
headers['X-Access-Key'] = projectAccessKey
|
23
|
+
}
|
24
|
+
|
25
|
+
// before the request is made
|
26
|
+
init!.headers = { ...init!.headers, ...headers }
|
27
|
+
|
28
|
+
return fetch(input, init)
|
29
|
+
}
|
30
|
+
}
|