chore: fmt

This commit is contained in:
Michael Abebe
2026-05-12 16:50:18 +03:00
parent 4540d35215
commit 1c5ee19388
181 changed files with 1492 additions and 1100 deletions

View File

@@ -1,5 +1,13 @@
import { Passenger } from '@edr/types';
import { IsDateString, IsEnum, IsNumber, IsOptional, IsString, IsUUID, Min } from 'class-validator';
import { Passenger } from "@edr/types";
import {
IsDateString,
IsEnum,
IsNumber,
IsOptional,
IsString,
IsUUID,
Min,
} from "class-validator";
export class CreateScheduleDto {
@IsString()

View File

@@ -1,32 +1,32 @@
import { BaseEntity } from '@edr/api-common';
import { Passenger } from '@edr/types';
import { Column, Entity } from 'typeorm';
import { BaseEntity } from "@edr/api-common";
import { Passenger } from "@edr/types";
import { Column, Entity } from "typeorm";
@Entity({ name: 'schedules' })
@Entity({ name: "schedules" })
export class Schedule extends BaseEntity {
@Column({ name: 'train_code', type: 'varchar', length: 32 })
@Column({ name: "train_code", type: "varchar", length: 32 })
trainCode!: string;
@Column({ name: 'origin_station_id', type: 'uuid' })
@Column({ name: "origin_station_id", type: "uuid" })
originStationId!: string;
@Column({ name: 'destination_station_id', type: 'uuid' })
@Column({ name: "destination_station_id", type: "uuid" })
destinationStationId!: string;
@Column({ name: 'departure_time', type: 'timestamptz' })
@Column({ name: "departure_time", type: "timestamptz" })
departureTime!: Date;
@Column({ name: 'arrival_time', type: 'timestamptz' })
@Column({ name: "arrival_time", type: "timestamptz" })
arrivalTime!: Date;
@Column({
name: 'status',
type: 'enum',
name: "status",
type: "enum",
enum: Passenger.ScheduleStatus,
default: Passenger.ScheduleStatus.Scheduled,
})
status!: Passenger.ScheduleStatus;
@Column({ name: 'base_price', type: 'numeric', precision: 10, scale: 2 })
@Column({ name: "base_price", type: "numeric", precision: 10, scale: 2 })
basePrice!: number;
}

View File

@@ -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 { CreateScheduleDto } from './dto/create-schedule.dto';
import { SchedulesService } from './schedules.service';
import { CreateScheduleDto } from "./dto/create-schedule.dto";
import { SchedulesService } from "./schedules.service";
@ApiTags('schedules')
@ApiTags("schedules")
// @UseGuards(JwtAuthGuard) — TODO: integrate @edr/auth
@Controller('schedules')
@Controller("schedules")
export class SchedulesController {
constructor(private readonly schedulesService: SchedulesService) {}
@Post()
@ApiOperation({ summary: 'Publish a new train schedule' })
@ApiOperation({ summary: "Publish a new train schedule" })
create(@Body() dto: CreateScheduleDto) {
return this.schedulesService.create(dto);
}
@Get()
@ApiOperation({ summary: 'List all schedules' })
@ApiOperation({ summary: "List all schedules" })
findAll() {
return this.schedulesService.findAll();
}
@Get(':id')
@ApiOperation({ summary: 'Get a schedule by ID' })
findOne(@Param('id', ParseUUIDPipe) id: string) {
@Get(":id")
@ApiOperation({ summary: "Get a schedule by ID" })
findOne(@Param("id", ParseUUIDPipe) id: string) {
return this.schedulesService.findById(id);
}
}

View File

@@ -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 { Schedule } from './entities/schedule.entity';
import { SchedulesController } from './schedules.controller';
import { SchedulesRepository } from './schedules.repository';
import { SchedulesService } from './schedules.service';
import { Schedule } from "./entities/schedule.entity";
import { SchedulesController } from "./schedules.controller";
import { SchedulesRepository } from "./schedules.repository";
import { SchedulesService } from "./schedules.service";
@Module({
imports: [TypeOrmModule.forFeature([Schedule])],

View File

@@ -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 { Schedule } from './entities/schedule.entity';
import { Schedule } from "./entities/schedule.entity";
@Injectable()
export class SchedulesRepository extends BaseRepository<Schedule> {

View File

@@ -1,8 +1,8 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { Injectable, NotFoundException } from "@nestjs/common";
import { CreateScheduleDto } from './dto/create-schedule.dto';
import { Schedule } from './entities/schedule.entity';
import { SchedulesRepository } from './schedules.repository';
import { CreateScheduleDto } from "./dto/create-schedule.dto";
import { Schedule } from "./entities/schedule.entity";
import { SchedulesRepository } from "./schedules.repository";
@Injectable()
export class SchedulesService {
@@ -19,7 +19,9 @@ export class SchedulesService {
/** List every published schedule. */
findAll(): Promise<Schedule[]> {
return this.schedulesRepository.findAll({ order: { departureTime: 'ASC' } });
return this.schedulesRepository.findAll({
order: { departureTime: "ASC" },
});
}
/** Get a single schedule by ID. */