Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
acc43f1
chore(tsconfig): move to dist structure
steebchen Sep 16, 2025
6bea432
ci(workflow): update commands to include `pnpm build`
steebchen Sep 16, 2025
459d650
ci(workflow): reorder setup and build commands
steebchen Sep 16, 2025
595ffe0
chore(dev-scripts): update dev commands to use tsup output
steebchen Sep 16, 2025
ef711e6
refactor(blog): reuse allBlogs without dynamic import
steebchen Sep 16, 2025
c0d5839
chore(build): standardize tsconfig and remove tsup usage
steebchen Sep 16, 2025
0b4e7f7
chore(imports): update to use explicit file extensions
steebchen Sep 16, 2025
25b14d5
chore(build): remove tsup and related configs
steebchen Sep 16, 2025
008fc72
chore(deps): update dependencies and add formatting scripts
steebchen Sep 16, 2025
a13d2d2
chore(imports): update paths and scripts for consistency
steebchen Sep 17, 2025
6919d48
chore(prettier): add .prettierignore files to gateway and api
steebchen Sep 17, 2025
0be5d28
chore(imports): fix import order to satisfy eslint rules
steebchen Sep 17, 2025
62036d7
chore(turbo): add build dependency to generate task
steebchen Sep 17, 2025
f0cddec
chore: wip
steebchen Sep 17, 2025
1a86656
chore: lintstaged
steebchen Sep 17, 2025
93ee185
chore(dev): add tsc-watch for improved DX
steebchen Sep 17, 2025
6ce3651
chore(test-utils): remove console logs in test helpers
steebchen Sep 17, 2025
c924862
chore(models): skip free models in pricing logic
steebchen Sep 17, 2025
ede80f6
Revert "chore(models): skip free models in pricing logic"
steebchen Sep 17, 2025
a065982
chore(package): simplify postinstall script
steebchen Sep 17, 2025
f88089a
Merge remote-tracking branch 'origin/main' into chore/tsconfig
steebchen Sep 17, 2025
8b75145
chore: wip
steebchen Sep 17, 2025
4bde1d6
Merge branch 'main' into chore/tsconfig
steebchen Sep 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ jobs:
uses: ./.github/workflows/run.yml
secrets: inherit
with:
cmd: pnpm lint
cmd: pnpm build && pnpm lint

generate:
uses: ./.github/workflows/run.yml
secrets: inherit
with:
cmd: pnpm generate && git diff --exit-code
cmd: pnpm build && pnpm generate && git diff --exit-code

build:
uses: ./.github/workflows/run.yml
secrets: inherit
with:
cmd: pnpm run setup && pnpm build && bash .github/start.sh
cmd: pnpm build && pnpm run setup && bash .github/start.sh

test:
uses: ./.github/workflows/run.yml
secrets: inherit
with:
cmd: pnpm run setup && pnpm test:unit
cmd: pnpm build && pnpm run setup && pnpm test:unit
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- name: Setup and run e2e shard ${{ matrix.shard }}
run: |
set -eux
pnpm build
pnpm run setup
export DATABASE_URL=postgres://postgres:pw@localhost:5432/test
E2E_TEST=true pnpm vitest run -c vitest/vitest.e2e.config.mts --no-file-parallelism --shard=${{ matrix.shard }}/5 --reporter=blob --outputFile=e2e-results-${{ matrix.shard }}.blob || true
Expand Down
13 changes: 0 additions & 13 deletions .prettierignore

This file was deleted.

5 changes: 5 additions & 0 deletions apps/api/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"package.json": "pnpm sort-package-json",
"**/*.{js,jsx,ts,tsx}": ["pnpm eslint --fix", "pnpm prettier --write"],
"**/*.{md,mdx,json,yml,yaml}": ["pnpm prettier --write"]
}
2 changes: 2 additions & 0 deletions apps/api/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
openapi.json
5 changes: 5 additions & 0 deletions apps/api/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import lint from "../../eslint.config.mjs";
import noRelativeImportPathsPlugin from "eslint-plugin-no-relative-import-paths";

/** @type {import("eslint").Linter.Config[]} */
export default [...lint];
10 changes: 7 additions & 3 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"dist/"
],
"scripts": {
"build": "NODE_OPTIONS=\"--max-old-space-size=8192\" tsc && NODE_OPTIONS=\"--max-old-space-size=8192\" tsup && pnpm run generate",
"dev": "nodemon -e ts,json --exec 'tsx src/serve.ts'",
"generate": "NODE_OPTIONS=\"--max-old-space-size=4096\" tsx ./src/scripts/generate-openapi.ts",
"build": "tsc && resolve-tspaths && pnpm run generate",
"dev": "concurrently \"tsc-watch --onSuccess 'resolve-tspaths'\" \"nodemon dist/serve.js\"",
"format": "eslint --fix . && prettier --write .",
"generate": "node ./dist/scripts/generate-openapi.js",
"lint": "eslint . && prettier --check .",
"start": "node --enable-source-maps dist/serve.js"
},
"dependencies": {
Expand All @@ -21,11 +23,13 @@
"@llmgateway/db": "workspace:*",
"@llmgateway/instrumentation": "workspace:*",
"@llmgateway/logger": "workspace:*",
"@llmgateway/models": "workspace:*",
"@llmgateway/shared": "workspace:*",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/sdk-node": "0.205.0",
"bcrypt-ts": "7.0.0",
"better-auth": "1.2.7",
"dotenv": "16.5.0",
"drizzle-zod": "0.7.1",
"gateway": "workspace:*",
"hono": "^4.9.7",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from "vitest";

import { app } from ".";
import { app } from "./index.js";

test("/", async () => {
const res = await app.request("/");
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/auth/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "vitest";

import { db, tables } from "@llmgateway/db";

import { apiAuth, redisClient } from "./config";
import { apiAuth, redisClient } from "./config.js";

describe("API auth configuration", () => {
test("should inherit basic auth configuration", () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/auth/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { createAuthMiddleware } from "better-auth/api";
import { passkey } from "better-auth/plugins/passkey";
import Redis from "ioredis";
import { Redis } from "ioredis";
import nodemailer from "nodemailer";

import { db, eq, tables } from "@llmgateway/db";
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/auth/handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { OpenAPIHono } from "@hono/zod-openapi";

import { apiAuth } from "./config";
import { apiAuth } from "./config.js";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

// Create a Hono app for auth routes
export const authHandler = new OpenAPIHono<ServerTypes>();
Expand Down
16 changes: 8 additions & 8 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { z } from "zod";
import { db } from "@llmgateway/db";
import { logger } from "@llmgateway/logger";

import { redisClient } from "./auth/config";
import { authHandler } from "./auth/handler";
import { tracingMiddleware } from "./middleware/tracing";
import { routes } from "./routes";
import { beacon } from "./routes/beacon";
import { stripeRoutes } from "./stripe";
import { redisClient } from "./auth/config.js";
import { authHandler } from "./auth/handler.js";
import { tracingMiddleware } from "./middleware/tracing.js";
import { beacon } from "./routes/beacon.js";
import { routes } from "./routes/index.js";
import { stripeRoutes } from "./stripe.js";

import type { ServerTypes } from "./vars";
import type { ServerTypes } from "./vars.js";

export const config = {
servers: [
Expand Down Expand Up @@ -148,7 +148,7 @@ app.openapi(root, async (c) => {

return c.json({
message: "OK",
version: process.env.APP_VERSION || "v0.0.0-unknown",
version: process.env.APP_VERSION || "v0.0.0-55555555",
health,
});
});
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/lib/maskToken.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";

import { maskToken } from "./maskToken";
import { maskToken } from "./maskToken.js";

describe("maskToken", () => {
it("masks all characters after the visible ones", () => {
Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/routes/activity.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";

import { createTestUser, deleteAll } from "@/testing";
import { app } from "@/index.js";
import { createTestUser, deleteAll } from "@/testing.js";

import { db, tables } from "@llmgateway/db";

import { app } from "..";

describe("activity endpoint", () => {
let token: string;
beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from "zod";

import { db } from "@llmgateway/db";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

export const activity = new OpenAPIHono<ServerTypes>();

Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/routes/beacon.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { describe, expect, it, vi } from "vitest";

import { posthog } from "@/posthog";

import { app } from "..";
import { app } from "@/index.js";
import { posthog } from "@/posthog.js";

// Mock PostHog
vi.mock("@/posthog", () => ({
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/beacon.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createRoute, OpenAPIHono } from "@hono/zod-openapi";
import { z } from "zod";

import { posthog } from "@/posthog";
import { posthog } from "@/posthog.js";

import { logger } from "@llmgateway/logger";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

export const beacon = new OpenAPIHono<ServerTypes>();

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from "zod";

import { logger } from "@llmgateway/logger";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

const chat = new OpenAPIHono<ServerTypes>();

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/chats.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { HTTPException } from "hono/http-exception";

import { hasActiveApiKey } from "@/lib/hasActiveApiKey";
import { hasActiveApiKey } from "@/lib/hasActiveApiKey.js";

import { db, tables, desc, eq, count, and } from "@llmgateway/db";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

const chats = new OpenAPIHono<ServerTypes>();

Expand Down
30 changes: 15 additions & 15 deletions apps/api/src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { OpenAPIHono } from "@hono/zod-openapi";

import { apiAuth as auth } from "@/auth/config";

import { activity } from "./activity";
import { chat } from "./chat";
import { chats } from "./chats";
import keysApi from "./keys-api";
import keysProvider from "./keys-provider";
import { logs } from "./logs";
import organization from "./organization";
import { payments } from "./payments";
import projects from "./projects";
import { subscriptions } from "./subscriptions";
import { user } from "./user";

import type { ServerTypes } from "@/vars";
import { apiAuth as auth } from "@/auth/config.js";

import { activity } from "./activity.js";
import { chat } from "./chat.js";
import { chats } from "./chats.js";
import keysApi from "./keys-api.js";
import keysProvider from "./keys-provider.js";
import { logs } from "./logs.js";
import organization from "./organization.js";
import { payments } from "./payments.js";
import projects from "./projects.js";
import { subscriptions } from "./subscriptions.js";
import { user } from "./user.js";

import type { ServerTypes } from "@/vars.js";

export const routes = new OpenAPIHono<ServerTypes>();

Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/routes/keys-api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test, beforeEach, describe, afterEach } from "vitest";

import { createTestUser, deleteAll } from "@/testing";
import { app } from "@/index.js";
import { createTestUser, deleteAll } from "@/testing.js";

import { db, tables } from "@llmgateway/db";

import { app } from "..";

describe("keys route", () => {
let token: string;

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/keys-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { createRoute, OpenAPIHono } from "@hono/zod-openapi";
import { HTTPException } from "hono/http-exception";
import { z } from "zod";

import { maskToken } from "@/lib/maskToken";
import { maskToken } from "@/lib/maskToken.js";

import { eq, db, shortid, tables } from "@llmgateway/db";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

export const keysApi = new OpenAPIHono<ServerTypes>();

Expand Down
13 changes: 7 additions & 6 deletions apps/api/src/routes/keys-provider.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import "dotenv/config";
import { afterAll, beforeAll, describe, expect, test } from "vitest";

import { app } from "@/index";
import { deleteAll } from "@/testing";
import { app } from "@/index.js";
import { deleteAll } from "@/testing.js";

import { db, tables } from "@llmgateway/db";
import { getProviderEnvVar, providers } from "@llmgateway/models";

// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths
import { getConcurrentTestOptions } from "../../../gateway/src/test-utils/test-helpers";
import {
getConcurrentTestOptions,
getProviderEnvVar,
providers,
} from "@llmgateway/models";

// Helper function to generate unique IDs for tests
function generateTestId(): string {
Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/routes/keys-provider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { expect, test, beforeEach, describe, afterEach } from "vitest";

import { createTestUser, deleteAll } from "@/testing";
import { app } from "@/index.js";
import { createTestUser, deleteAll } from "@/testing.js";

import { db, tables } from "@llmgateway/db";

import { app } from "..";

describe("provider keys route", () => {
let token: string;

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/keys-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { createRoute, OpenAPIHono } from "@hono/zod-openapi";
import { HTTPException } from "hono/http-exception";
import { z } from "zod";

import { maskToken } from "@/lib/maskToken";
import { maskToken } from "@/lib/maskToken.js";

import { db, eq, tables } from "@llmgateway/db";
import { providers, validateProviderKey } from "@llmgateway/models";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";
import type { ProviderId } from "@llmgateway/models";

export const keysProvider = new OpenAPIHono<ServerTypes>();
Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/routes/logs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { afterEach, beforeEach, describe, expect, test } from "vitest";

import { createTestUser, deleteAll } from "@/testing";
import { app } from "@/index.js";
import { createTestUser, deleteAll } from "@/testing.js";

import { db, tables } from "@llmgateway/db";

import { app } from "..";

describe("logs route", () => {
let token: string;

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
tools,
} from "@llmgateway/db";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

export const logs = new OpenAPIHono<ServerTypes>();

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from "zod";

import { db, eq, tables } from "@llmgateway/db";

import type { ServerTypes } from "@/vars";
import type { ServerTypes } from "@/vars.js";

export const organization = new OpenAPIHono<ServerTypes>();

Expand Down
Loading
Loading