mirror of
https://github.com/musistudio/claude-code-router.git
synced 2026-06-16 21:03:54 +08:00
24 lines
575 B
TypeScript
24 lines
575 B
TypeScript
import express, { RequestHandler } from "express";
|
|
|
|
interface Server {
|
|
app: express.Application;
|
|
useMiddleware: (middleware: RequestHandler) => void;
|
|
start: () => void;
|
|
}
|
|
|
|
export const createServer = async (port: number): Promise<Server> => {
|
|
const app = express();
|
|
app.use(express.json({ limit: "500mb" }));
|
|
return {
|
|
app,
|
|
useMiddleware: (middleware: RequestHandler) => {
|
|
app.use("/v1/messages", middleware);
|
|
},
|
|
start: () => {
|
|
app.listen(port, () => {
|
|
console.log(`Server is running on port ${port}`);
|
|
});
|
|
},
|
|
};
|
|
};
|