Files
backend/src/timezone/services/timezone.service.ts
2024-07-15 15:46:51 +03:00

26 lines
655 B
TypeScript

import { TimeZoneRepository } from '@app/common/modules/timezone/repositories';
import {
BadRequestException,
HttpException,
HttpStatus,
Injectable,
} from '@nestjs/common';
@Injectable()
export class TimeZoneService {
constructor(private readonly timeZoneRepository: TimeZoneRepository) {}
async getAllTimeZones() {
try {
const timeZones = await this.timeZoneRepository.find();
return timeZones;
} catch (err) {
if (err instanceof BadRequestException) {
throw err; // Re-throw BadRequestException
} else {
throw new HttpException('TimeZones found', HttpStatus.NOT_FOUND);
}
}
}
}