Skip to content

Commit

Permalink
*: test formatting and types (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
montyanderson authored Aug 8, 2023
1 parent 013c787 commit 1badc63
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Validate Formatting & Types

on: [push, pull_request]

jobs:
validate:
steps:
- uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- run: deno fmt --check

- run: deno check prodia.ts
12 changes: 12 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"fmt": {
"useTabs": true,
"lineWidth": 80,
"indentWidth": 4,
"singleQuote": false,
"proseWrap": "preserve"
},
"compilerOptions": {
"noUncheckedIndexedAccess": true
}
}
16 changes: 8 additions & 8 deletions prodia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ export const createProdia = ({ apiKey, base: _base }: CreateProdiaOptions) => {
const base = _base || "https://api.prodia.com/v1";

const headers = {
"X-Prodia-Key": apiKey
"X-Prodia-Key": apiKey,
};

const generate = async (params: ProdiaGenerateRequest) => {
const response = await fetch(`${base}/job`, {
method: "POST",
headers: {
...headers,
"Content-Type": "application/json"
"Content-Type": "application/json",
},
body: JSON.stringify(params)
body: JSON.stringify(params),
});

if (response.status !== 200) {
Expand All @@ -81,9 +81,9 @@ export const createProdia = ({ apiKey, base: _base }: CreateProdiaOptions) => {
method: "POST",
headers: {
...headers,
"Content-Type": "application/json"
"Content-Type": "application/json",
},
body: JSON.stringify(params)
body: JSON.stringify(params),
});

if (response.status !== 200) {
Expand All @@ -95,7 +95,7 @@ export const createProdia = ({ apiKey, base: _base }: CreateProdiaOptions) => {

const getJob = async (jobId: string) => {
const response = await fetch(`${base}/job/${jobId}`, {
headers
headers,
});

if (response.status !== 200) {
Expand All @@ -122,7 +122,7 @@ export const createProdia = ({ apiKey, base: _base }: CreateProdiaOptions) => {

const listModels = async () => {
const response = await fetch(`${base}/models/list`, {
headers
headers,
});

if (response.status !== 200) {
Expand All @@ -137,6 +137,6 @@ export const createProdia = ({ apiKey, base: _base }: CreateProdiaOptions) => {
transform,
wait,
getJob,
listModels
listModels,
};
};
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

Official TypeScript library for Prodia's AI inference API.

- [Get an API Key](https://app.prodia.com/api)
- [Get an API Key](https://app.prodia.com/api)

- [View Docs + Pricing](https://docs.prodia.com/reference/getting-started)
- [View Docs + Pricing](https://docs.prodia.com/reference/getting-started)

## Usage

Expand All @@ -18,12 +18,12 @@ npm install prodia --save
import { createProdia } from "prodia";

const prodia = createProdia({
apiKey: "..."
apiKey: "...",
});

(async () => {
const job = await prodia.generate({
prompt: "puppies in a cloud, 4k"
prompt: "puppies in a cloud, 4k",
});

const { imageUrl, status } = await prodia.wait(job);
Expand All @@ -40,11 +40,11 @@ Create a new Prodia object.

#### `opts`

- `apiKey` (`string`)
- `apiKey` (`string`)

Your API key from the Prodia dashboard.

- `base` (`string`)
- `base` (`string`)

Optional: an enterprise-specific Prodia island.

Expand Down

0 comments on commit 1badc63

Please sign in to comment.