| 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"); |
| }); |