fix(core): resolve local client url redirects and stabilize dev environment

- enforce localhost:5174 for wheel campaign client URL in local development
- lock vite dev server ports using strictPort on admin (5173) and client (5174)
- sanitize .env.example and remove hardcoded staging domain
- configure root dev orchestration and docker multi-stage build context
This commit is contained in:
s.esmaeili
2026-09-13 02:02:46 +03:30
parent efb0051ab9
commit afde44ab8a
67 changed files with 5229 additions and 558 deletions
+6
View File
@@ -2,6 +2,7 @@ FROM node:20-alpine AS builder
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apk add --no-cache openssl
RUN corepack enable pnpm
WORKDIR /app
@@ -9,11 +10,16 @@ WORKDIR /app
COPY . .
RUN pnpm install --frozen-lockfile
RUN pnpm --filter @lucky-wheel/api exec prisma generate
RUN pnpm run build:types
RUN pnpm --filter @lucky-wheel/api build
RUN pnpm deploy --filter @lucky-wheel/api --prod /prod/api
RUN cp -r /app/node_modules/.pnpm/@prisma+client* /prod/api/node_modules/.pnpm/
FROM node:20-alpine AS runner
RUN apk add --no-cache openssl
WORKDIR /app
COPY --from=builder /prod/api .
@@ -0,0 +1,6 @@
-- AlterEnum: add 5 new wheel design themes
ALTER TYPE "WheelDesign" ADD VALUE IF NOT EXISTS 'RUSTIC_WOOD';
ALTER TYPE "WheelDesign" ADD VALUE IF NOT EXISTS 'GALAXY_SPACE';
ALTER TYPE "WheelDesign" ADD VALUE IF NOT EXISTS 'CANDY_LAND';
ALTER TYPE "WheelDesign" ADD VALUE IF NOT EXISTS 'FIRE_FLAME';
ALTER TYPE "WheelDesign" ADD VALUE IF NOT EXISTS 'CRYSTAL_ICE';
+7 -1
View File
@@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
@@ -93,6 +94,11 @@ enum WheelDesign {
MINIMAL_FLAT
LUXURY_GOLD
PLAYFUL_CARTOON
RUSTIC_WOOD
GALAXY_SPACE
CANDY_LAND
FIRE_FLAME
CRYSTAL_ICE
}
// ==================== MODELS ====================
@@ -62,13 +62,27 @@ export class CampaignService {
];
}
const [data, total] = await Promise.all([
const [campaigns, total] = await Promise.all([
this.prisma.campaign.findMany({
where,
skip,
take: pageSize,
orderBy: { createdAt: 'desc' },
include: {
prizes: {
select: {
id: true,
title: true,
type: true,
stockType: true,
initialStock: true,
remainingStock: true,
weight: true,
segmentColor: true,
sortOrder: true,
},
orderBy: { sortOrder: 'asc' },
},
_count: {
select: {
prizes: true,
@@ -81,6 +95,32 @@ export class CampaignService {
this.prisma.campaign.count({ where }),
]);
const formatFarsiDateTime = (d?: Date | null) => {
if (!d) return null;
try {
return new Intl.DateTimeFormat('fa-IR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
}).format(new Date(d));
} catch {
return null;
}
};
const data = campaigns.map((campaign) => {
const prizeTypes = Array.from(new Set(campaign.prizes?.map((p) => p.type) || []));
return {
...campaign,
prizeTypes,
startAtFormatted: formatFarsiDateTime(campaign.startAt),
endAtFormatted: formatFarsiDateTime(campaign.endAt),
createdAtFormatted: formatFarsiDateTime(campaign.createdAt),
};
});
return {
data,
meta: {
+46 -2
View File
@@ -56,8 +56,31 @@ export class WinnerService {
this.prisma.userPrize.count({ where }),
]);
const formatFarsiDateTime = (d?: Date | null) => {
if (!d) return null;
try {
return new Intl.DateTimeFormat('fa-IR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
}).format(new Date(d));
} catch {
return null;
}
};
const enrichedData = data.map((item) => ({
...item,
createdAt: item.wonAt,
wonAtFormatted: formatFarsiDateTime(item.wonAt),
redeemedAtFormatted: formatFarsiDateTime(item.redeemedAt),
prizeType: item.prize?.type,
}));
return {
data,
data: enrichedData,
meta: {
page,
pageSize,
@@ -200,8 +223,29 @@ export class WinnerService {
this.prisma.spin.count({ where }),
]);
const formatFarsiDateTime = (d?: Date | null) => {
if (!d) return null;
try {
return new Intl.DateTimeFormat('fa-IR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
}).format(new Date(d));
} catch {
return null;
}
};
const enrichedData = data.map((item) => ({
...item,
createdAtFormatted: formatFarsiDateTime(item.createdAt),
prizeType: item.prize?.type,
}));
return {
data,
data: enrichedData,
meta: {
page,
pageSize,