Damian
Importing AppType to client defaults output to any types
Client tsconfig.json
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
}
}
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
}
}
7 replies
Importing AppType to client defaults output to any types
Server tsconfig.json
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "Bundler"
}
}
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "Bundler"
}
}
7 replies
Importing AppType to client defaults output to any types
Server src: /packages/functions/src/stableDiffusion.ts
import { Hono } from "hono";
import { handle } from "hono/aws-lambda";
import {
type Model,
type Samplers,
AUTOMATIC1111_BASE_URL,
} from "@tavern/core/stable-diffusion";
const app = new Hono();
const routes = app
.get("/models", async (c) => {
try {
const response = await fetch(
`${AUTOMATIC1111_BASE_URL}/sdapi/v1/sd-models`
);
const data = await response.json();
const models: Model[] = data as Model[];
const formattedModels = models.map((model) => ({
id: model.title,
name: model.model_name,
}));
return c.json(formattedModels, 200);
} catch (e) {
console.error(e);
return c.json({ error: "Failed to Fetch Models" }, 500);
}
})
.get("/samplers", async (c) => {
try {
const response = await fetch(
`${AUTOMATIC1111_BASE_URL}/sdapi/v1/samplers`
);
const data = await response.json();
const samplers: Samplers[] = data as Samplers[];
return c.json({ samplers }, 200);
} catch (e) {
console.error(e);
return c.json({ error: "Failed to Fetch Samplers" }, 500);
}
});
export type AppType = typeof routes;
export const handler = handle(app);
import { Hono } from "hono";
import { handle } from "hono/aws-lambda";
import {
type Model,
type Samplers,
AUTOMATIC1111_BASE_URL,
} from "@tavern/core/stable-diffusion";
const app = new Hono();
const routes = app
.get("/models", async (c) => {
try {
const response = await fetch(
`${AUTOMATIC1111_BASE_URL}/sdapi/v1/sd-models`
);
const data = await response.json();
const models: Model[] = data as Model[];
const formattedModels = models.map((model) => ({
id: model.title,
name: model.model_name,
}));
return c.json(formattedModels, 200);
} catch (e) {
console.error(e);
return c.json({ error: "Failed to Fetch Models" }, 500);
}
})
.get("/samplers", async (c) => {
try {
const response = await fetch(
`${AUTOMATIC1111_BASE_URL}/sdapi/v1/samplers`
);
const data = await response.json();
const samplers: Samplers[] = data as Samplers[];
return c.json({ samplers }, 200);
} catch (e) {
console.error(e);
return c.json({ error: "Failed to Fetch Samplers" }, 500);
}
});
export type AppType = typeof routes;
export const handler = handle(app);
7 replies