-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Print-one/next
docs: issue templates
- Loading branch information
Showing
9 changed files
with
264 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ on: | |
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "docs/**" | ||
- "**/*.md" | ||
jobs: | ||
release: | ||
name: Release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# 1.0.0 (2023-11-30) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* building error ([1fa3a2b](https://github.com/Print-one/print-one-js/commit/1fa3a2b9b43ee92c2ff2a277a8502a19a3bd82f4)) | ||
Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import axios, { Axios, AxiosRequestConfig, AxiosResponse } from "axios"; | ||
import debug from "debug"; | ||
import { HttpHandler } from "./HttpHandler"; | ||
import { PrintOneOptions } from "./PrintOne"; | ||
|
||
export class AxiosHTTPHandler extends HttpHandler<AxiosRequestConfig, AxiosResponse> { | ||
private readonly client: Axios; | ||
|
||
constructor(token: string, options: Required<PrintOneOptions>, debug: debug.Debugger) { | ||
super(token, options, debug); | ||
this.client = axios.create({ | ||
baseURL: new URL(options.version, options.url).href + "/", | ||
responseType: "json", | ||
validateStatus: () => true, | ||
headers: { | ||
"x-api-key": token, | ||
}, | ||
}); | ||
} | ||
/** | ||
* Performs a GET request. | ||
* @param url The url to perform the request to | ||
* @param options The options for the request | ||
*/ | ||
public async GET<T>( | ||
url: string, | ||
options: AxiosRequestConfig = {}, | ||
): Promise<T> { | ||
const response = await this.client.request<T>({ | ||
method: "GET", | ||
url: url, | ||
...options, | ||
}); | ||
|
||
this.debug(`GET ${response.request.path}`); | ||
|
||
this.handleErrors(response); | ||
|
||
return response.data; | ||
} | ||
|
||
/** | ||
* Performs a GET request and returns the response as a ArrayBuffer. | ||
* @param url The url to perform the request to | ||
* @param options The options for the request | ||
*/ | ||
public async GETBuffer( | ||
url: string, | ||
options: AxiosRequestConfig = {}, | ||
): Promise<Uint8Array> { | ||
const response = await this.client.request<number[]>({ | ||
method: "GET", | ||
url: url, | ||
responseType: "arraybuffer", | ||
...options, | ||
}); | ||
|
||
this.debug(`GET ${response.request.path}`); | ||
|
||
this.handleErrors(response); | ||
|
||
return Uint8Array.from(response.data); | ||
} | ||
|
||
/** | ||
* Performs a POST request. | ||
* @param data The data to send with the request | ||
* @param options The options for the request | ||
*/ | ||
public async POST<T>( | ||
url: string, | ||
data: unknown, | ||
options: AxiosRequestConfig = {}, | ||
): Promise<T> { | ||
const response = await this.client.request<T>({ | ||
method: "POST", | ||
url: url, | ||
data: data, | ||
...options, | ||
}); | ||
|
||
this.debug(`POST ${response.request.path}`); | ||
|
||
this.handleErrors(response); | ||
|
||
return response.data; | ||
} | ||
|
||
/** | ||
* Performs a DELETE request. | ||
* @param url The url to perform the request to | ||
* @param options The options for the request | ||
*/ | ||
public async DELETE<T>( | ||
url: string, | ||
options: AxiosRequestConfig = {}, | ||
): Promise<T> { | ||
const response = await this.client.request<T>({ | ||
method: "DELETE", | ||
url: url, | ||
...options, | ||
}); | ||
|
||
this.debug(`DELETE ${response.request.path}`); | ||
|
||
this.handleErrors(response); | ||
|
||
return response.data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.