Skip to content

Commit f214547

Browse files
authored
Merge pull request #2 from hodfords-solutions/feat/upgrade-nestjs-10
feat: upgrade nestjs 10
2 parents 3ea1323 + ac6584c commit f214547

File tree

10 files changed

+6799
-2776
lines changed

10 files changed

+6799
-2776
lines changed

.husky/pre-commit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npx --no-install lint-staged
4+
changedFiles="$(git diff --name-only --cached)"
5+
npm run cspell --no-must-find-files ${changedFiles}
6+
npm run lint-staged

.lintstagedrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"libs/**/*.ts": ["prettier --write"]
2+
"libs/**/*.ts": ["eslint --fix --max-warnings 0"]
33
}

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"useTabs": false,
77
"trailingComma": "none",
88
"bracketSpacing": true,
9-
"jsxBracketSameLine": false,
9+
"bracketSameLine": false,
1010
"semi": true,
1111
"endOfLine": "auto"
1212
}

cspell.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"words": ["nestjs", "middlewares", "hodfords", "postbuild"],
5+
"flagWords": ["hte"],
6+
"ignorePaths": ["node_modules", "test", "*.spec.ts", "cspell.json"]
7+
}

libs/helpers/translation.helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { TranslationService } from '../services/translation.service';
1+
import cls from '@hodfords/cls-hooked';
22
import {
33
CLS_TRANSLATION_NAMESPACE,
44
CLS_TRANSLATION_NAMESPACE_NAME
55
} from '../constants/cls-translation-namespace.constant';
66
import { IS_FULL_LANGUAGE } from '../constants/language-key.constant';
7+
import { TranslationService } from '../services/translation.service';
78
import { RunInLanguageParams, TranslateOptions } from '../types';
8-
import cls from '@hodfords/cls-hooked';
99

1010
export function trans(key: string, options: TranslateOptions = {}) {
1111
return TranslationService.instance.translate(key, options);

libs/middlewares/translation.middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Injectable, NestMiddleware } from '@nestjs/common';
22
import { NextFunction, Request, Response } from 'express';
3-
import { TranslationService } from '../services/translation.service';
43
import { CLS_TRANSLATION_NAMESPACE } from '../constants/cls-translation-namespace.constant';
54
import { runInLanguage } from '../helpers/translation.helper';
5+
import { TranslationService } from '../services/translation.service';
66

77
@Injectable()
88
export class TranslationMiddleware implements NestMiddleware {

libs/services/translation.service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ExecutionContext, Injectable } from '@nestjs/common';
2-
import { I18N_OPTIONS, I18nOptions, I18nService } from 'nestjs-i18n';
32
import { ModuleRef } from '@nestjs/core';
3+
import { I18nOptions, I18nService, I18N_OPTIONS } from 'nestjs-i18n';
44
import { CLS_RESOLVERS, CLS_TRANSLATION_NAMESPACE, DEFAULT_LANGUAGE_KEY, PRIORITY_LANGUAGE_GETTER } from '../constants';
5-
import { LanguageKeyMap, TranslateOptions } from '../types';
65
import { ClsResolver } from '../interfaces';
6+
import { LanguageKeyMap, TranslateOptions } from '../types';
77

88
@Injectable()
99
export class TranslationService {
@@ -14,7 +14,10 @@ export class TranslationService {
1414
private defaultLanguageKey: string;
1515
private priorityLanguageGetter: () => string;
1616

17-
constructor(private i18nService: I18nService, private moduleRef: ModuleRef) {
17+
constructor(
18+
private i18nService: I18nService<Record<string, string>>,
19+
private moduleRef: ModuleRef
20+
) {
1821
TranslationService.instance = this;
1922
this.clsResolvers = this.moduleRef.get(CLS_RESOLVERS, { strict: false });
2023
this.i18nOptions = this.moduleRef.get(I18N_OPTIONS, { strict: false });
@@ -35,7 +38,7 @@ export class TranslationService {
3538
options.lang = this.getCurrentLanguage();
3639
}
3740

38-
return this.i18nService.translate<string>(key, options);
41+
return this.i18nService.translate(key, options);
3942
}
4043

4144
getDefaultLanguageKey() {

0 commit comments

Comments
 (0)