short-video-maker
Version:
Creates short videos for TikTok, Instagram Reels, and YouTube Shorts using the Model Context Protocol (MCP) and a REST API.
49 lines (48 loc) • 1.99 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Server = void 0;
const express_1 = __importDefault(require("express"));
const path_1 = __importDefault(require("path"));
const rest_1 = require("./routers/rest");
const mcp_1 = require("./routers/mcp");
const logger_1 = require("../logger");
class Server {
app;
config;
constructor(config, shortCreator) {
this.config = config;
this.app = (0, express_1.default)();
// add healthcheck endpoint
this.app.get("/health", (req, res) => {
res.status(200).json({ status: "ok" });
});
const apiRouter = new rest_1.APIRouter(config, shortCreator);
const mcpRouter = new mcp_1.MCPRouter(shortCreator);
this.app.use("/api", apiRouter.router);
this.app.use("/mcp", mcpRouter.router);
// Serve static files from the UI build
this.app.use(express_1.default.static(path_1.default.join(__dirname, "../../dist/ui")));
this.app.use("/static", express_1.default.static(path_1.default.join(__dirname, "../../static")));
// Serve the React app for all other routes (must be last)
this.app.get("*", (req, res) => {
res.sendFile(path_1.default.join(__dirname, "../../dist/ui/index.html"));
});
}
start() {
const server = this.app.listen(this.config.port, () => {
logger_1.logger.info({ port: this.config.port, mcp: "/mcp", api: "/api" }, "MCP and API server is running");
logger_1.logger.info(`UI server is running on http://localhost:${this.config.port}`);
});
server.on("error", (error) => {
logger_1.logger.error(error, "Error starting server");
});
return server;
}
getApp() {
return this.app;
}
}
exports.Server = Server;