mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 05:18:11 +00:00
chore: fmt
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { IsDateString, IsEmail, IsOptional, IsString } from 'class-validator';
|
||||
import { IsDateString, IsEmail, IsOptional, IsString } from "class-validator";
|
||||
|
||||
export class CreatePassengerDto {
|
||||
@IsString()
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { BaseEntity } from '@edr/api-common';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { BaseEntity } from "@edr/api-common";
|
||||
import { Column, Entity } from "typeorm";
|
||||
|
||||
@Entity({ name: 'passengers' })
|
||||
@Entity({ name: "passengers" })
|
||||
export class Passenger extends BaseEntity {
|
||||
@Column({ name: 'full_name', type: 'varchar', length: 256 })
|
||||
@Column({ name: "full_name", type: "varchar", length: 256 })
|
||||
fullName!: string;
|
||||
|
||||
@Column({ name: 'email', type: 'varchar', length: 256, unique: true })
|
||||
@Column({ name: "email", type: "varchar", length: 256, unique: true })
|
||||
email!: string;
|
||||
|
||||
@Column({ name: 'phone', type: 'varchar', length: 32 })
|
||||
@Column({ name: "phone", type: "varchar", length: 32 })
|
||||
phone!: string;
|
||||
|
||||
@Column({ name: 'national_id', type: 'varchar', length: 64, nullable: true })
|
||||
@Column({ name: "national_id", type: "varchar", length: 64, nullable: true })
|
||||
nationalId?: string | null;
|
||||
|
||||
@Column({ name: 'date_of_birth', type: 'date', nullable: true })
|
||||
@Column({ name: "date_of_birth", type: "date", nullable: true })
|
||||
dateOfBirth?: string | null;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,37 @@
|
||||
import { Body, Controller, Get, Param, ParseUUIDPipe, Post } from '@nestjs/common';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Post,
|
||||
} from "@nestjs/common";
|
||||
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||
|
||||
import { CreatePassengerDto } from './dto/create-passenger.dto';
|
||||
import { PassengersService } from './passengers.service';
|
||||
import { CreatePassengerDto } from "./dto/create-passenger.dto";
|
||||
import { PassengersService } from "./passengers.service";
|
||||
|
||||
@ApiTags('passengers')
|
||||
@ApiTags("passengers")
|
||||
// @UseGuards(JwtAuthGuard) — TODO: integrate @edr/auth
|
||||
@Controller('passengers')
|
||||
@Controller("passengers")
|
||||
export class PassengersController {
|
||||
constructor(private readonly passengersService: PassengersService) {}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Register a new passenger' })
|
||||
@ApiOperation({ summary: "Register a new passenger" })
|
||||
create(@Body() dto: CreatePassengerDto) {
|
||||
return this.passengersService.create(dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'List all passengers' })
|
||||
@ApiOperation({ summary: "List all passengers" })
|
||||
findAll() {
|
||||
return this.passengersService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Get a passenger by ID' })
|
||||
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
||||
@Get(":id")
|
||||
@ApiOperation({ summary: "Get a passenger by ID" })
|
||||
findOne(@Param("id", ParseUUIDPipe) id: string) {
|
||||
return this.passengersService.findById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Module } from "@nestjs/common";
|
||||
import { TypeOrmModule } from "@nestjs/typeorm";
|
||||
|
||||
import { Passenger } from './entities/passenger.entity';
|
||||
import { PassengersController } from './passengers.controller';
|
||||
import { PassengersRepository } from './passengers.repository';
|
||||
import { PassengersService } from './passengers.service';
|
||||
import { Passenger } from "./entities/passenger.entity";
|
||||
import { PassengersController } from "./passengers.controller";
|
||||
import { PassengersRepository } from "./passengers.repository";
|
||||
import { PassengersService } from "./passengers.service";
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Passenger])],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { BaseRepository } from '@edr/api-common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseRepository } from "@edr/api-common";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
|
||||
import { Passenger } from './entities/passenger.entity';
|
||||
import { Passenger } from "./entities/passenger.entity";
|
||||
|
||||
@Injectable()
|
||||
export class PassengersRepository extends BaseRepository<Passenger> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||
|
||||
import { CreatePassengerDto } from './dto/create-passenger.dto';
|
||||
import { Passenger } from './entities/passenger.entity';
|
||||
import { PassengersRepository } from './passengers.repository';
|
||||
import { CreatePassengerDto } from "./dto/create-passenger.dto";
|
||||
import { Passenger } from "./entities/passenger.entity";
|
||||
import { PassengersRepository } from "./passengers.repository";
|
||||
|
||||
@Injectable()
|
||||
export class PassengersService {
|
||||
@@ -15,7 +15,7 @@ export class PassengersService {
|
||||
|
||||
/** List every passenger (alphabetical). */
|
||||
findAll(): Promise<Passenger[]> {
|
||||
return this.passengersRepository.findAll({ order: { fullName: 'ASC' } });
|
||||
return this.passengersRepository.findAll({ order: { fullName: "ASC" } });
|
||||
}
|
||||
|
||||
/** Get a single passenger by ID. */
|
||||
|
||||
Reference in New Issue
Block a user