Skip to content

Commit

Permalink
fix: getPackageJson
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin committed Oct 18, 2023
1 parent 91c361f commit 4b0492e
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 83 deletions.
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = rubiin({
"ts/no-unsafe-assignment": "off", // optimize this
"ts/no-unsafe-member-access": "off", // optimize this
"unicorn/prefer-top-level-await": "off",
"sonarjs/no-duplicate-string": ["error", { "threshold": 10 }],
"ts/no-misused-promises": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"firebase-admin": "^11.11.0",
"handlebars": "^4.7.8",
"helmet": "^7.0.0",
"helper-fns": "^2.6.33",
"helper-fns": "^2.6.35",
"ioredis": "^5.3.2",
"isomorphic-dompurify": "^1.9.0",
"joi": "^17.11.0",
Expand Down
27 changes: 13 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/common/constant/string.constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { capitalize, getPackageJson } from "helper-fns";


export const REQUEST_ID_TOKEN_HEADER = "x-request-id";
export const VERSION_VALIDATION_MESSAGE = "Version must start with \"v\" followed by a number.";

Expand All @@ -12,9 +13,9 @@ export const API_UNAUTHORISED_RESPONSE = "No auth token in request.";
// swagger constants
const packageJson = getPackageJson();

export const APP_NAME = packageJson.name;
export const APP_NAME: string = packageJson.name;
export const SWAGGER_API_CURRENT_VERSION = packageJson.version;
export const SWAGGER_DESCRIPTION = packageJson.description!;
export const SWAGGER_DESCRIPTION = packageJson.description;
export const SWAGGER_TITLE = `${capitalize(APP_NAME)} API Documentation`;

export const SWAGGER_API_ENDPOINT = "doc";
Expand Down
2 changes: 0 additions & 2 deletions src/common/database/mikro-orm-cli.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ dotEnvExpand.expand(environment);

logger.log(`🛠️ Using env ${process.cwd()}/env/.env.${process.env.NODE_ENV}\n`);



const config: Options = defineConfig({
...baseOptions,
dbName: process.env.DB_DATABASE,
Expand Down
3 changes: 1 addition & 2 deletions src/common/database/orm.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { LoadStrategy } from "@mikro-orm/core";
import { TsMorphMetadataProvider } from "@mikro-orm/reflection";
import { SqlHighlighter } from "@mikro-orm/sql-highlighter";
import { NotFoundException, Logger } from "@nestjs/common";
import { Logger, NotFoundException } from "@nestjs/common";
import { BaseRepository } from "./base.repository";


const logger = new Logger("MikroORM");

export const baseOptions = {
Expand Down
6 changes: 2 additions & 4 deletions src/common/helpers/helpers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Observable } from "rxjs";
import { from } from "rxjs";
import sharp from "sharp";
import { REDIS_URI_REGEX } from "@common/constant";
import { RedisOptions } from "ioredis";
import type { RedisOptions } from "ioredis";

const argon2Options: ArgonOptions & { raw?: false } = {
type: argon2id,
Expand Down Expand Up @@ -93,9 +93,8 @@ which is the hashed password to compare against. */
return new Date(format(currentUtcTime, "yyyy-MM-dd HH:mm:ss"));
},
redisUrlToOptions(url: string): RedisOptions {
if(!REDIS_URI_REGEX.test(url)){
if (!REDIS_URI_REGEX.test(url))
throw new Error("Invalid redis url");
}

const separator = "://";

Expand All @@ -118,6 +117,5 @@ which is the hashed password to compare against. */
host,
port: Number.parseInt(port!, 10),
};

},
};
12 changes: 5 additions & 7 deletions src/common/misc/workers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HelperService } from "@common/helpers"
import { ThreadWorker } from 'poolifier'
import { HelperService } from "@common/helpers";
import { ThreadWorker } from "poolifier";

export interface WorkerData<T = string> {
input: T
Expand All @@ -11,21 +11,19 @@ export interface WorkerResponse<T = string> {

class FunctionHandlerWorker<
Data extends WorkerData,
Response extends WorkerResponse
Response extends WorkerResponse,
> extends ThreadWorker<Data, Response> {

public constructor() {
super({
hashString: async (workerData?: Data) => {
const hashedString = await HelperService.hashString(JSON.stringify(workerData));
return { response: hashedString } as Response;
}
},
});
}

}

export const requestHandlerWorker = new FunctionHandlerWorker<
WorkerData,
WorkerResponse
>()
>();
93 changes: 47 additions & 46 deletions src/generated/i18n-generated.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
/* DO NOT EDIT, file generated by nestjs-i18n */

import { Path } from "nestjs-i18n";
export type I18nTranslations = {
"exception": {
"itemExists": string;
"itemDoesNotExist": string;
"unauthorized": string;
"internalError": string;
"otpRequired": string;
"usernameRequired": string;
"followerFollowingSame": string;
"invalidOTP": string;
"inactiveUser": string;
"invalidCredentials": string;
"invalidTwoFaCode": string;
"forbidden": string;
"userInactive": string;
"notFound": string;
"itemExpired": string;
"emailLooksGood": string;
"unsupportedFileType": string;
"incorrectOldPassword": string;
"badRequest": string;
"invalidRefreshToken": string;
"deleteDefaultError": string;
"tooManyTries": string;
"refreshToken": string;
"token": string;
"tooManyRequests": string;
"invalidCursor": string;
"cursorInvalidDate": string;
"cursorInvalidNumber": string;
"apiUnauthorizedResponse": string;
"tooManyRequest": string;
};
"validation": {
"isNotEmpty": string;
"maxLength": string;
"minLength": string;
"max": string;
"min": string;
"isPassword": string;
"isIn": string;
"isEnum": string;
"isDataType": string;
};
};
import type { Path } from "nestjs-i18n";

export interface I18nTranslations {
"exception": {
"itemExists": string
"itemDoesNotExist": string
"unauthorized": string
"internalError": string
"otpRequired": string
"usernameRequired": string
"followerFollowingSame": string
"invalidOTP": string
"inactiveUser": string
"invalidCredentials": string
"invalidTwoFaCode": string
"forbidden": string
"userInactive": string
"notFound": string
"itemExpired": string
"emailLooksGood": string
"unsupportedFileType": string
"incorrectOldPassword": string
"badRequest": string
"invalidRefreshToken": string
"deleteDefaultError": string
"tooManyTries": string
"refreshToken": string
"token": string
"tooManyRequests": string
"invalidCursor": string
"cursorInvalidDate": string
"cursorInvalidNumber": string
"apiUnauthorizedResponse": string
"tooManyRequest": string
}
"validation": {
"isNotEmpty": string
"maxLength": string
"minLength": string
"max": string
"min": string
"isPassword": string
"isIn": string
"isEnum": string
"isDataType": string
}
}
export type I18nPath = Path<I18nTranslations>;
2 changes: 1 addition & 1 deletion src/lib/i18n/i18n.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ import { AcceptLanguageResolver, HeaderResolver, I18nModule, QueryResolver } fro
],
exports: [I18nModule],
})
export class NestI18nModule { }
export class NestI18nModule {}
2 changes: 1 addition & 1 deletion src/modules/category/category.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class CategoryService extends BaseService<Category, OffsetPaginationDto>
protected readonly searchField = "name"; // the field to search for when searching for tags
constructor(
// @ts-expect-error: Unused import error
// eslint-disable-next-line ts/no-unsafe-call

@InjectRepository(Category) private categoryRepository: BaseRepository<Category>,
) {
super(categoryRepository);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { IsUniqueConstraint } from "@common/decorators/validation";
import { CustomThrottlerGuard } from "@common/guards";
import { ClearCacheInterceptor, HttpCacheInterceptor } from "@common/interceptors";
import {
NestCacheModule,
NestCaslModule,
NestCloudinaryModule,
NestConfigModule,
Expand All @@ -15,7 +16,6 @@ import {
NestServeStaticModule,
NestThrottlerModule,
OrmModule,
NestCacheModule
} from "@lib/index";
import { AuthModule } from "@modules/auth/auth.module";
import { CategoryModule } from "@modules/category/category.module";
Expand Down Expand Up @@ -78,4 +78,4 @@ import { SentryInterceptor } from "@travelerdev/nestjs-sentry";
},
],
})
export class SharedModule { }
export class SharedModule {}

0 comments on commit 4b0492e

Please sign in to comment.