This commit is contained in:
Stephanos A
2026-06-24 19:54:37 +03:00
4 changed files with 12 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import { Body, Controller, Get, Param, Post, Patch, Delete, UseGuards, Request, Query } from '@nestjs/common'; import { Body, Controller, Get, Param, Post, Patch, Delete, UseGuards, Request, Query } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { IsPublic } from '@tria-plc/api-common/modules/auth/decorators/public.decorator';
import { PackagesService } from './packages.service'; import { PackagesService } from './packages.service';
import { CreatePackageDto, BookPackageDto, CreatePriceTierDto, UpdatePriceTierDto } from './packages.dto'; import { CreatePackageDto, BookPackageDto, CreatePriceTierDto, UpdatePriceTierDto } from './packages.dto';
import { JwtGuard } from '../../common/jwt.guard'; import { JwtGuard } from '../../common/jwt.guard';
@@ -11,6 +12,7 @@ export class PackagesController {
constructor(private readonly service: PackagesService) {} constructor(private readonly service: PackagesService) {}
@Get() @Get()
@IsPublic()
@ApiOperation({ summary: 'List active packages' }) @ApiOperation({ summary: 'List active packages' })
listActive() { listActive() {
return this.service.listActive(); return this.service.listActive();
@@ -33,12 +35,14 @@ export class PackagesController {
} }
@Get('booking/:ref') @Get('booking/:ref')
@IsPublic()
@ApiOperation({ summary: 'Get package booking by reference' }) @ApiOperation({ summary: 'Get package booking by reference' })
getBookingByRef(@Param('ref') ref: string) { getBookingByRef(@Param('ref') ref: string) {
return this.service.getBookingByRef(ref); return this.service.getBookingByRef(ref);
} }
@Get(':id') @Get(':id')
@IsPublic()
@ApiOperation({ summary: 'Get package details' }) @ApiOperation({ summary: 'Get package details' })
getById(@Param('id') id: string) { getById(@Param('id') id: string) {
return this.service.getById(id); return this.service.getById(id);
@@ -93,6 +97,7 @@ export class PackagesController {
} }
@Post('book') @Post('book')
@IsPublic()
@UseGuards(OptionalJwtGuard) @UseGuards(OptionalJwtGuard)
@ApiBearerAuth('JWT-auth') @ApiBearerAuth('JWT-auth')
@ApiOperation({ summary: 'Book a package (public or authenticated)' }) @ApiOperation({ summary: 'Book a package (public or authenticated)' })

View File

@@ -17,6 +17,7 @@ import {
} from '@nestjs/swagger'; } from '@nestjs/swagger';
import { Throttle } from '@nestjs/throttler'; import { Throttle } from '@nestjs/throttler';
import type { TCurrentUser } from '@tria-plc/api-common/modules/auth/types/current-user.type'; import type { TCurrentUser } from '@tria-plc/api-common/modules/auth/types/current-user.type';
import { IsPublic } from '@tria-plc/api-common/modules/auth/decorators/public.decorator';
import { JwtGuard } from '../../common/jwt.guard'; import { JwtGuard } from '../../common/jwt.guard';
import { OptionalJwtGuard } from './optional-jwt.guard'; import { OptionalJwtGuard } from './optional-jwt.guard';
import { import {
@@ -43,6 +44,7 @@ export class VerifaydaController {
constructor(private readonly service: VerifaydaService) {} constructor(private readonly service: VerifaydaService) {}
@Post('start') @Post('start')
@IsPublic()
@HttpCode(HttpStatus.OK) @HttpCode(HttpStatus.OK)
@UseGuards(OptionalJwtGuard) @UseGuards(OptionalJwtGuard)
@ApiBearerAuth('JWT-auth') @ApiBearerAuth('JWT-auth')
@@ -77,6 +79,7 @@ export class VerifaydaController {
} }
@Get('complete') @Get('complete')
@IsPublic()
@ApiOperation({ @ApiOperation({
summary: 'Complete a verification (Fayda redirect / client callback lands here)', summary: 'Complete a verification (Fayda redirect / client callback lands here)',
description: `This is the registered Fayda \`redirect_uri\`. Fayda redirects the browser here with \`?code&state\``, description: `This is the registered Fayda \`redirect_uri\`. Fayda redirects the browser here with \`?code&state\``,

View File

@@ -7,6 +7,7 @@ import {
Role, Role,
RolePermission, RolePermission,
} from '@tria-plc/iamapi-common'; } from '@tria-plc/iamapi-common';
import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource, EntityManager, In } from 'typeorm'; import { DataSource, EntityManager, In } from 'typeorm';
import { ERoleKey } from '@tria-plc/api-common/utils/enums/seed.enum'; import { ERoleKey } from '@tria-plc/api-common/utils/enums/seed.enum';
import { import {
@@ -25,7 +26,7 @@ type SeedOrganization = { id: string; key: string };
export class EdrPassengerOrgSeeder { export class EdrPassengerOrgSeeder {
private readonly logger = new Logger(EdrPassengerOrgSeeder.name); private readonly logger = new Logger(EdrPassengerOrgSeeder.name);
constructor(private readonly dataSource: DataSource) {} constructor(@InjectDataSource() private readonly dataSource: DataSource) {}
async run() { async run() {
if (process.env[SEED_FLAG]?.trim().toLowerCase() !== 'true') { if (process.env[SEED_FLAG]?.trim().toLowerCase() !== 'true') {

View File

@@ -9,6 +9,7 @@ import {
UserCredential, UserCredential,
UserRole, UserRole,
} from '@tria-plc/iamapi-common'; } from '@tria-plc/iamapi-common';
import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
const SEED_FLAG = 'SEED_PASSENGER_STAFF'; const SEED_FLAG = 'SEED_PASSENGER_STAFF';
@@ -25,7 +26,7 @@ const STAFF_USERS = [
export class PassengerStaffUsersSeeder { export class PassengerStaffUsersSeeder {
private readonly logger = new Logger(PassengerStaffUsersSeeder.name); private readonly logger = new Logger(PassengerStaffUsersSeeder.name);
constructor(private readonly dataSource: DataSource) {} constructor(@InjectDataSource() private readonly dataSource: DataSource) {}
async run() { async run() {
if (process.env[SEED_FLAG]?.trim().toLowerCase() !== 'true') { if (process.env[SEED_FLAG]?.trim().toLowerCase() !== 'true') {