Skip to content

Commit

Permalink
style: fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gulfaraz committed Jul 1, 2024
1 parent 1029dc1 commit ab556a7
Show file tree
Hide file tree
Showing 20 changed files with 80 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { HelperService } from '../../shared/helper.service';
import { EventAreaService } from '../admin-area/services/event-area.service';
import { DisasterTypeGeoServerMapper } from '../../scripts/disaster-type-geoserver-file.mapper';

interface RasterData {
originalname: string;
buffer: Buffer;
}

@Injectable()
export class AdminAreaDynamicDataService {
@InjectRepository(AdminAreaDynamicDataEntity)
Expand Down Expand Up @@ -232,9 +237,9 @@ export class AdminAreaDynamicDataService {
const result = await this.adminAreaDynamicDataRepo
.createQueryBuilder('dynamic')
.where({
indicator: indicator,
placeCode: placeCode,
leadTime: leadTime,
indicator,
placeCode,
leadTime,
eventName: eventName === 'no-name' || !eventName ? IsNull() : eventName,
})
.select(['dynamic.value AS value'])
Expand All @@ -244,7 +249,7 @@ export class AdminAreaDynamicDataService {
}

public async postRaster(
data: any,
data: RasterData,
disasterType: DisasterType,
): Promise<void> {
const subfolder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class AdminAreaController {
type: [AdminAreaEntity],
})
@Get('raw/:countryCodeISO3')
public async getAdminAreasRaw(@Param() params): Promise<any[]> {
public async getAdminAreasRaw(@Param() params) {
return await this.adminAreaService.getAdminAreasRaw(params.countryCodeISO3);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class AdminAreaService {
});
}

public async getAdminAreasRaw(countryCodeISO3): Promise<any[]> {
public async getAdminAreasRaw(countryCodeISO3) {
return await this.adminAreaRepository.find({
select: [
'countryCodeISO3',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Post, Body, Get, UseGuards, Param } from '@nestjs/common';
import { EapActionsService } from './eap-actions.service';
import { EapAction, EapActionsService } from './eap-actions.service';
import { UserDecorator } from '../user/user.decorator';
import {
ApiBearerAuth,
Expand Down Expand Up @@ -70,7 +70,7 @@ export class EapActionsController {
@Post('check-external/:countryCodeISO3/:disasterType')
public async checkActionExternally(
@Param() params,
@Body() eapActions: any,
@Body() eapActions: EapAction[],
): Promise<void> {
return await this.eapActionsService.checkActionExternally(
params.countryCodeISO3,
Expand Down
12 changes: 8 additions & 4 deletions services/API-service/src/api/eap-actions/eap-actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { AdminAreaEntity } from '../admin-area/admin-area.entity';
import { AddEapActionsDto } from './dto/eap-action.dto';
import { DisasterType } from '../disaster/disaster-type.enum';

export interface EapAction {
Early_action: string;
placeCode: string;
}

@Injectable()
export class EapActionsService {
@InjectRepository(UserEntity)
Expand Down Expand Up @@ -110,9 +115,8 @@ export class EapActionsService {
public async checkActionExternally(
countryCodeISO3: string,
disasterType: DisasterType,
eapActions,
eapActions: EapAction[],
): Promise<void> {
console.log('eapAction: ', eapActions);
const eapActionIds = eapActions['Early_action'].split(' ');
const actionIds = await this.eapActionRepository.find({
where: {
Expand All @@ -129,7 +133,7 @@ export class EapActionsService {
const placeCode = eapActions['placeCode'];
const adminArea = await this.adminAreaRepository.findOne({
select: ['id'],
where: { placeCode: placeCode },
where: { placeCode },
});

// note: the below will not be able to distinguish between different open events (= typhoon only)
Expand Down Expand Up @@ -223,7 +227,7 @@ export class EapActionsService {
'(' + eapActionsStates.getQuery() + ')',
'status',
'action.id = status."actionCheckedId" AND status."placeCode" = :placeCode',
{ placeCode: placeCode },
{ placeCode },
)
.setParameters(eapActionsStates.getParameters())
.leftJoin('action.areaOfFocus', 'area')
Expand Down
3 changes: 2 additions & 1 deletion services/API-service/src/api/event/event.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ export class EventController {
);
}
const bufferStream = new stream.PassThrough();
bufferStream.end(Buffer.from(blob, 'binary'));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
bufferStream.end(Buffer.from(blob as any, 'binary'));
response.writeHead(HttpStatus.OK, {
'Content-Type': 'image/png',
});
Expand Down
3 changes: 2 additions & 1 deletion services/API-service/src/api/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class EventService {
}

private async populateEventsDetails(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
rawEvents: any[],
countryCodeISO3: string,
disasterType: DisasterType,
Expand Down Expand Up @@ -1025,7 +1026,7 @@ export class EventService {
countryCodeISO3: string,
disasterType: DisasterType,
eventName: string,
): Promise<any> {
): Promise<Buffer> {
const eventMapImageEntity = await this.eventMapImageRepository.findOne({
where: {
countryCodeISO3: countryCodeISO3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class GlofasStationController {
description: 'Glofas station locations and attributes for given country.',
})
@Get(':countryCodeISO3')
public async getStationsByCountry(@Param() params): Promise<any[]> {
public async getStationsByCountry(@Param() params) {
return await this.glofasStationService.getStationsByCountry(
params.countryCodeISO3,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class GlofasStationService {

public constructor(private readonly pointDataService: PointDataService) {}

public async getStationsByCountry(countryCodeISO3: string): Promise<any[]> {
public async getStationsByCountry(countryCodeISO3: string) {
const stations = await this.pointDataService.getPointDataByCountry(
PointDataEnum.glofasStations,
countryCodeISO3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class LinesDataService {

public constructor(private readonly helperService: HelperService) {}

private getDtoPerLinesDataCategory(linesDataCategory: LinesDataEnum): any {
private getDtoPerLinesDataCategory(linesDataCategory: LinesDataEnum) {
switch (linesDataCategory) {
case LinesDataEnum.roads:
return new RoadDto();
Expand All @@ -34,6 +34,7 @@ export class LinesDataService {
public async uploadJson(
linesDataCategory: LinesDataEnum,
countryCodeISO3: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
validatedObjArray: any,
deleteExisting = true,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ContentEventEmail {
public indicatorMetadata: IndicatorMetadataEntity;
public linkEapSop: string;
public dataPerEvent: NotificationDataPerEventDto[];
public mapImageData: any[];
public mapImageData: unknown[];
public defaultAdminLevel: number;
public defaultAdminAreaLabel: AdminAreaLabel;
public country: CountryEntity; // Ensure that is has the following relations 'disasterTypes', 'notificationInfo','countryDisasterSettings','countryDisasterSettings.activeLeadTimes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import { twilio } from './twilio.client';
export class AuthMiddlewareTwilio implements NestMiddleware {
public constructor() {}

public async use(
req: Request,
res: Response,
next: NextFunction,
): Promise<any> {
public async use(req: Request, res: Response, next: NextFunction) {
const twilioSignature = req.headers['x-twilio-signature'];

if (DEBUG) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class WhatsappService {
message: string,
recipientPhoneNr: string,
mediaUrl?: string,
): Promise<any> {
) {
const payload = {
body: message,
messagingServiceSid: process.env.TWILIO_MESSAGING_SID,
Expand Down Expand Up @@ -256,8 +256,7 @@ export class WhatsappService {
events,
disasterType.disasterType,
);
await this.sendWhatsapp(noTriggerMessage, fromNumber);
return;
return await this.sendWhatsapp(noTriggerMessage, fromNumber);
}

for (const event of sortedEvents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Roles } from '../../roles.decorator';
import { RolesGuard } from '../../roles.guard';
import { GeoJson } from '../../shared/geo.model';
import { UserRole } from '../user/user-role.enum';
import { PointDataService } from './point-data.service';
import { CommunityNotification, PointDataService } from './point-data.service';
import {
UploadAssetExposureStatusDto,
UploadDynamicPointDataDto,
Expand Down Expand Up @@ -101,7 +101,7 @@ export class PointDataController {
@Post('community-notification/:countryCodeISO3')
public async uploadCommunityNotification(
@Param() params,
@Body() communityNotification: any,
@Body() communityNotification: CommunityNotification,
): Promise<void> {
return await this.pointDataService.uploadCommunityNotification(
params.countryCodeISO3,
Expand Down
21 changes: 16 additions & 5 deletions services/API-service/src/api/point-data/point-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ import { GaugeDto } from './dto/upload-gauge.dto';
import { DynamicPointDataEntity } from './dynamic-point-data.entity';
import { GlofasStationDto } from './dto/upload-glofas-station.dto';

export interface CommunityNotification {
nameVolunteer: string;
nameVillage: string;
disasterType: string;
description: string;
end: Date;
_attachments: [{ download_url: string }];
_geolocation: [number, number];
}

@Injectable()
export class PointDataService {
@InjectRepository(PointDataEntity)
Expand Down Expand Up @@ -89,7 +99,7 @@ export class PointDataService {
return this.helperService.toGeojson(pointData);
}

private getDtoPerPointDataCategory(pointDataCategory: PointDataEnum): any {
private getDtoPerPointDataCategory(pointDataCategory: PointDataEnum) {
switch (pointDataCategory) {
case PointDataEnum.dams:
return new DamSiteDto();
Expand Down Expand Up @@ -120,6 +130,7 @@ export class PointDataService {
public async uploadJson(
pointDataCategory: PointDataEnum,
countryCodeISO3: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
validatedObjArray: any,
deleteExisting = true,
) {
Expand Down Expand Up @@ -170,7 +181,7 @@ export class PointDataService {
csvArray,
): Promise<object[]> {
const errors = [];
const validatatedArray = [];
const validatedArray = [];
for (const [i, row] of csvArray.entries()) {
const dto = this.getDtoPerPointDataCategory(pointDataCategory);
for (const attribute in dto) {
Expand All @@ -185,12 +196,12 @@ export class PointDataService {
const errorObj = { lineNumber: i + 1, validationError: result };
errors.push(errorObj);
}
validatatedArray.push(dto);
validatedArray.push(dto);
}
if (errors.length > 0) {
throw new HttpException(errors, HttpStatus.BAD_REQUEST);
}
return validatatedArray;
return validatedArray;
}

public async dismissCommunityNotification(pointDataId: string) {
Expand All @@ -209,7 +220,7 @@ export class PointDataService {

public async uploadCommunityNotification(
countryCodeISO3: string,
communityNotification: any,
communityNotification: CommunityNotification,
): Promise<void> {
const notification = new CommunityNotificationDto();
notification.nameVolunteer = communityNotification['nameVolunteer'];
Expand Down
2 changes: 1 addition & 1 deletion services/API-service/src/api/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class UserController {
public async update(
@UserDecorator('userId') loggedInUserId: string,
@Body() userData: UpdatePasswordDto,
): Promise<any> {
) {
return this.userService.update(loggedInUserId, userData);
}
}
2 changes: 1 addition & 1 deletion services/API-service/src/roles.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SetMetadata } from '@nestjs/common';
import { UserRole } from './api/user/user-role.enum';

export const Roles = (...roles: UserRole[]): any => SetMetadata('roles', roles);
export const Roles = (...roles: UserRole[]) => SetMetadata('roles', roles);
Loading

0 comments on commit ab556a7

Please sign in to comment.