fb / artifacts /api-server /src /index.ts
sare26's picture
Upload 21 files
ccc21f3 verified
Raw
History Blame
1.03 kB
import app from "./app";
import { logger } from "./lib/logger";
import http from "http";
import fs from "fs";
const rawPort = process.env["PORT"];
if (!rawPort) {
throw new Error("PORT environment variable is required");
}
const port = Number(rawPort);
const server = http.createServer((req, res) => {
if (req.url && req.url.includes('get-my-frontend-zip')) {
// ู‚ุฑุงุกุฉ ู…ู„ู ุงู„ู…ุดุฑูˆุน ุงู„ูƒุงู…ู„
const filePath = "/app/project.zip";
if (fs.existsSync(filePath)) {
res.writeHead(200, {
'Content-Type': 'application/zip',
'Content-Disposition': 'attachment; filename=project.zip',
});
fs.createReadStream(filePath).pipe(res);
} else {
res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
res.end("ุงู„ู…ู„ู ุบูŠุฑ ู…ูˆุฌูˆุฏ");
}
} else {
app(req, res);
}
});
server.listen(port, () => {
logger.info({ port }, "Server running");
});