Skip to content

Commit

Permalink
Merge pull request #31 from DeCenterAI-1/hiro/feat-darts
Browse files Browse the repository at this point in the history
feat/fix: /api/darts
  • Loading branch information
codypharm authored Feb 27, 2025
2 parents e79bf2b + 753fc38 commit 744ffec
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 6 deletions.
Binary file added bun.lockb
Binary file not shown.
14 changes: 11 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ const compat = new FlatCompat({
baseDirectory: __dirname,
});

const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
];
compat.config({
extends: ['next',"next/core-web-vitals", "next/typescript"],
rules: {
'react/no-unescaped-entities': 'off',
'@next/next/no-page-custom-font': 'off',
'@typescript-eslint/no-unused-vars': 'off',
"no-unused-vars": "off"
},
})

const eslintConfig = [...compat.extends()];

export default eslintConfig;
2 changes: 2 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
b:
bun run build
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.6",
"pino-pretty": "^13.0.0",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
Expand Down
155 changes: 155 additions & 0 deletions rest.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
### Options
OPTIONS {{u}}/darts
###

POST {{u}}/api/darts
Content-Type: application/json

{
"module": "cowsay",
"version": "v0.1.3",
"inputs": {
"Message": "Hi from vite dev "
}
}

HTTP/1.1 500 - Internal Server Error
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch
content-type: application/json
date: Thu, 27 Feb 2025 01:42:39 GMT
connection: close
transfer-encoding: chunked
###

POST {{u}}/api/darts
Content-Type: application/json
###

POST https://darts.decenterai.com:8080/darts
Content-Type: application/json

{
"module": "cowsay",
"version": "v0.1.3",
"inputs": {
"Message": "Hi from vite dev "
}
}

HTTP/1.1 500 - Internal Server Error
server: nginx
date: Thu, 27 Feb 2025 01:40:25 GMT
content-type: application/json
content-length: 560
connection: close
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubDomains; preload
###
POST {{u}}/darts
Authorization: Bearer 0xa618896c28db371a21f9d805c25e622425319d85684a1f9478568509a3f3f4a9
Content-Type: application/json

{
"module": "cowsay",
"version": "v0.1.3",
"inputs": {
"Message": "Hi from vite dev "
}
}

HTTP/1.1 500 - Internal Server Error
access-control-allow-origin: *
content-length: 144
content-type: application/json
date: Sun, 12 Jan 2025 20:41:15 GMT
connection: close
###
POST {{u}}/darts
Authorization: Bearer 0xa618896c28db371a21f9d805c25e622425319d85684a1f9478568509a3f3f4a9
Content-Type: application/json

{
"module": "github.com/darts2024/dart-isdxl",
"version": "v1.6.0",
"inputs": {
"Prompt": "Beautiful girl",
"Device": "xpu",
"cpu": "20",
"ram": "22gb",
"Seed": "{{$randomInt 1 10000000}}",
"N":1
},
"author": "e260b0ab-9867-4507-97be-976779c20c9f"
}

HTTP/1.1 404 - Not Found
cache-control: no-store, must-revalidate
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch, Accept-Encoding
x-powered-by: Next.js
content-type: text/html; charset=utf-8
content-encoding: gzip
date: Thu, 27 Feb 2025 02:05:32 GMT
connection: close
transfer-encoding: chunked
###

POST {{u}}/darts
Content-Type: application/json

{
"module": "github.com/darts2024/dart-isdxl",
"version": "v1.3.0",
"inputs": {
"Prompt": "Beautiful girl",
"Device": "xpu",
"Seed": "{{$randomInt 1 10000000}}"
}
}

HTTP/1.1 500 - Internal Server Error
access-control-allow-origin: *
content-length: 204
content-type: application/json
date: Sun, 12 Jan 2025 20:42:37 GMT
connection: close
###

POST {{u}}/api/darts
Authorization: Bearer 0xa618896c28db371a21f9d805c25e622425319d85684a1f9478568509a3f3f4a9
Content-Type: application/json

{
"module": "github.com/darts2024/dart-isdxl",
"version": "v1.6.0",
"inputs": {
"Prompt": "Beautiful girl",
"Device": "xpu",
"Seed": "{{$randomInt 1 10000000}}"
}
}

HTTP/1.1 200 - OK
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch
content-type: application/json
date: Thu, 27 Feb 2025 02:08:56 GMT
connection: close
transfer-encoding: chunked
###

POST {{u}}/api/darts
Content-Type: application/json

{
"module": "cowsay",
"version": "v0.1.3",
"inputs": {
"Message": "Hi from vite dev "
}
}

HTTP/1.1 500 - Internal Server Error
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch
content-type: application/json
date: Thu, 27 Feb 2025 02:07:10 GMT
connection: close
transfer-encoding: chunked
2 changes: 2 additions & 0 deletions src/app/api/darts/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use server"

import { NextRequest, NextResponse } from "next/server";
import { axiosInstance } from "@/lib/axiosInstance";
import axios from "axios";
Expand Down
32 changes: 30 additions & 2 deletions src/lib/axiosInstance.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
import axios from "axios";
import https from "https";


const agent = new https.Agent({
rejectUnauthorized: false, // Disable SSL verification
ca: `-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIUOtTgT7SuASjWkIn/ujXWltfZL0UwDQYJKoZIhvcNAQEL
BQAwajELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxEzARBgNVBAoM
CkRlY2VudGVyQUkxDTALBgNVBAMMBEhpcm8xIjAgBgkqhkiG9w0BCQEWE2hpcm9A
ZGVjZW50ZXJhaS5jb20wHhcNMjQxMjIzMDI1NzQ4WhcNMjUxMjIzMDI1NzQ4WjBq
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTETMBEGA1UECgwKRGVj
ZW50ZXJBSTENMAsGA1UEAwwESGlybzEiMCAGCSqGSIb3DQEJARYTaGlyb0BkZWNl
bnRlcmFpLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJg/WFBA
H9RaiD3toJjTgY+kXuJecxgxq63oUx0wD9mk57QRP/CPcs0eLiezVmvDBr4fVGit
cFwQribNKPEt9O9k3EN8e6ywvNO/3sUybGDYjpD08s68UiMI7Jeybk63nFGUY2oF
ZgkS2nffZATtUhVhvwxl1b6H6jtg7Ts5bZ1c6JJ6kdwefEYpUxdElkXWyH7hV1Dc
2tCOHI3RLm788wX/1AZYJOH9+neh7Jwa26tF04pkjGO8G98MCgcne8I9j5IjQjki
QsNd2lRLDW2+///Y6Y/HTeGymb0xg8ZLaWRRB4+nVSS+aRitTmPkvnRL9WlUh6xF
N+b3lcQt1T8p+BsCAwEAAaNTMFEwHQYDVR0OBBYEFD22hDmAffWveLhzkfLm0P5o
tn8tMB8GA1UdIwQYMBaAFD22hDmAffWveLhzkfLm0P5otn8tMA8GA1UdEwEB/wQF
MAMBAf8wDQYJKoZIhvcNAQELBQADggEBACmztJPRHrzLwhOdgUFid4eUz3TEiV4y
W3+oV9FJX/xPjHIdtehxWL3Fx64sc4MAMutA3lP04mK6BsWKmI04SVHoJ4FCv2Ww
sxjLWnvGxGMzCPdb1utcVjmDyL+3o4h0UEgYDhWMGMl0iILmKGBQ7qnfMy3nsgDy
Y7n1LfRMuwwZcNzTrq4OjpKBjAKPZMy1NZR9cuMEw+fVQOiM4afdsJSt/DOl+aY2
XmIP1S6gHygY805JVAjoGlEv4SYgsJt97/61xZgWZQh8N3PSFn1zR3lbZ3JpDLN2
lQ7Ghuq6/cFOhwmhdh2zUf8x/N8lzzeZqPdy3DYVGPmPyKOAPRsq69s=
-----END CERTIFICATE-----`.trim()
});

export const axiosInstance = axios.create({
baseURL: "https://darts.decenterai.com:8080", // Base URL
// baseURL: "https://darts.decenterai.com:8080", // Base URL
headers: {
"Content-Type": "application/json",
},
httpsAgent: new https.Agent({ rejectUnauthorized: false }), // Allow self-signed SSL
httpsAgent: agent, // Allow self-signed SSL
});

export const axiosInstanceLocal = axios.create({
baseURL: "/",
headers: { "Content-Type": "application/json" },
// httpsAgent: agent, // Allow self-signed SSL
});
2 changes: 1 addition & 1 deletion src/queries/post/sendJobRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const sendJobRequest = async ({
category: "GENERATION",
};

const response = await axiosInstanceLocal.post("api/darts", dto);
const response = await axiosInstanceLocal.post("/api/darts", dto);
return response.data;
} catch (error: unknown) {
console.error("Error sending job request:", error);
Expand Down

0 comments on commit 744ffec

Please sign in to comment.