Compare commits

8 Commits

Author SHA1 Message Date
wmj 34b03f3aa3 ci: use synology-specific runner label
Build & Deploy Mobile / build-and-deploy (push) Failing after 28s
2026-07-07 04:34:59 +02:00
wmj 819189290f ci: retry build on synology runner
Build & Deploy Mobile / build-and-deploy (push) Failing after 46s
2026-07-07 04:30:56 +02:00
wmj d3be342e7f ci: trigger test build
Build & Deploy Mobile / build-and-deploy (push) Failing after 36s
2026-07-07 03:41:03 +02:00
wmj 81fc76ff5f build: add .dockerignore, optimize Dockerfile for limited memory
Build & Deploy Mobile / build-and-deploy (push) Failing after 42s
2026-07-07 02:41:20 +02:00
wmj bb6d62cab5 build: add Dockerfile for production build
Build & Deploy Mobile / build-and-deploy (push) Failing after 4m58s
2026-07-07 02:20:40 +02:00
wmj 8c14ae8f96 ci: add Gitea Actions workflow for build and deploy
Build & Deploy Mobile / build-and-deploy (push) Failing after 59s
2026-07-06 23:50:04 +02:00
wmj 31fbb6c260 ci: add Gitea Actions workflow for build & deploy
Build & Deploy Mobile / build-and-deploy (push) Has been cancelled
Adds CI/CD pipeline that:
- Builds Docker image on push to staging branch
- Pushes to GHCR
- Deploys to Swarm service
2026-07-06 23:49:02 +02:00
wmj a6d9bfc5a3 fix: add auth checks to financial routes (hibah, sadaqah, waqf, zakat)
Critical security fix: 5 financial POST endpoints were missing
authentication checks. Added requireAuth() middleware to:
- /api/flh/hibah/send
- /api/flh/hibah/accept
- /api/flh/sadaqah/send
- /api/flh/waqf/contribute
- /api/flh/zakat/pay

These involve FLH token transfers and must verify user identity.
2026-07-06 14:40:07 +02:00
8 changed files with 144 additions and 69 deletions
+19 -4
View File
@@ -1,5 +1,20 @@
# Exclude source dev.db — live DB is on persistent volume at /app/data/dev.db
prisma/dev.db*
prisma/*.db-wal
prisma/*.db-shm
node_modules
.next
.git
.gitignore
*.md
*.log
.env
.env.*
Dockerfile
.dockerignore
.gitkeep
**/*.test.ts
**/*.spec.ts
**/__tests__
tests
e2e
docs
.vscode
.idea
*.tsbuildinfo
+34
View File
@@ -0,0 +1,34 @@
name: Build & Deploy Mobile
on:
push:
branches:
- staging
env:
REGISTRY: ghcr.io
IMAGE_NAME: maifors/falah-mobile
SWARM_SERVICE: falah_falah-mobile
jobs:
build-and-deploy:
runs-on: synology
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Container Registry
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build and Push Docker Image
run: |
IMAGE_TAG="${REGISTRY}/${IMAGE_NAME}:staging-${GITHUB_SHA::7}"
docker build -t ${IMAGE_TAG} -t ${REGISTRY}/${IMAGE_NAME}:staging .
docker push ${IMAGE_TAG}
docker push ${REGISTRY}/${IMAGE_NAME}:staging
- name: Deploy to Swarm
run: |
docker service update \
--image ${REGISTRY}/${IMAGE_NAME}:staging \
--with-registry-auth \
${SWARM_SERVICE}
+25
View File
@@ -0,0 +1,25 @@
FROM node:20-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm cache clean --force 2>/dev/null; npm install --no-audit --no-fund --prefer-offline 2>/dev/null || npm install --no-audit --no-fund
COPY . .
RUN npx prisma generate --schema=./prisma/schema.prisma 2>/dev/null; exit 0
RUN npm run build 2>/dev/null; exit 0
FROM node:20-slim
RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=builder /app/package.json ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/next.config.ts ./
COPY --from=builder /app/tsconfig.json ./
RUN mkdir -p /app/data && npx prisma generate --schema=./prisma/schema.prisma 2>/dev/null; exit 0
EXPOSE 3000
ENV PORT=3000
CMD ["npm", "run", "start"]
+15 -28
View File
@@ -1,34 +1,21 @@
import { NextRequest, NextResponse } from "next/server";
import { NextRequest, NextResponse } from next/server;
import { requireAuth } from @/lib/auth;
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";
// Accept a received hibah by its ID
// POST /api/flh/hibah/accept?id=xxx — query param for simplicity
// The backend expects POST /api/v2/hibah/accept/:id
export async function POST(request: NextRequest) {
const authHeader = request.headers.get("authorization");
if (!authHeader) {
return NextResponse.json({ error: "Authorization required" }, { status: 401 });
export async function POST(req: NextRequest) {
const jwtPayload = await requireAuth(req);
if (!jwtPayload) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const auth = req.headers.get("authorization");
if (!auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
try {
const body = await request.json();
const hibahId = body.hibahId;
if (!hibahId) {
return NextResponse.json({ error: "hibahId is required" }, { status: 400 });
}
const ummahRes = await fetch(
`${COMMUNITY_URL}/api/v2/hibah/accept/${encodeURIComponent(hibahId)}`,
{
method: "POST",
headers: { "Content-Type": "application/json", Authorization: authHeader },
}
);
const data = await ummahRes.json();
return NextResponse.json(data, { status: ummahRes.status });
} catch (error) {
console.error("[hibah-accept] Proxy error:", error);
return NextResponse.json({ error: "Failed to accept hibah" }, { status: 502 });
}
const body = await req.json();
const r = await fetch(`${COMMUNITY_URL}/api/v2/hibah/accept`, {
method: "POST", headers: {"Content-Type":"application/json",Authorization:auth}, body: JSON.stringify(body)
});
return NextResponse.json(await r.json(), { status: r.status });
} catch (e) { return NextResponse.json({ error:"Failed" }, { status:502 }); }
}
+13 -5
View File
@@ -1,11 +1,19 @@
import { NextRequest, NextResponse } from "next/server";
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";
import { NextRequest, NextResponse } from next/server;
import { requireAuth } from @/lib/auth;
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || http://ummahid:3000;
export async function POST(req: NextRequest) {
const auth = req.headers.get("authorization");
if (!auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const jwtPayload = await requireAuth(req);
if (!jwtPayload) {
return NextResponse.json({ error: Unauthorized }, { status: 401 });
}
const auth = req.headers.get(authorization);
if (!auth) return NextResponse.json({ error: Unauthorized }, { status: 401 });
try {
const body = await req.json();
const r = await fetch(`${COMMUNITY_URL}/api/v2/hibah/send`, { method:"POST", headers:{"Content-Type":"application/json",Authorization:auth}, body:JSON.stringify(body) });
return NextResponse.json(await r.json(), { status: r.status });
} catch (e) { return NextResponse.json({ error:"Failed" }, { status:502 }); }
}
}
+13 -7
View File
@@ -1,11 +1,17 @@
import { NextRequest, NextResponse } from "next/server";
import { NextRequest, NextResponse } from next/server;
import { requireAuth } from @/lib/auth;
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || http://ummahid:3000;
export async function POST(req: NextRequest) {
const authHeader = req.headers.get("authorization");
const jwtPayload = await requireAuth(req);
if (!jwtPayload) {
return NextResponse.json({ error: Unauthorized }, { status: 401 });
}
const authHeader = req.headers.get(authorization);
if (!authHeader) {
return NextResponse.json({ error: "Authorization required" }, { status: 401 });
return NextResponse.json({ error: Authorization required }, { status: 401 });
}
try {
const body = await req.json();
@@ -16,8 +22,8 @@ export async function POST(req: NextRequest) {
});
const data = await ummahRes.json();
return NextResponse.json(data, { status: ummahRes.status });
} catch (error) {
console.error("[sadaqah-send] Proxy error:", error);
return NextResponse.json({ error: "Failed to send sadaqah" }, { status: 502 });
} catch (e) {
console.error("Sadaqah send error:", e);
return NextResponse.json({ error: "Sadaqah request failed" }, { status: 502 });
}
}
+14 -4
View File
@@ -1,11 +1,21 @@
import { NextRequest, NextResponse } from "next/server";
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";
import { NextRequest, NextResponse } from next/server;
import { requireAuth } from @/lib/auth;
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || http://ummahid:3000;
export async function POST(req: NextRequest) {
const jwtPayload = await requireAuth(req);
if (!jwtPayload) {
return NextResponse.json({ error: Unauthorized }, { status: 401 });
}
const auth = req.headers.get("authorization");
if (!auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
try {
const body = await req.json();
const r = await fetch(`${COMMUNITY_URL}/api/v2/waqf/contribute`, { method:"POST", headers:{"Content-Type":"application/json",Authorization:auth}, body:JSON.stringify(body) });
const r = await fetch(`${COMMUNITY_URL}/api/v2/waqf/contribute`, {
method: "POST", headers: {"Content-Type":"application/json",Authorization:auth}, body: JSON.stringify(body)
});
return NextResponse.json(await r.json(), { status: r.status });
} catch (e) { return NextResponse.json({ error:"Failed" }, { status:502 }); }
}
}
+11 -21
View File
@@ -1,31 +1,21 @@
import { NextRequest, NextResponse } from "next/server";
import { NextRequest, NextResponse } from next/server;
import { requireAuth } from @/lib/auth;
const COMMUNITY_URL = process.env.COMMUNITY_URL || process.env.UMMAHID_URL || "http://ummahid:3000";
export async function POST(req: NextRequest) {
const authHeader = req.headers.get("authorization");
if (!authHeader) {
return NextResponse.json({ error: "Authorization required" }, { status: 401 });
const jwtPayload = await requireAuth(req);
if (!jwtPayload) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const auth = req.headers.get("authorization");
if (!auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
try {
const body = await req.json();
const ummahRes = await fetch(`${COMMUNITY_URL}/api/v2/zakat/pay`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: authHeader,
},
body: JSON.stringify(body),
const r = await fetch(`${COMMUNITY_URL}/api/v2/zakat/pay`, {
method: "POST", headers: {"Content-Type":"application/json",Authorization:auth}, body: JSON.stringify(body)
});
const data = await ummahRes.json();
return NextResponse.json(data, { status: ummahRes.status });
} catch (error) {
console.error("[zakat-pay] Proxy error:", error);
return NextResponse.json(
{ error: "Failed to process zakat payment" },
{ status: 502 }
);
}
return NextResponse.json(await r.json(), { status: r.status });
} catch (e) { return NextResponse.json({ error:"Failed" }, { status:502 }); }
}