Merge branch 'alpha' of github.com:Tria-plc/edr-platform into alpha

This commit is contained in:
Stephanos A
2026-07-01 09:03:37 +03:00
140 changed files with 8741 additions and 2360 deletions

View File

@@ -4,6 +4,12 @@
# `migration` stage, invoked as a one-shot container in CI before deploy.
FROM node:24.15.0-alpine AS base
RUN apk add --no-cache libc6-compat
# Put the pnpm content-addressable store under PNPM_HOME so the BuildKit
# `--mount=type=cache,target=/pnpm/store` below actually persists it across
# builds. Without this, pnpm stores in ~/.local/share/pnpm/store and the
# cache mount is a no-op — deps re-download on every pipeline run.
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
FROM base AS pruner
@@ -22,11 +28,14 @@ RUN pnpm --filter "@edr/passenger-api" exec prisma generate
RUN pnpm turbo build --filter="@edr/passenger-api..."
FROM base AS deployer
COPY --from=builder /app/ .
RUN pnpm deploy --filter="@edr/passenger-api" --legacy /deploy
# Copy Prisma schema and generated client to deployment directory
RUN mkdir -p /deploy/node_modules/.prisma /deploy/node_modules/@prisma && \
cp -r node_modules/.prisma/client /deploy/node_modules/.prisma/ 2>/dev/null || true && \
cp -r node_modules/@prisma/client /deploy/node_modules/@prisma/ 2>/dev/null || true
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm deploy --filter="@edr/passenger-api" --legacy /deploy
# The generated Prisma client is NOT in the pnpm store (it's an output of
# `prisma generate`), so `pnpm deploy` does not copy it into /deploy. Regenerate
# it here so the runtime enum values imported from @prisma/client (Currency, …)
# are real objects instead of undefined — otherwise @IsEnum(Currency) throws
# "Cannot convert undefined or null to object" at module load.
RUN cd /deploy && npm run prisma:generate
# --- Migration image: built in CI, run as a one-shot `docker run --rm --env-file ...`
# against the real DB, as its own gated step *before* the app image is built/deployed.
@@ -37,10 +46,7 @@ WORKDIR /deploy
RUN corepack enable && corepack prepare pnpm@11.1.1 --activate
ENV CI=true
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
# Copy the resolution script
COPY apps/edr-passenger-api/scripts/resolve-migrations.sh /deploy/scripts/
RUN chmod +x /deploy/scripts/resolve-migrations.sh
CMD ["sh", "-c", "/deploy/scripts/resolve-migrations.sh && npm run prisma:generate && npm run prisma:migrate && npm run prisma:seed"]
CMD ["sh", "-c", "npm run prisma:generate && npm run prisma:migrate && npm run prisma:seed"]
FROM node:24.15.0-alpine AS runner
RUN apk add --no-cache libc6-compat

View File

@@ -15,6 +15,10 @@ export class DynamicThrottlerGuard extends ThrottlerGuard {
}
async canActivate(context: ExecutionContext): Promise<boolean> {
if (context.getType() !== 'http') {
return true;
}
const [authLimit, authTtl, strictLimit, strictTtl, defaultLimit, defaultTtl] =
await Promise.all([
this.systemConfig.getNumber(CONFIG_KEYS.THROTTLE_AUTH_LIMIT),

View File

@@ -1,5 +1,6 @@
import { Injectable, Logger } from '@nestjs/common';
import { Nack, RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
import { IsPublic } from '@tria-plc/api-common/modules/auth/decorators/public.decorator';
import {
PAYMENT_EVENTS_DLX,
PAYMENT_EVENTS_EXCHANGE,
@@ -19,6 +20,7 @@ export class PaymentEventsConsumer {
constructor(private readonly paymentsService: PaymentsService) {}
@IsPublic()
@RabbitSubscribe({
exchange: PAYMENT_EVENTS_EXCHANGE,
routingKey: paymentServiceBindingPattern(PaymentService.PASSENGER), // payment.passenger.*