Skip to content

Commit 984dca5

Browse files
author
Kerem Sirin
committed
Merge remote-tracking branch 'origin/main' into feature/bundle-analyzer
2 parents 24be8e3 + 3959e24 commit 984dca5

File tree

14 files changed

+583
-314
lines changed

14 files changed

+583
-314
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.17.1
1+
22.18.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Commencis Starter – Next.js provides a streamlined foundation for building mod
1616

1717
#### Node.js
1818

19-
Before you begin, ensure you have `node: >= 22.16` installed on your system.
19+
Before you begin, ensure you have `node: >= 22.18` installed on your system.
2020

2121
#### pnpm
2222

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"author": "Commencis WEB Team",
77
"license": "Apache-2.0",
88
"engines": {
9-
"node": ">=22.16"
9+
"node": ">=22.18"
1010
},
11-
"packageManager": "pnpm@10.13.1",
11+
"packageManager": "pnpm@10.14.0",
1212
"scripts": {
1313
"preinstall": "npx only-allow pnpm",
1414
"dev": "next dev",
@@ -31,31 +31,32 @@
3131
},
3232
"dependencies": {
3333
"@next/bundle-analyzer": "15.4.6",
34+
"axios": "1.11.0",
3435
"clsx": "2.1.1",
35-
"next": "15.4.5",
36+
"next": "15.4.6",
3637
"next-intl": "4.3.4",
3738
"react": "19.1.1",
3839
"react-dom": "19.1.1"
3940
},
4041
"devDependencies": {
4142
"@commencis/commitlint-config": "1.1.4",
42-
"@commencis/eslint-config": "1.7.3",
43+
"@commencis/eslint-config": "1.7.4",
4344
"@commencis/lint-staged-config": "1.0.0",
4445
"@commencis/prettier-config": "2.0.0",
4546
"@commencis/stylelint-config": "2.1.1",
4647
"@commencis/ts-config": "0.0.2",
4748
"@commitlint/cli": "19.8.1",
4849
"@svgr/webpack": "8.1.0",
49-
"@types/node": "22.17.0",
50+
"@types/node": "22.17.1",
5051
"@types/react": "19.1.9",
5152
"@types/react-dom": "19.1.7",
52-
"eslint": "9.32.0",
53+
"eslint": "9.33.0",
5354
"husky": "9.1.7",
54-
"lint-staged": "16.1.2",
55+
"lint-staged": "16.1.5",
5556
"prettier": "3.6.2",
56-
"sass": "1.89.2",
57-
"stylelint": "16.23.0",
58-
"typescript": "5.8.3"
57+
"sass": "1.90.0",
58+
"stylelint": "16.23.1",
59+
"typescript": "5.9.2"
5960
},
6061
"pnpm": {
6162
"onlyBuiltDependencies": [

pnpm-lock.yaml

Lines changed: 379 additions & 302 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/models/AuthLoginRequest.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type AuthLoginRequest = {
2+
username: string;
3+
password: string;
4+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type AuthLoginResponse = {
2+
userId: string;
3+
accessToken: string;
4+
};

src/api/services/Auth.service.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { makeRequest } from '@/lib';
2+
3+
import { AuthLoginRequest } from '@/api/models/AuthLoginRequest';
4+
import { AuthLoginResponse } from '@/api/models/AuthLoginResponse';
5+
6+
const ACCESS_TOKEN_KEY = 'accessToken';
7+
8+
class AuthService {
9+
private accessTokenKey = ACCESS_TOKEN_KEY;
10+
11+
public async login(request: AuthLoginRequest): Promise<AuthLoginResponse> {
12+
try {
13+
const response = await makeRequest<AuthLoginResponse, AuthLoginRequest>({
14+
method: 'POST',
15+
path: '/auth/login',
16+
data: request,
17+
withAuthorization: false,
18+
});
19+
20+
this.setAccessToken(response.accessToken);
21+
return response;
22+
} catch (error) {
23+
if (error instanceof Error && error.message) {
24+
throw new Error(`Login Failed: ${error.message}`);
25+
} else {
26+
throw new Error('Login Failed: Unknown error occurred');
27+
}
28+
}
29+
}
30+
31+
public async logout(userId: string): Promise<AuthLoginResponse> {
32+
try {
33+
const response = await makeRequest<AuthLoginResponse, { userId: string }>(
34+
{
35+
method: 'POST',
36+
path: '/auth/logout',
37+
data: { userId },
38+
}
39+
);
40+
41+
this.clearAccessToken();
42+
return response;
43+
} catch (error) {
44+
if (error instanceof Error && error.message) {
45+
throw new Error(`Logout Failed: ${error.message}`);
46+
} else {
47+
throw new Error('Logout Failed: Unknown error occurred');
48+
}
49+
}
50+
}
51+
52+
private setAccessToken(token: string): void {
53+
localStorage.setItem(this.accessTokenKey, token);
54+
}
55+
56+
private clearAccessToken(): void {
57+
localStorage.removeItem(this.accessTokenKey);
58+
}
59+
}
60+
61+
export const authService = new AuthService();

src/api/services/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '@/api/services/Auth.service';

src/constants/http.constants.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { HttpHeader } from '@/types';
2+
3+
export const HEADER_KEY = {
4+
ACCEPT: 'Accept',
5+
CONTENT_TYPE: 'Content-Type',
6+
AUTHORIZATION: 'Authorization',
7+
} as const;
8+
9+
export const HEADERS = {
10+
CONTENT_TYPE_JSON: { [HEADER_KEY.CONTENT_TYPE]: 'application/json' },
11+
ACCEPT_JSON: { [HEADER_KEY.ACCEPT]: 'application/json' },
12+
} as const satisfies Record<string, HttpHeader>;

src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from '@/constants/env.constants';
22
export * from '@/constants/font.constants';
3+
export * from '@/constants/http.constants';
34
export * from '@/constants/localization.constants';

0 commit comments

Comments
 (0)