Skip to content

Commit 5d4b2c4

Browse files
Victor A Higuitaharvic3
Victor A Higuita
authored andcommitted
[UPDATE]: package for locales and its implementation were improved
1 parent 958b88e commit 5d4b2c4

File tree

8 files changed

+62
-54
lines changed

8 files changed

+62
-54
lines changed

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,39 @@
4848
"@types/jest": "^29.5.12",
4949
"@types/jsonwebtoken": "^9.0.6",
5050
"@types/luxon": "^3.4.2",
51-
"@types/node": "^20.14.11",
51+
"@types/node": "^20.14.13",
5252
"@types/swagger-ui-express": "^4.1.6",
5353
"@types/uuid": "^10.0.0",
54-
"@typescript-eslint/eslint-plugin": "^7.16.1",
55-
"@typescript-eslint/parser": "^7.16.1",
54+
"@typescript-eslint/eslint-plugin": "^7.18.0",
55+
"@typescript-eslint/parser": "^7.18.0",
5656
"eslint": "^8.57.0",
5757
"eslint-config-prettier": "^9.1.0",
5858
"eslint-plugin-prettier": "^5.2.1",
59-
"husky": "^9.1.0",
59+
"husky": "^9.1.4",
6060
"jest": "^29.7.0",
6161
"jest-fetch-mock": "^3.0.3",
6262
"jest-mock-extended": "^3.0.7",
6363
"prettier": "^3.3.3",
6464
"pretty-quick": "^4.0.0",
65-
"ts-jest": "^29.2.2",
65+
"ts-jest": "^29.2.3",
6666
"ts-node-dev": "^2.0.0",
67-
"typescript": "^5.5.3"
67+
"typescript": "^5.5.4"
6868
},
6969
"dependencies": {
7070
"cors": "^2.8.5",
71-
"dic-tsk": "^1.0.6",
71+
"dic-tsk": "^1.0.8",
7272
"express": "^4.19.2",
7373
"express-async-errors": "^3.1.1",
7474
"fast-glob": "^3.3.2",
7575
"helmet": "^7.1.0",
7676
"jsonwebtoken": "^9.0.2",
7777
"luxon": "^3.4.4",
7878
"mapper-tsk": "^2.0.4",
79-
"resources-tsk": "^2.1.5",
80-
"result-tsk": "^2.1.8",
79+
"resources-tsk": "^2.5.1",
80+
"result-tsk": "^2.1.9",
8181
"swagger-ui-express": "^5.0.1",
8282
"uuid": "^10.0.0",
83-
"validator-tsk": "^2.0.7"
83+
"validator-tsk": "^2.0.8"
8484
},
8585
"husky": {
8686
"hooks": {

src/adapters/shared/kernel/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import applicationStatus from "../../../application/shared/status/applicationStatus";
2-
import appMessages, { localKeys } from "../../../application/shared/locals/messages";
2+
import appMessages from "../../../application/shared/locals/messages";
33
import tsKernel, { IServiceContainer } from "dic-tsk";
44

55
tsKernel.init({
66
internalErrorCode: applicationStatus.INTERNAL_ERROR,
77
appMessages,
8-
appErrorMessageKey: localKeys.DEPENDENCY_NOT_FOUND,
8+
appErrorMessageKey: appMessages.keys.DEPENDENCY_NOT_FOUND,
99
applicationStatus,
1010
applicationStatusCodeKey: "INTERNAL_ERROR",
1111
});
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import AppSettings from "../../settings/AppSettings";
22
import { LocaleTypeEnum } from "../LocaleType.enum";
3-
import { Resources } from "../../types";
3+
import { Resources, IResources } from "../../types";
4+
import { MessageKeysDictionaryEnum } from "./keys";
5+
import ptBrLocal from "./pt-br.local";
46
import esLocal from "./es.local";
57
import enLocal from "./en.local";
6-
import ptBrLocal from "./pt-br.local";
7-
import localKeys from "./keys";
88

9-
const locals = {
9+
type LocalesType = {
10+
[K in LocaleTypeEnum]: { [key in keyof typeof MessageKeysDictionaryEnum]: string };
11+
};
12+
13+
const locales: LocalesType = {
1014
[LocaleTypeEnum.ES]: esLocal,
1115
[LocaleTypeEnum.EN]: enLocal,
1216
[LocaleTypeEnum.ES_CO]: esLocal,
1317
[LocaleTypeEnum.EN_US]: enLocal,
1418
[LocaleTypeEnum.PT_BR]: ptBrLocal,
1519
};
1620

17-
export { Resources, localKeys };
18-
export default new Resources(locals, localKeys, AppSettings.DefaultLanguage);
21+
export { IResources as Resources };
22+
export default new Resources(locales, MessageKeysDictionaryEnum, AppSettings.DefaultLanguage);
+17-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
export default {
2-
AUTHORIZATION_REQUIRED: "AUTHORIZATION_REQUIRED",
3-
RESOURCE_NOT_FOUND: "RESOURCE_NOT_FOUND",
4-
PROCESSING_DATA_CLIENT_ERROR: "PROCESSING_DATA_CLIENT_ERROR",
5-
UNKNOWN_RESPONSE_STATUS: "UNKNOWN_RESPONSE_STATUS",
6-
TOOL_HAS_NOT_BEEN_INITIALIZED: "TOOL_HAS_NOT_BEEN_INITIALIZED",
7-
DEPENDENCY_NOT_FOUND: "DEPENDENCY_NOT_FOUND",
8-
SOME_PARAMETERS_ARE_MISSING: "SOME_PARAMETERS_ARE_MISSING",
9-
SOMETHING_WENT_WRONG: "SOMETHING_WENT_WRONG",
10-
INVALID_USER_OR_PASSWORD: "INVALID_USER_OR_PASSWORD",
11-
ERROR_CREATING_USER: "ERROR_CREATING_USER",
12-
USER_WAS_CREATED: "USER_WAS_CREATED",
13-
USER_WITH_EMAIL_ALREADY_EXISTS: "USER_WITH_EMAIL_ALREADY_EXISTS",
14-
INVALID_EMAIL: "INVALID_EMAIL",
15-
INVALID_PASSWORD: "INVALID_PASSWORD",
16-
INVALID_SESSION: "INVALID_SESSION",
17-
};
1+
export enum MessageKeysDictionaryEnum {
2+
AUTHORIZATION_REQUIRED = "AUTHORIZATION_REQUIRED",
3+
RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND",
4+
PROCESSING_DATA_CLIENT_ERROR = "PROCESSING_DATA_CLIENT_ERROR",
5+
UNKNOWN_RESPONSE_STATUS = "UNKNOWN_RESPONSE_STATUS",
6+
TOOL_HAS_NOT_BEEN_INITIALIZED = "TOOL_HAS_NOT_BEEN_INITIALIZED",
7+
DEPENDENCY_NOT_FOUND = "DEPENDENCY_NOT_FOUND",
8+
SOME_PARAMETERS_ARE_MISSING = "SOME_PARAMETERS_ARE_MISSING",
9+
SOMETHING_WENT_WRONG = "SOMETHING_WENT_WRONG",
10+
INVALID_USER_OR_PASSWORD = "INVALID_USER_OR_PASSWORD",
11+
ERROR_CREATING_USER = "ERROR_CREATING_USER",
12+
USER_WAS_CREATED = "USER_WAS_CREATED",
13+
USER_WITH_EMAIL_ALREADY_EXISTS = "USER_WITH_EMAIL_ALREADY_EXISTS",
14+
INVALID_EMAIL = "INVALID_EMAIL",
15+
INVALID_PASSWORD = "INVALID_PASSWORD",
16+
INVALID_SESSION = "INVALID_SESSION",
17+
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import AppSettings from "../../settings/AppSettings";
22
import { LocaleTypeEnum } from "../LocaleType.enum";
3+
import { WordKeysDictionaryEnum } from "./keys";
34
import { Resources } from "../../types";
5+
import ptBrLocal from "./pt-br.local";
46
import esLocal from "./es.local";
57
import enLocal from "./en.local";
6-
import ptBrLocal from "./pt-br.local";
7-
import localKeys from "./keys";
88

9-
const locals = {
9+
type LocalesType = {
10+
[K in LocaleTypeEnum]: { [key in keyof typeof WordKeysDictionaryEnum]: string };
11+
};
12+
13+
const locales: LocalesType = {
1014
[LocaleTypeEnum.ES]: esLocal,
1115
[LocaleTypeEnum.EN]: enLocal,
1216
[LocaleTypeEnum.ES_CO]: esLocal,
1317
[LocaleTypeEnum.EN_US]: enLocal,
1418
[LocaleTypeEnum.PT_BR]: ptBrLocal,
1519
};
1620

17-
export { Resources, localKeys };
18-
export default new Resources(locals, localKeys, AppSettings.DefaultLanguage);
21+
export default new Resources(locales, WordKeysDictionaryEnum, AppSettings.DefaultLanguage);
+11-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export default {
2-
EMAIL: "EMAIL",
3-
PASSWORD: "PASSWORD",
4-
FIRST_NAME: "FIRST_NAME",
5-
LAST_NAME: "LAST_NAME",
6-
GENDER: "GENDER",
7-
ENCRYPTION: "ENCRYPTION",
8-
SESSION: "SESSION",
9-
SESSION_ID: "SESSION_ID",
10-
SESSION_EXP: "SESSION_EXP",
11-
};
1+
export enum WordKeysDictionaryEnum {
2+
EMAIL = "EMAIL",
3+
PASSWORD = "PASSWORD",
4+
FIRST_NAME = "FIRST_NAME",
5+
LAST_NAME = "LAST_NAME",
6+
GENDER = "GENDER",
7+
ENCRYPTION = "ENCRYPTION",
8+
SESSION = "SESSION",
9+
SESSION_ID = "SESSION_ID",
10+
SESSION_EXP = "SESSION_EXP",
11+
}

src/application/shared/types/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ export {
77
ResultExecutionPromise,
88
} from "result-tsk";
99
export { Validator } from "validator-tsk";
10-
export { Resources } from "resources-tsk";
10+
export { Resources, IResources } from "resources-tsk";

src/infrastructure/config/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MessageKeysDictionaryEnum } from "../../application/shared/locals/messages/keys";
12
import { LocaleTypeEnum } from "../../application/shared/locals/LocaleType.enum";
23
import { ServiceContext } from "../../adapters/shared/ServiceContext";
34
import { DefaultValue } from "../../domain/shared/utils/DefaultValue";
@@ -43,7 +44,7 @@ export default {
4344
process.env.ORIGINS,
4445
"http://localhost:3000,http://localhost:3001,http://localhost:3002",
4546
),
46-
ServiceName: DefaultValue.evaluateAndGet(process.env.SERVICE_NAME, "NodeTskeleton"),
47+
ServiceName: DefaultValue.evaluateAndGet(process.env.SERVICE_NAME, "NodeTSkeleton"),
4748
ServiceContext: {
4849
LoadWithContext: !!process.env.SERVICE_CONTEXT,
4950
Context: serviceContext,
@@ -58,7 +59,7 @@ export default {
5859
},
5960
DefaultApplicationError: {
6061
Code: "500",
61-
MessageKey: "SOMETHING_WENT_WRONG",
62+
MessageKey: MessageKeysDictionaryEnum.SOMETHING_WENT_WRONG,
6263
},
6364
Security: {
6465
JWT: {

0 commit comments

Comments
 (0)