Files
hermes-mcp/product/site/server.mjs
Garfield ecdf332b78 feat: social video uploads + hero page video + TikTok content
Hero page:
- Replace GIF with squaremcp-hero-loop.mp4 (autoplay, muted, loop)
- Update styles, scripts, tests, Dockerfile, baselines
- Deployed and verified

Social video uploads:
- Twitter/X: uploadVideoAndTweet via v1.1 media/upload + v2 tweets
- Facebook: createVideoPost via Graph API /{pageId}/videos
- Instagram: createReel via Graph API (container → poll → publish)
- TikTok: REST endpoints + OpenAPI schema for video upload

Marketing:
- TikTok content prompts, scripts, and posting schedule

Note: Remotion not mentioned in any user-facing content
2026-05-11 13:55:58 -04:00

70 lines
2.0 KiB
JavaScript

import http from "node:http";
import { createReadStream, existsSync } from "node:fs";
import { stat } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const root = __dirname;
const port = Number(process.env.PRODUCT_SITE_PORT || 4173);
const host = "127.0.0.1";
const contentTypes = {
".html": "text/html; charset=utf-8",
".css": "text/css; charset=utf-8",
".js": "text/javascript; charset=utf-8",
".json": "application/json; charset=utf-8",
".mp4": "video/mp4",
};
function resolvePath(urlPath) {
const cleanPath = decodeURIComponent(urlPath.split("?")[0]);
const relativePath = cleanPath === "/" ? "/index.html" : cleanPath;
const absolutePath = path.normalize(path.join(root, relativePath));
if (!absolutePath.startsWith(root)) {
return null;
}
// Try with .html extension for clean URLs (e.g. /privacy → privacy.html)
const withHtml = absolutePath + ".html";
if (!existsSync(absolutePath) && existsSync(withHtml)) return withHtml;
return absolutePath;
}
const server = http.createServer(async (req, res) => {
const filePath = resolvePath(req.url || "/");
if (!filePath) {
res.writeHead(403);
res.end("Forbidden");
return;
}
try {
const fileStat = await stat(filePath);
if (!fileStat.isFile()) {
res.writeHead(404);
res.end("Not found");
return;
}
} catch {
const fallback = path.join(root, "index.html");
if (existsSync(fallback)) {
res.writeHead(200, { "Content-Type": contentTypes[".html"] });
createReadStream(fallback).pipe(res);
return;
}
res.writeHead(404);
res.end("Not found");
return;
}
const ext = path.extname(filePath).toLowerCase();
res.writeHead(200, {
"Content-Type": contentTypes[ext] || "application/octet-stream",
});
createReadStream(filePath).pipe(res);
});
server.listen(port, host, () => {
console.log(`SquareMCP product site running at http://${host}:${port}`);
});