Skip to content

Commit

Permalink
refactor: base feature rename to feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadeera3784 committed Jun 15, 2024
1 parent 498bf17 commit e038fd0
Show file tree
Hide file tree
Showing 40 changed files with 89 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { AnalyticService } from '../services';

@Injectable()
export class DeleteAnalyticFeature extends BaseFeature {
export class DeleteAnalyticFeature extends Feature {
constructor(private readonly analyticService: AnalyticService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { AnalyticService } from '../services';

@Injectable()
export class GetAnalyticByIdFeature extends BaseFeature {
export class GetAnalyticByIdFeature extends Feature {
constructor(private readonly analyticService: AnalyticService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { AnalyticService } from '../services/analytic.service';
import { UpdateCountDto } from '../dtos';

@Injectable()
export class UpdateAnalyticCountFeature extends BaseFeature {
export class UpdateAnalyticCountFeature extends Feature {
constructor(private readonly analyticService: AnalyticService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { HttpStatus, Injectable } from '@nestjs/common';
import { HttpStatus, Injectable, Logger } from '@nestjs/common';

@Injectable()
export class BaseFeature {
export class Feature {
protected loggable: boolean = false;

protected async responseSuccess(
status: number = HttpStatus.OK,
message = 'Operation successful',
Expand All @@ -22,6 +24,7 @@ export class BaseFeature {
message = 'Something went wrong, Please try again later',
data: any = null,
) {
this.setLogger(data);
return {
status: status,
response: {
Expand All @@ -31,4 +34,10 @@ export class BaseFeature {
},
};
}

protected setLogger(error: any): void {
if (this.loggable) {
Logger.debug(error);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from './base-feature';
import { Feature } from './feature';
import { AppService } from '../services/app.service';
import { LocationService } from '../../location/services/location.service';
import { CategoryService } from '../../category/services/category.service';
import { CacheService } from '../services';

@Injectable()
export class GetSharedFiltersFeature extends BaseFeature {
export class GetSharedFiltersFeature extends Feature {
constructor(
private readonly appService: AppService,
private readonly locationService: LocationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { EventDispatcher } from '../../core/event-dispatcher';

import { PasswordResetTokenService } from '../services';
import { UserService } from '../../user/services/user.service';
import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { ForgotPasswordDto } from '../dtos';
import { ResetPasswordEvent } from '../events/reset-password.event';
import { RESET_PASSWORD } from '../constants';
import { User } from '../../user/schemas/user.schema';

@Injectable()
export class ForgotPasswordFeature extends BaseFeature {
export class ForgotPasswordFeature extends Feature {
constructor(
private readonly passwordResetTokenService: PasswordResetTokenService,
private readonly userService: UserService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { UserService } from '../../user/services/user.service';
import { TwoFactorAuthenticationTokenService } from '../services';

@Injectable()
export class GenerateTwoFactorSecretFeature extends BaseFeature {
export class GenerateTwoFactorSecretFeature extends Feature {
constructor(
private readonly userService: UserService,
private readonly twoFactorAuthenticationTokenService: TwoFactorAuthenticationTokenService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { TwoFactorAuthenticationTokenService } from '../services';

@Injectable()
export class GenerateTwoFactorTokenFeature extends BaseFeature {
export class GenerateTwoFactorTokenFeature extends Feature {
constructor(
private readonly twoFactorAuthenticationTokenService: TwoFactorAuthenticationTokenService,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, BadRequestException, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { UserService } from '../../user/services/user.service';

@Injectable()
export class MeFeature extends BaseFeature {
export class MeFeature extends Feature {
constructor(private readonly userService: UserService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { PasswordResetTokenService } from '../services';
import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { UserService } from '../../user/services/user.service';
import { ResetPasswordDto } from '../dtos';

@Injectable()
export class ResetPasswordFeature extends BaseFeature {
export class ResetPasswordFeature extends Feature {
constructor(
private readonly userService: UserService,
private readonly passwordResetTokenService: PasswordResetTokenService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Injectable, HttpStatus } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { AuthenticateTwoFactorTokenDto } from '../dtos';
import { TwoFactorAuthenticationTokenService } from '../services';
import { UserService } from '../../user/services/user.service';

@Injectable()
export class SignInTwoFactorTokenFeature extends BaseFeature {
export class SignInTwoFactorTokenFeature extends Feature {
constructor(
private readonly userService: UserService,
private readonly jwtService: JwtService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EventDispatcher } from '../../core/event-dispatcher';

import { SignInDto } from '../dtos';
import { UserRegisterdEvent } from '../events/user-registerd.event';
import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { UserService } from '../../user/services/user.service';
import { UtilityService } from '../../app/services';
import {
Expand All @@ -22,7 +22,7 @@ import { UserLoginEvent } from '../events/user-login-event';
import { USER_LOGIN_EVENT } from '../constants';

@Injectable()
export class SignInFeature extends BaseFeature {
export class SignInFeature extends Feature {
constructor(
private readonly userService: UserService,
private readonly jwtService: JwtService,
Expand Down Expand Up @@ -93,7 +93,6 @@ export class SignInFeature extends BaseFeature {

return this.responseError(HttpStatus.UNAUTHORIZED, 'Invalid credentials');
} catch (error) {
console.log('error', error);
return this.responseError(
HttpStatus.BAD_REQUEST,
'Something went wrong, Please try again later',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { EventDispatcher } from '../../core/event-dispatcher';
import { SignupDto } from '../dtos';
import { UserRegisterdEvent } from '../events/user-registerd.event';
import { VerificationTokenService } from '../services';
import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { UserService } from '../../user/services/user.service';
import { USER_REGISTERED } from '../../user/constants';
import { User } from '../../user/schemas/user.schema';

@Injectable()
export class SignUpFeature extends BaseFeature {
export class SignUpFeature extends Feature {
constructor(
private readonly tokenService: VerificationTokenService,
private readonly userService: UserService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { VerificationTokenService } from '../services';
import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { UserService } from '../../user/services/user.service';

@Injectable()
export class VerifyEmailFeature extends BaseFeature {
export class VerifyEmailFeature extends Feature {
constructor(
private readonly userService: UserService,
private readonly verificationTokenService: VerificationTokenService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { CategoryService } from '../services/category.service';
import { CreateCategoryDto } from '../dtos/create-category.dto';

@Injectable()
export class CreateCategoryFeature extends BaseFeature {
export class CreateCategoryFeature extends Feature {
constructor(private readonly categoryService: CategoryService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { CategoryService } from '../services/category.service';

@Injectable()
export class DatatableFeature extends BaseFeature {
export class DatatableFeature extends Feature {
constructor(private readonly categoryService: CategoryService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { CategoryService } from '../services/category.service';

@Injectable()
export class DeleteCategoryFeature extends BaseFeature {
export class DeleteCategoryFeature extends Feature {
constructor(private readonly categoryService: CategoryService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { CategoryService } from '../services/category.service';

@Injectable()
export class GetAllCategoriesFeature extends BaseFeature {
export class GetAllCategoriesFeature extends Feature {
constructor(private readonly categoryService: CategoryService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { CategoryService } from '../services/category.service';

@Injectable()
export class GetCategoryByIdFeature extends BaseFeature {
export class GetCategoryByIdFeature extends Feature {
constructor(private readonly categoryService: CategoryService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { CategoryService } from '../services/category.service';
import { UpdateCategoryDto } from '../dtos/update-category.dto';

@Injectable()
export class UpdateCategorynFeature extends BaseFeature {
export class UpdateCategorynFeature extends Feature {
constructor(private readonly categoryService: CategoryService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { ApplicationService } from '../services';
import { CreateApplicationDto } from '../dtos';

@Injectable()
export class ApplyJobApplicationFeature extends BaseFeature {
export class ApplyJobApplicationFeature extends Feature {
constructor(private readonly applicationService: ApplicationService) {
super();
}
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/modules/job/features/create-job.feature.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { JobService } from '../services';
import { CreateJobDto } from '../dtos';

@Injectable()
export class CreateJobFeature extends BaseFeature {
export class CreateJobFeature extends Feature {
constructor(private readonly jobService: JobService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { JobService } from '../services';

@Injectable()
export class DeleteExpiredJobsFeature extends BaseFeature {
export class DeleteExpiredJobsFeature extends Feature {
constructor(private readonly jobService: JobService) {
super();
}
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/modules/job/features/get-all-jobs.feature.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { JobService } from '../services';
import {
JobFilterInterface,
Expand All @@ -9,7 +9,7 @@ import {
} from '../interfaces';

@Injectable()
export class GetAllJobsFeature extends BaseFeature {
export class GetAllJobsFeature extends Feature {
constructor(private readonly jobService: JobService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { JobService } from '../services/job.service';

@Injectable()
export class GetJobByIdFeature extends BaseFeature {
export class GetJobByIdFeature extends Feature {
constructor(private readonly jobService: JobService) {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Injectable, HttpStatus } from '@nestjs/common';

import { BaseFeature } from '../../app/features/base-feature';
import { Feature } from '../../app/features/feature';
import { JobService } from '../services/job.service';

@Injectable()
export class TrackAnalyticFeature extends BaseFeature {
export class TrackAnalyticFeature extends Feature {
constructor(private readonly jobService: JobService) {
super();
}
Expand Down
Loading

0 comments on commit e038fd0

Please sign in to comment.