Skip to content

Commit

Permalink
fix: eslint strict null check
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin committed Aug 29, 2024
1 parent 1a60906 commit a52fe2e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ValidatorFieldBuilder {
}

addMinMaxLength() {
if (this.options.minLength && this.options.maxLength) {
if (this.options?.minLength != null && this.options?.maxLength != null) {
MinMaxLength({
minLength: this.options.minLength,
maxLength: this.options.maxLength,
Expand Down
2 changes: 1 addition & 1 deletion src/common/helpers/helpers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const HelperService = {
...pick(user, ["id", "idx"]),
},
accessToken,
...(refreshToken ? { refresh_token: refreshToken } : {}),
...(refreshToken != null ? { refresh_token: refreshToken } : {}),
};
},

Expand Down
5 changes: 4 additions & 1 deletion src/common/middlewares/cache.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export class ClearCacheMiddleware implements NestMiddleware {
constructor(private readonly cacheService: CacheService) {}

async use(request: NestifyRequest, _response: NestifyResponse, next: NestifyNextFunction) {
request.query?.clearCache === "true" && (await this.cacheService.resetCache());

if(request.query?.clearCache === "true")
await this.cacheService.resetCache()

next();
}
}
2 changes: 1 addition & 1 deletion src/common/middlewares/request-id.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { REQUEST_ID_TOKEN_HEADER } from "@common/constant";
export function RequestIdMiddleware(request: NestifyRequest, response: NestifyResponse, next: NestifyNextFunction) {
const requestId = request.header(REQUEST_ID_TOKEN_HEADER);

if (!request.headers[REQUEST_ID_TOKEN_HEADER] || (requestId && !isCuid(requestId)))
if (request.headers[REQUEST_ID_TOKEN_HEADER] == null || (requestId != null && !isCuid(requestId)))
request.headers[REQUEST_ID_TOKEN_HEADER] = createId();

response.set(REQUEST_ID_TOKEN_HEADER, request.headers[REQUEST_ID_TOKEN_HEADER]);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/crud/crud.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AbstractValidationPipe extends ValidationPipe {
async transform(value: any, metadata: ArgumentMetadata) {
const targetType = this.targetTypes[metadata.type] as Type<any>;

if (!targetType)
if (targetType == null)
return super.transform(value, metadata);

return super.transform(value, { ...metadata, metatype: targetType });
Expand Down
2 changes: 1 addition & 1 deletion src/lib/firebase-admin/firebase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class NestFirebaseService implements NestFirebase {
if (!existsSync(filePath))
throw new Error(`Unknown file ${filePath}`);

if (!this._firebaseConnection) {
if (this._firebaseConnection == null) {
try {
this._firebaseConnection = admin.initializeApp({
credential: admin.credential.cert(filePath),
Expand Down
10 changes: 5 additions & 5 deletions src/lib/minio.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { NestMinioModule } from "nestjs-minio";
inject: [ConfigService],
isGlobal: true,
useFactory: async (configService: ConfigService) => ({
endPoint: configService.get("minio.host") || "localhost",
port: configService.get("minio.port") || 9000,
accessKey: configService.get("minio.accessKey") || "minio",
secretKey: configService.get("minio.secretKey") || "minio",
useSSL: configService.get("minio.ssl"),
endPoint: configService.get("minio.host","localhost"),
port: configService.get("minio.port",9000),
accessKey: configService.get("minio.accessKey","minio") ,
secretKey: configService.get("minio.secretKey","minio") ,
useSSL: configService.get("minio.ssl",false),
}),
}),
],
Expand Down

0 comments on commit a52fe2e

Please sign in to comment.