mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 21:17:54 +00:00
Add TimeZone module with controller and service
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export * from './timezone.service';
|
||||
@@ -0,0 +1,25 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user