File size: 1,028 Bytes
ccc21f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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");
});