Skip to content

Commit 42f6009

Browse files
authored
Merge pull request #4 from wefloc/feat/general-error
feat(global): general error added
2 parents ff1c589 + e100265 commit 42f6009

File tree

14 files changed

+146
-52
lines changed

14 files changed

+146
-52
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"access": "public"
1010
},
1111
"devDependencies": {
12-
"@types/jest": "27.0.1",
13-
"@types/node": "16.9.4",
14-
"@typescript-eslint/eslint-plugin": "4.31.1",
15-
"@typescript-eslint/parser": "4.31.1",
12+
"@types/jest": "27.0.2",
13+
"@types/node": "16.10.0",
14+
"@typescript-eslint/eslint-plugin": "4.31.2",
15+
"@typescript-eslint/parser": "4.31.2",
1616
"eslint": "7.32.0",
1717
"eslint-config-prettier": "8.3.0",
1818
"eslint-plugin-prettier": "4.0.0",

src/codes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import { IErrors } from './types';
22

33
// Resources
44
import authentication from './resources/authentication';
5+
import signIn from './resources/signIn';
6+
import general from './resources/general';
57

68
const codes: IErrors = {
79
authentication,
10+
signIn,
11+
general,
812
};
913

1014
export { codes };

src/resources/authentication/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const authentication: IErrorRes = {
2222
status: EHttpCode.UNAUTHORIZED,
2323
},
2424
},
25+
internal: {},
26+
external: {},
2527
i18n,
2628
};
2729

src/resources/authentication/locales/en_US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
"unauthorizedRoute": "Access denied",
66
"unauthorizedResource": "Access denied",
77
"tokenExpired": "Token expired"
8-
}
8+
},
9+
"internal": {},
10+
"external": {}
911
}

src/resources/authentication/locales/fr_FR.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
"unauthorizedRoute": "Accès refusé",
66
"unauthorizedResource": "Accès refusé",
77
"tokenExpired": "Token expiré"
8-
}
8+
},
9+
"internal": {},
10+
"external": {}
911
}

src/resources/general/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { II18n, IErrorRes, EHttpCode } from '../../types';
2+
3+
// Locals
4+
import * as fr_FR from './locales/fr_FR.json';
5+
import * as en_US from './locales/en_US.json';
6+
7+
const i18n: II18n = { fr_FR, en_US };
8+
9+
const general: IErrorRes = {
10+
client: {},
11+
internal: {
12+
unexpected: {
13+
status: EHttpCode.INTERNAL_SERVER_ERROR,
14+
},
15+
},
16+
external: {},
17+
i18n,
18+
};
19+
20+
export default general;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"client": { },
3+
"internal": {
4+
"unexpected": "An unexpected error occurred"
5+
},
6+
"external": {}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"client": {},
3+
"internal": {
4+
"unexpected": "Une erreur inattendue est survenue"
5+
},
6+
"external": {}
7+
}

src/resources/signIn/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { II18n, IErrorRes, EHttpCode } from '../../types';
2+
import * as fr_FR from './locales/fr_FR.json';
3+
import * as en_US from './locales/en_US.json';
4+
5+
const i18n: II18n = { fr_FR, en_US };
6+
7+
const authentication: IErrorRes = {
8+
client: {
9+
formInvalidEmail: {
10+
status: EHttpCode.BAD_REQUEST,
11+
},
12+
formInvalidPassword: {
13+
status: EHttpCode.BAD_REQUEST,
14+
},
15+
},
16+
internal: {},
17+
external: {},
18+
i18n,
19+
};
20+
21+
export default authentication;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"client": {
3+
"formInvalidEmail": "Invalid email",
4+
"formInvalidPassword": "Invalid password"
5+
},
6+
"internal": {},
7+
"external": {}
8+
}

0 commit comments

Comments
 (0)