Skip to content

Commit

Permalink
Merge pull request #74 from Samagra-Anamaya/feat-search-by-enumerator
Browse files Browse the repository at this point in the history
Feat search by enumerator
  • Loading branch information
geeky-abhishek authored Oct 12, 2023
2 parents 669a1a4 + 7906b0a commit 12b0376
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/bff/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { PrismaService } from './prisma/prisma.service';
import { PrismaModule } from './prisma/prisma.module';
//import { EnumeratorModule } from './enumerator/enumerator.module';
import { SubmissionService } from './submission/submission.service';
import { ScheduleModule } from './schedule/schedule.module';
// import { ScheduleModule } from './schedule/schedule.module';
import { UtilsModule } from './utils/utils.module';
import { ScheduleService } from './schedule/schedule.service';
//import { ScheduleService } from './schedule/schedule.service';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { CustomLogger } from './common/logger';
Expand All @@ -18,7 +18,7 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
imports: [
PrismaModule,
// EnumeratorModule,
ScheduleModule,
//ScheduleModule,
UtilsModule,
EventEmitterModule.forRoot({
maxListeners: 50,
Expand All @@ -36,7 +36,7 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
AppService,
PrismaService,
SubmissionService,
ScheduleService,
// ScheduleService,
CustomLogger,
],
})
Expand Down
3 changes: 2 additions & 1 deletion packages/bff/src/common/auth-gaurd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export class AuthGuard implements CanActivate {
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
const request = context.switchToHttp().getRequest();
console.log({ headers: request.headers });
const bearerToken = request.headers.authorization?.split(' ')[1];

console.log({ bearerToken });
if (!bearerToken) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/bff/src/common/generate-citizenid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const getCitizenId = (village: any): string => {
return `${village.stateCode}${village.districtCode}${village.blockCode}`;
};
2 changes: 1 addition & 1 deletion packages/bff/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ async function bootstrap() {
SwaggerModule.setup('api', app, document);

app.enableCors();
await app.listen(3000);
await app.listen(3001);
}
bootstrap();
19 changes: 13 additions & 6 deletions packages/bff/src/submission/submission.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
UseFilters,
BadRequestException,
InternalServerErrorException,
Delete,
// UseGuards,
// Headers,
} from '@nestjs/common';
Expand All @@ -23,9 +24,14 @@ import {
} from './dto/submission.dto';
import { PrismaExceptionFilter } from 'src/exceptions/exception-filter';
import { CustomLogger } from 'src/common/logger';
//import { AuthGuard } from 'src/common/auth-gaurd';
// import { AuthGuard } from 'src/common/auth-gaurd';
// import { ApiHeader } from '@nestjs/swagger';

@Controller('submissions')
// @ApiHeader({
// name: 'Authorization',
// description: 'Bearer Token',
// })
// @UseGuards(AuthGuard)
@UseFilters(PrismaExceptionFilter)
export class SubmissionController {
Expand All @@ -51,9 +57,10 @@ export class SubmissionController {
@Get()
async getAllSubmissions(
@Query() query: GetAllSubmissionsDto,
//@Headers('authorization') authorization: string,
// @Headers('Authorization') authorization: string,
): Promise<any> {
try {
// console.log({ authorization });
const page = Number(query.page) || 1;
const limit = Number(query.limit) || 10;

Expand Down Expand Up @@ -165,8 +172,8 @@ export class SubmissionController {
return await this.submissionService.updateSubmission(id, data);
}

// @Delete(':id')
// async deleteSubmission(@Param('id') id: number): Promise<any> {
// return this.submissionService.deleteSubmission(id);
// }
@Delete('deleteAll')
async deleteSubmission(): Promise<any> {
return this.submissionService.deleteAllSubmission();
}
}
5 changes: 5 additions & 0 deletions packages/bff/src/submission/submission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export class SubmissionService {
record?.submissionData?.aadharNumber,
saltRounds,
);
const lastDigits = record.submissionData.aadharNumber.slice(-4);
record.submissionData.lastDigits = lastDigits;
record.submissionData.aadharNumber = hashedAadhar;
return record;
}),
Expand Down Expand Up @@ -277,6 +279,9 @@ export class SubmissionService {
}
}

async deleteAllSubmission(): Promise<any> {
return this.prisma.submission.deleteMany({});
}
// async deleteSubmission(id: number): Promise<any> {
// return this.prisma.submission.delete({
// where: { id },
Expand Down

0 comments on commit 12b0376

Please sign in to comment.