-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from Shubham4026/user_local
Issue PS-1999 : Removed hasura Adapter and Resolved eslint issues
- Loading branch information
Showing
179 changed files
with
7,559 additions
and
9,738 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,105 @@ | ||
import { Body, Controller, Post, Res, Headers, UsePipes, ValidationPipe, UseFilters, BadRequestException, Get, Param, ParseUUIDPipe, UseGuards } from '@nestjs/common'; | ||
import { ApiBasicAuth, ApiBody, ApiCreatedResponse, ApiHeader, ApiInternalServerErrorResponse, ApiResponse, ApiTags } from '@nestjs/swagger'; | ||
import { | ||
Body, | ||
Controller, | ||
Post, | ||
Res, | ||
Headers, | ||
UsePipes, | ||
ValidationPipe, | ||
UseFilters, | ||
BadRequestException, | ||
Get, | ||
Param, | ||
ParseUUIDPipe, | ||
UseGuards, | ||
} from "@nestjs/common"; | ||
import { | ||
ApiBasicAuth, | ||
ApiBody, | ||
ApiCreatedResponse, | ||
ApiHeader, | ||
ApiInternalServerErrorResponse, | ||
ApiResponse, | ||
ApiTags, | ||
} from "@nestjs/swagger"; | ||
import { Response } from "express"; | ||
import { AcademicYearDto } from './dto/academicyears-create.dto'; | ||
import { AcademicYearAdapter } from './academicyearsadaptor'; | ||
import { AllExceptionsFilter } from 'src/common/filters/exception.filter'; | ||
import { APIID } from '@utils/api-id.config'; | ||
import { API_RESPONSES } from '@utils/response.messages'; | ||
import { DateValidationPipe } from 'src/common/pipes/date-validation.pipe'; | ||
import { isUUID } from 'class-validator'; | ||
import { AcademicYearSearchDto } from './dto/academicyears-search.dto'; | ||
import { JwtAuthGuard } from 'src/common/guards/keycloak.guard'; | ||
|
||
import { AcademicYearDto } from "./dto/academicyears-create.dto"; | ||
import { AcademicYearAdapter } from "./academicyearsadaptor"; | ||
import { AllExceptionsFilter } from "src/common/filters/exception.filter"; | ||
import { APIID } from "@utils/api-id.config"; | ||
import { API_RESPONSES } from "@utils/response.messages"; | ||
import { DateValidationPipe } from "src/common/pipes/date-validation.pipe"; | ||
import { isUUID } from "class-validator"; | ||
import { AcademicYearSearchDto } from "./dto/academicyears-search.dto"; | ||
import { JwtAuthGuard } from "src/common/guards/keycloak.guard"; | ||
|
||
@ApiTags("Academicyears") | ||
@Controller('academicyears') | ||
@Controller("academicyears") | ||
@UseGuards(JwtAuthGuard) | ||
export class AcademicyearsController { | ||
constructor(private readonly academicYearAdapter: AcademicYearAdapter) {} | ||
|
||
constructor(private readonly academicYearAdapter: AcademicYearAdapter) { } | ||
|
||
@UseFilters(new AllExceptionsFilter(APIID.ACADEMICYEAR_CREATE)) | ||
@Post('/create') | ||
@ApiBasicAuth("access-token") | ||
@UsePipes(new ValidationPipe({ transform: true }), new DateValidationPipe()) | ||
@ApiBody({ type: AcademicYearDto }) | ||
@ApiCreatedResponse({ description: API_RESPONSES.ACADEMICYEAR }) | ||
@ApiHeader({ name: "tenantid" }) | ||
async createAcademicYears(@Body() academicyearsService: AcademicYearDto, | ||
@Res() response: Response, | ||
@Headers() headers) { | ||
const tenantId = headers["tenantid"]; | ||
if (!tenantId || !isUUID(tenantId)) { | ||
throw new BadRequestException(API_RESPONSES.TENANTID_VALIDATION); | ||
} | ||
let result = await this.academicYearAdapter.buildAcademicYears().createAcademicYear(academicyearsService, tenantId, response) | ||
return response.status(result.statusCode).json(result); | ||
@UseFilters(new AllExceptionsFilter(APIID.ACADEMICYEAR_CREATE)) | ||
@Post("/create") | ||
@ApiBasicAuth("access-token") | ||
@UsePipes(new ValidationPipe({ transform: true }), new DateValidationPipe()) | ||
@ApiBody({ type: AcademicYearDto }) | ||
@ApiCreatedResponse({ description: API_RESPONSES.ACADEMICYEAR }) | ||
@ApiHeader({ name: "tenantid" }) | ||
async createAcademicYears( | ||
@Body() academicyearsService: AcademicYearDto, | ||
@Res() response: Response, | ||
@Headers() headers | ||
) { | ||
const tenantId = headers["tenantid"]; | ||
if (!tenantId || !isUUID(tenantId)) { | ||
throw new BadRequestException(API_RESPONSES.TENANTID_VALIDATION); | ||
} | ||
const result = await this.academicYearAdapter | ||
.buildAcademicYears() | ||
.createAcademicYear(academicyearsService, tenantId, response); | ||
return response.status(result.statusCode).json(result); | ||
} | ||
|
||
@UseFilters(new AllExceptionsFilter(APIID.ACADEMICYEAR_LIST)) | ||
@Post('/list') | ||
@ApiBasicAuth("access-token") | ||
@UsePipes(new ValidationPipe({ transform: true })) | ||
@ApiHeader({ name: "tenantid" }) | ||
@ApiBody({ type: AcademicYearSearchDto }) | ||
@ApiCreatedResponse({ description: API_RESPONSES.ACADEMICYEAR }) | ||
async getAcademicYearList(@Body() academicYearSearchDto: AcademicYearSearchDto, @Res() response: Response, @Headers() headers) { | ||
const tenantId = headers["tenantid"]; | ||
if (!tenantId || !isUUID(tenantId)) { | ||
throw new BadRequestException(API_RESPONSES.TENANTID_VALIDATION); | ||
} | ||
let result = await this.academicYearAdapter.buildAcademicYears().getAcademicYearList(academicYearSearchDto, tenantId, response) | ||
return response.status(result.statusCode).json(result); | ||
@UseFilters(new AllExceptionsFilter(APIID.ACADEMICYEAR_LIST)) | ||
@Post("/list") | ||
@ApiBasicAuth("access-token") | ||
@UsePipes(new ValidationPipe({ transform: true })) | ||
@ApiHeader({ name: "tenantid" }) | ||
@ApiBody({ type: AcademicYearSearchDto }) | ||
@ApiCreatedResponse({ description: API_RESPONSES.ACADEMICYEAR }) | ||
async getAcademicYearList( | ||
@Body() academicYearSearchDto: AcademicYearSearchDto, | ||
@Res() response: Response, | ||
@Headers() headers | ||
) { | ||
const tenantId = headers["tenantid"]; | ||
if (!tenantId || !isUUID(tenantId)) { | ||
throw new BadRequestException(API_RESPONSES.TENANTID_VALIDATION); | ||
} | ||
const result = await this.academicYearAdapter | ||
.buildAcademicYears() | ||
.getAcademicYearList(academicYearSearchDto, tenantId, response); | ||
return response.status(result.statusCode).json(result); | ||
} | ||
|
||
@UseFilters(new AllExceptionsFilter(APIID.ACADEMICYEAR_GET)) | ||
@Get('/:id') | ||
@ApiBasicAuth("access-token") | ||
@ApiResponse({ status: 200, description: API_RESPONSES.ACADEMICYEAR_GET_SUCCESS }) | ||
@ApiInternalServerErrorResponse({ | ||
description: API_RESPONSES.INTERNAL_SERVER_ERROR, | ||
}) | ||
async getAcademicYearById( | ||
@Param('id', new ParseUUIDPipe()) id: string, | ||
@Res() response: Response, | ||
) { | ||
let result = await this.academicYearAdapter.buildAcademicYears().getAcademicYearById(id, response) | ||
return response.status(result.statusCode).json(result); | ||
} | ||
@UseFilters(new AllExceptionsFilter(APIID.ACADEMICYEAR_GET)) | ||
@Get("/:id") | ||
@ApiBasicAuth("access-token") | ||
@ApiResponse({ | ||
status: 200, | ||
description: API_RESPONSES.ACADEMICYEAR_GET_SUCCESS, | ||
}) | ||
@ApiInternalServerErrorResponse({ | ||
description: API_RESPONSES.INTERNAL_SERVER_ERROR, | ||
}) | ||
async getAcademicYearById( | ||
@Param("id", new ParseUUIDPipe()) id: string, | ||
@Res() response: Response | ||
) { | ||
const result = await this.academicYearAdapter | ||
.buildAcademicYears() | ||
.getAcademicYearById(id, response); | ||
return response.status(result.statusCode).json(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AcademicyearsController } from './academicyears.controller'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { AcademicYear } from './entities/academicyears-entity'; | ||
import { AcademicYearAdapter } from './academicyearsadaptor'; | ||
import { PostgresAcademicYearService } from 'src/adapters/postgres/academicyears-adapter'; | ||
import { Module } from "@nestjs/common"; | ||
import { AcademicyearsController } from "./academicyears.controller"; | ||
import { TypeOrmModule } from "@nestjs/typeorm"; | ||
import { AcademicYear } from "./entities/academicyears-entity"; | ||
import { AcademicYearAdapter } from "./academicyearsadaptor"; | ||
import { PostgresAcademicYearService } from "src/adapters/postgres/academicyears-adapter"; | ||
|
||
@Module({ | ||
imports: [ | ||
TypeOrmModule.forFeature([AcademicYear]) | ||
], | ||
imports: [TypeOrmModule.forFeature([AcademicYear])], | ||
providers: [AcademicYearAdapter, PostgresAcademicYearService], | ||
controllers: [AcademicyearsController] | ||
controllers: [AcademicyearsController], | ||
}) | ||
export class AcademicyearsModule { } | ||
export class AcademicyearsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsDateString, IsNotEmpty, IsUUID } from 'class-validator'; | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { IsDateString, IsNotEmpty, IsUUID } from "class-validator"; | ||
|
||
export class AcademicYearDto { | ||
|
||
@ApiProperty({ description: 'startDate', example: '2024-10-05' }) | ||
@IsNotEmpty() | ||
@IsDateString({}, { message: 'startDate must be in ISO 8601 format (e.g., YYYY-MM-DD)' }) | ||
startDate: string; | ||
|
||
@ApiProperty({ description: 'endDate', example: '2024-10-10' }) | ||
@IsDateString({}, { message: 'endDate must be in ISO 8601 format (e.g., YYYY-MM-DD)' }) | ||
endDate: string; | ||
|
||
isActive?: boolean; | ||
|
||
session: string | ||
|
||
tenantId: string | ||
|
||
@ApiProperty({ | ||
type: String, | ||
description: 'createdBy', | ||
example: 'eff008a8-2573-466d-b877-fddf6a4fc13e', | ||
}) | ||
@IsUUID('4', { message: 'createdBy must be a valid UUID' }) | ||
createdBy: string; | ||
|
||
@ApiProperty({ | ||
type: String, | ||
description: 'updatedBy', | ||
example: 'eff008a8-2573-466d-b877-fddf6a4fc13e', | ||
}) | ||
@IsUUID('4', { message: 'updatedBy must be a valid UUID' }) | ||
updatedBy: string; | ||
|
||
@ApiProperty({ description: "startDate", example: "2024-10-05" }) | ||
@IsNotEmpty() | ||
@IsDateString( | ||
{}, | ||
{ message: "startDate must be in ISO 8601 format (e.g., YYYY-MM-DD)" } | ||
) | ||
startDate: string; | ||
|
||
@ApiProperty({ description: "endDate", example: "2024-10-10" }) | ||
@IsDateString( | ||
{}, | ||
{ message: "endDate must be in ISO 8601 format (e.g., YYYY-MM-DD)" } | ||
) | ||
endDate: string; | ||
|
||
isActive?: boolean; | ||
|
||
session: string; | ||
|
||
tenantId: string; | ||
|
||
@ApiProperty({ | ||
type: String, | ||
description: "createdBy", | ||
example: "eff008a8-2573-466d-b877-fddf6a4fc13e", | ||
}) | ||
@IsUUID("4", { message: "createdBy must be a valid UUID" }) | ||
createdBy: string; | ||
|
||
@ApiProperty({ | ||
type: String, | ||
description: "updatedBy", | ||
example: "eff008a8-2573-466d-b877-fddf6a4fc13e", | ||
}) | ||
@IsUUID("4", { message: "updatedBy must be a valid UUID" }) | ||
updatedBy: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsBoolean, IsOptional } from 'class-validator'; | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { IsBoolean, IsOptional } from "class-validator"; | ||
|
||
export class AcademicYearSearchDto { | ||
|
||
@ApiProperty({ description: 'isActive', example: true }) | ||
@IsOptional() | ||
@IsBoolean() | ||
isActive?: boolean; | ||
@ApiProperty({ description: "isActive", example: true }) | ||
@IsOptional() | ||
@IsBoolean() | ||
isActive?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,48 @@ | ||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm'; | ||
|
||
@Entity('AcademicYears') | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
} from "typeorm"; | ||
|
||
@Entity("AcademicYears") | ||
export class AcademicYear { | ||
@PrimaryGeneratedColumn('uuid') | ||
id: string; | ||
@PrimaryGeneratedColumn("uuid") | ||
id: string; | ||
|
||
@Column({ type: 'date', name: 'startDate' }) | ||
startDate: string; | ||
@Column({ type: "date", name: "startDate" }) | ||
startDate: string; | ||
|
||
@Column({ type: 'date', name: 'endDate' }) | ||
endDate: string; | ||
@Column({ type: "date", name: "endDate" }) | ||
endDate: string; | ||
|
||
@Column({ type: 'varchar', length: 15, name: 'session' }) | ||
session: string; | ||
@Column({ type: "varchar", length: 15, name: "session" }) | ||
session: string; | ||
|
||
@CreateDateColumn({ type: 'timestamp', name: 'createdAt', default: () => 'CURRENT_TIMESTAMP' }) | ||
createdAt: Date; | ||
@CreateDateColumn({ | ||
type: "timestamp", | ||
name: "createdAt", | ||
default: () => "CURRENT_TIMESTAMP", | ||
}) | ||
createdAt: Date; | ||
|
||
@UpdateDateColumn({ type: 'timestamp', name: 'updatedAt', default: () => 'CURRENT_TIMESTAMP' }) | ||
updatedAt: Date; | ||
@UpdateDateColumn({ | ||
type: "timestamp", | ||
name: "updatedAt", | ||
default: () => "CURRENT_TIMESTAMP", | ||
}) | ||
updatedAt: Date; | ||
|
||
@Column({ type: 'uuid', nullable: true }) | ||
createdBy: string; | ||
@Column({ type: "uuid", nullable: true }) | ||
createdBy: string; | ||
|
||
@Column({ type: 'uuid', nullable: true }) | ||
updatedBy: string; | ||
@Column({ type: "uuid", nullable: true }) | ||
updatedBy: string; | ||
|
||
@Column({ type: 'boolean', name: 'isActive', default: true }) | ||
isActive: boolean; | ||
@Column({ type: "boolean", name: "isActive", default: true }) | ||
isActive: boolean; | ||
|
||
@Column('uuid', { nullable: false }) | ||
tenantId: string; | ||
@Column("uuid", { nullable: false }) | ||
tenantId: string; | ||
} |
Oops, something went wrong.