Add TimeZone module with controller and service

This commit is contained in:
faris Aljohari
2024-07-15 15:46:51 +03:00
parent 31a6377fa6
commit 4a87a42827
5 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1 @@
export * from './timezone.controller';

View File

@ -0,0 +1,33 @@
import {
Controller,
Get,
HttpException,
HttpStatus,
UseGuards,
} from '@nestjs/common';
import { TimeZoneService } from '../services/timezone.service';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
@ApiTags('TimeZone Module')
@Controller({
version: '1',
path: 'timezone',
})
export class TimeZoneController {
constructor(private readonly timeZoneService: TimeZoneService) {}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get()
async getAllTimeZones() {
try {
return await this.timeZoneService.getAllTimeZones();
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
}