Skip to content

Commit

Permalink
Change in api config file and change in url pattern regex
Browse files Browse the repository at this point in the history
  • Loading branch information
arati-tekdi committed Feb 24, 2025
1 parent 88e8230 commit 1383e6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/common/middleware/apiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1229,22 +1229,23 @@ export const apiList = {
},
'/object/category/definition/v4/create',
),
'/api/object/category/definition/v1/update': createRouteObject(
'/api/object/category/definition/v1/update/:identifier': createRouteObject(
{
patch: {
...common_role_check,
},
},
'/object/category/definition/v4/update',
'/object/category/definition/v4/update/:identifier',
),
'/api/object/category/definition/v1/update/:identifier': createRouteObject(
'/api/object/category/definition/v1/update': createRouteObject(
{
patch: {
...common_role_check,
},
},
'/object/category/definition/v4/update/:identifier',
'/object/category/definition/v4/update',
),

'/api/object/category/definition/v1/read/:identifier': createRouteObject(
{
get: {
Expand Down Expand Up @@ -1645,7 +1646,7 @@ export const apiListForAcademicYear = [
];

function convertToRegex(pattern) {
const regexString = pattern.replace(/:[^\s/]+/g, '([\\w-]+)');
const regexString = pattern.replace(/:[^\s/]+/g, '([\\w:-]+)');
return new RegExp(`^${regexString}$`);
}

Expand Down
17 changes: 8 additions & 9 deletions src/middleware/gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,20 @@ export class GatewayService {
method,
formData: any,
token?: string,
) {
try {
) {
try {
let response;
const headers = {
const headers = {
...formData.getHeaders(),
...(token ? { Authorization: `Bearer ${token}` } : {}),
...(token ? { Authorization: `Bearer ${token}` } : {}),
};
response = await axios({
method: method.toLowerCase(),
url,
data: formData,
headers,
method: method.toLowerCase(),
url,
data: formData,
headers,
});


res.locals.responseBody = response.data;
res.status(response.status);
return response.data;
Expand Down

0 comments on commit 1383e6b

Please sign in to comment.