Skip to content

Commit 951b55a

Browse files
authored
Merge pull request #105 from BinaryStudioAcademy/task/thjs-60-fix-path-join-helper
thjs-60: Fix path join helper
2 parents 827d979 + e68b266 commit 951b55a

File tree

24 files changed

+92
-171
lines changed

24 files changed

+92
-171
lines changed

server/src/libs/packages/config/config.package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Config {
3030
}
3131
},
3232
JWT: {
33-
SECRET_KEY: {
33+
SECRET: {
3434
doc: 'Secret key for token generation',
3535
format: String,
3636
env: 'SECRET_KEY',

server/src/libs/packages/controller/controller.api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getJoinedNormalizedPath } from '#libs/packages/path/path.js';
1+
import { joinPath } from '#libs/packages/path/path.js';
22

33
class Controller {
44
#apiPath;
@@ -15,7 +15,7 @@ class Controller {
1515

1616
addRoute = ({ url, ...options }) => {
1717
this.#routes.push({
18-
url: getJoinedNormalizedPath([this.#apiPath, url]),
18+
url: joinPath([this.#apiPath, url]),
1919
...options
2020
});
2121
};

server/src/libs/packages/path/libs/helpers/get-joined-normalized-path/get-joined-normalized-path.helper.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
export { getJoinedNormalizedPath } from './get-joined-normalized-path/get-joined-normalized-path.helper.js';
21
export { joinPath } from './join-path/join-path.helper.js';
3-
export { normalizeTrailingSlash } from './normalize-trailing-slash/normalize-trailing-slash.helper.js';
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import path from 'node:path';
2-
3-
const joinPath = paths => path.join(...paths);
1+
const joinPath = paths => paths.join('');
42

53
export { joinPath };

server/src/libs/packages/path/libs/helpers/normalize-trailing-slash/normalize-trailing-slash.helper.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
export {
2-
getJoinedNormalizedPath,
3-
joinPath,
4-
normalizeTrailingSlash
5-
} from './libs/helpers/helpers.js';
1+
export { joinPath } from './libs/helpers/helpers.js';

server/tests/api/0-starter/auth.api.spec.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ApiPath } from '#libs/enums/enums.js';
55
import { config } from '#libs/packages/config/config.js';
66
import { DatabaseTableName } from '#libs/packages/database/database.js';
77
import { HttpCode, HttpHeader, HttpMethod } from '#libs/packages/http/http.js';
8-
import { getJoinedNormalizedPath } from '#libs/packages/path/path.js';
8+
import { joinPath } from '#libs/packages/path/path.js';
99
import { AuthApiPath } from '#packages/auth/auth.js';
1010
import {
1111
UserPayloadKey,
@@ -21,24 +21,21 @@ import {
2121
import { getBearerAuthHeader } from '../../libs/packages/http/http.js';
2222
import { TEST_USERS_CREDENTIALS } from '../../packages/user/user.js';
2323

24-
const authApiPath = getJoinedNormalizedPath([
25-
config.ENV.APP.API_PATH,
26-
ApiPath.AUTH
27-
]);
24+
const authApiPath = joinPath([config.ENV.APP.API_PATH, ApiPath.AUTH]);
2825

29-
const registerEndpoint = getJoinedNormalizedPath([
26+
const registerEndpoint = joinPath([
3027
config.ENV.APP.API_PATH,
3128
ApiPath.AUTH,
3229
AuthApiPath.REGISTER
3330
]);
3431

35-
const loginEndpoint = getJoinedNormalizedPath([
32+
const loginEndpoint = joinPath([
3633
config.ENV.APP.API_PATH,
3734
ApiPath.AUTH,
3835
AuthApiPath.LOGIN
3936
]);
4037

41-
const userEndpoint = getJoinedNormalizedPath([
38+
const userEndpoint = joinPath([
4239
config.ENV.APP.API_PATH,
4340
ApiPath.AUTH,
4441
AuthApiPath.USER

server/tests/api/0-starter/comment.api.spec.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ApiPath } from '#libs/enums/enums.js';
44
import { config } from '#libs/packages/config/config.js';
55
import { DatabaseTableName } from '#libs/packages/database/database.js';
66
import { HttpCode, HttpHeader, HttpMethod } from '#libs/packages/http/http.js';
7-
import { getJoinedNormalizedPath } from '#libs/packages/path/path.js';
7+
import { joinPath } from '#libs/packages/path/path.js';
88
import { AuthApiPath } from '#packages/auth/auth.js';
99
import {
1010
CommentPayloadKey,
@@ -24,24 +24,21 @@ import {
2424
TEST_USERS_CREDENTIALS
2525
} from '../../packages/user/user.js';
2626

27-
const loginEndpoint = getJoinedNormalizedPath([
27+
const loginEndpoint = joinPath([
2828
config.ENV.APP.API_PATH,
2929
ApiPath.AUTH,
3030
AuthApiPath.LOGIN
3131
]);
3232

33-
const commentApiPath = getJoinedNormalizedPath([
34-
config.ENV.APP.API_PATH,
35-
ApiPath.COMMENTS
36-
]);
33+
const commentApiPath = joinPath([config.ENV.APP.API_PATH, ApiPath.COMMENTS]);
3734

38-
const commentsEndpoint = getJoinedNormalizedPath([
35+
const commentsEndpoint = joinPath([
3936
config.ENV.APP.API_PATH,
4037
ApiPath.COMMENTS,
4138
CommentsApiPath.ROOT
4239
]);
4340

44-
const commentIdEndpoint = getJoinedNormalizedPath([
41+
const commentIdEndpoint = joinPath([
4542
config.ENV.APP.API_PATH,
4643
ApiPath.COMMENTS,
4744
CommentsApiPath.$ID

server/tests/api/0-starter/image.api.spec.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ApiPath } from '#libs/enums/enums.js';
99
import { config } from '#libs/packages/config/config.js';
1010
import { DatabaseTableName } from '#libs/packages/database/database.js';
1111
import { HttpCode, HttpHeader, HttpMethod } from '#libs/packages/http/http.js';
12-
import { getJoinedNormalizedPath } from '#libs/packages/path/path.js';
12+
import { joinPath } from '#libs/packages/path/path.js';
1313
import { AuthApiPath } from '#packages/auth/auth.js';
1414
import { ImagePayloadKey, ImagesApiPath } from '#packages/image/image.js';
1515
import { UserPayloadKey } from '#packages/user/user.js';
@@ -25,18 +25,15 @@ import {
2525
TEST_USERS_CREDENTIALS
2626
} from '../../packages/user/user.js';
2727

28-
const loginEndpoint = getJoinedNormalizedPath([
28+
const loginEndpoint = joinPath([
2929
config.ENV.APP.API_PATH,
3030
ApiPath.AUTH,
3131
AuthApiPath.LOGIN
3232
]);
3333

34-
const imageEndpoint = getJoinedNormalizedPath([
35-
config.ENV.APP.API_PATH,
36-
ApiPath.IMAGES
37-
]);
34+
const imageEndpoint = joinPath([config.ENV.APP.API_PATH, ApiPath.IMAGES]);
3835

39-
const imagesEndpoint = getJoinedNormalizedPath([
36+
const imagesEndpoint = joinPath([
4037
config.ENV.APP.API_PATH,
4138
ApiPath.IMAGES,
4239
ImagesApiPath.ROOT

0 commit comments

Comments
 (0)