aebedfc52e
Adds an API server with proxy routes for OpenAI and Anthropic clients, along with a frontend portal to interact with the API. Replit-Commit-Author: Agent Replit-Commit-Session-Id: dcd090ca-935a-42ae-8db4-503e1bbe165a Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 61b72c06-3c4d-47af-a97e-9d527892d9c5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/40608c50-a053-47e8-aa03-1bdcc1a2698b/dcd090ca-935a-42ae-8db4-503e1bbe165a/ZBSB1hW Replit-Helium-Checkpoint-Created: true
37 lines
759 B
TypeScript
37 lines
759 B
TypeScript
import express, { type Express } from "express";
|
|
import cors from "cors";
|
|
import pinoHttp from "pino-http";
|
|
import router from "./routes";
|
|
import proxyRouter from "./routes/proxy";
|
|
import { logger } from "./lib/logger";
|
|
|
|
const app: Express = express();
|
|
|
|
app.use(
|
|
pinoHttp({
|
|
logger,
|
|
serializers: {
|
|
req(req) {
|
|
return {
|
|
id: req.id,
|
|
method: req.method,
|
|
url: req.url?.split("?")[0],
|
|
};
|
|
},
|
|
res(res) {
|
|
return {
|
|
statusCode: res.statusCode,
|
|
};
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
app.use(cors());
|
|
app.use(express.json({ limit: "50mb" }));
|
|
app.use(express.urlencoded({ extended: true, limit: "50mb" }));
|
|
|
|
app.use("/api", router);
|
|
app.use("/v1", proxyRouter);
|
|
|
|
export default app;
|