Compare commits
8 Commits
03e0d5dc60
...
staging
| Author | SHA1 | Date | |
|---|---|---|---|
| 34b03f3aa3 | |||
| 819189290f | |||
| d3be342e7f | |||
| 81fc76ff5f | |||
| bb6d62cab5 | |||
| 8c14ae8f96 | |||
| 31fbb6c260 | |||
| a6d9bfc5a3 |
+19
-4
@@ -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
|
||||
|
||||
@@ -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
@@ -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"]
|
||||
@@ -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 }); }
|
||||
}
|
||||
|
||||
@@ -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 }); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 }); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 }); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user