sare26 commited on
Commit
d5e788c
·
verified ·
1 Parent(s): 88b1f94

Update artifacts/api-server/src/app.ts

Browse files
Files changed (1) hide show
  1. artifacts/api-server/src/app.ts +11 -12
artifacts/api-server/src/app.ts CHANGED
@@ -2,32 +2,31 @@ import express, { type Express, type Request, type Response } from "express";
2
  import path from "node:path";
3
  import { fileURLToPath } from "node:url";
4
  import { existsSync } from "node:fs";
5
- import http from "node:http";
6
  import compression from "compression";
7
  import cors from "cors";
8
  import pinoHttp from "pino-http";
 
9
  import router from "./routes";
10
  import { logger } from "./lib/logger";
11
 
12
  const app: Express = express();
13
 
 
 
 
 
 
 
 
 
 
14
  app.use(pinoHttp({ logger, serializers: { req(req) { return { id: req.id, method: req.method, url: req.url?.split("?")[0] }; }, res(res) { return { statusCode: res.statusCode }; } } }));
15
- app.use(compression({ filter: (req, res) => { if (res.getHeader("Content-Type")?.toString().includes("text/event-stream")) return false; return compression.filter(req, res); } }));
16
  app.use(cors());
17
  app.use(express.json({ limit: "5mb" }));
18
  app.use(express.urlencoded({ extended: true }));
19
  app.use("/api", router);
20
 
21
- // 📦 تحميل المشروع كـ ZIP
22
- app.get("/api/download-project", async (_req: Request, res: Response) => {
23
- const { execSync } = await import("node:child_process");
24
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
25
- const projectRoot = path.join(__dirname, "..", "..", "..");
26
- const zipFile = path.join(projectRoot, "project.zip");
27
- execSync(`cd "${projectRoot}" && zip -r project.zip . -x "node_modules/*" "**/node_modules/*" ".git/*" "*.zip"`, { stdio: "ignore" });
28
- if (existsSync(zipFile)) { res.download(zipFile); } else { res.status(404).json({ error: "لم يتم إنشاء الملف" }); }
29
- });
30
-
31
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
32
  const staticDir = path.join(__dirname, "..", "..", "fb-publisher", "dist", "public");
33
 
 
2
  import path from "node:path";
3
  import { fileURLToPath } from "node:url";
4
  import { existsSync } from "node:fs";
 
5
  import compression from "compression";
6
  import cors from "cors";
7
  import pinoHttp from "pino-http";
8
+ import { setupKinde } from "@kinde-oss/kinde-node-express";
9
  import router from "./routes";
10
  import { logger } from "./lib/logger";
11
 
12
  const app: Express = express();
13
 
14
+ // ✅ إعداد Kinde
15
+ setupKinde({
16
+ clientId: process.env.KINDE_BACKEND_CLIENT_ID || "6d63079d509c4a07bd7570882a9056a1",
17
+ issuerBaseUrl: process.env.KINDE_BACKEND_DOMAIN || "https://sare26.kinde.com",
18
+ siteUrl: "https://sare26-fb.hf.space",
19
+ secret: process.env.KINDE_BACKEND_CLIENT_SECRET || "",
20
+ redirectUrl: "https://sare26-fb.hf.space/api/kinde/callback",
21
+ }, app);
22
+
23
  app.use(pinoHttp({ logger, serializers: { req(req) { return { id: req.id, method: req.method, url: req.url?.split("?")[0] }; }, res(res) { return { statusCode: res.statusCode }; } } }));
24
+ app.use(compression());
25
  app.use(cors());
26
  app.use(express.json({ limit: "5mb" }));
27
  app.use(express.urlencoded({ extended: true }));
28
  app.use("/api", router);
29
 
 
 
 
 
 
 
 
 
 
 
30
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
31
  const staticDir = path.join(__dirname, "..", "..", "fb-publisher", "dist", "public");
32