Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Master to prod #63

Merged
merged 44 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3dd7b14
"Revise documentation structure and content
sopyb Sep 13, 2023
ddda055
Reorganize and update documentation files
sopyb Sep 13, 2023
1ef5aa9
Merge remote-tracking branch 'origin/master' into Docs-Update
sopyb Sep 13, 2023
d9c13ac
Add documentation for new API endpoints
sopyb Sep 13, 2023
1c2274e
Updated cookie documentation in Google Login
sopyb Sep 13, 2023
7238418
Improved route in roadmaps and response handling
sopyb Sep 16, 2023
ecab2a1
Add profanity filter utilities
sopyb Sep 20, 2023
a76de26
Add profanity filter to Roadmap creation & editing
sopyb Sep 20, 2023
c959623
Improve profanity filter and apply to roadmap validation
sopyb Sep 20, 2023
9f7f10f
Set Roadmaps to draft when containing profanity
sopyb Sep 20, 2023
dd1d059
Merge pull request #62 from NavigoLearn/wordFilter
sopyb Sep 20, 2023
db439c0
Version bump
sopyb Sep 20, 2023
3d2a599
Refactor `EmailUtil` functionality into `misc`
sopyb Sep 20, 2023
ebf0cbc
Prevent publishing drafts when roadmap is unlisted for profanity.
sopyb Sep 20, 2023
0a37ec9
Add detailed API documentation for auth endpoints
sopyb Sep 20, 2023
bf32739
Remove outdated auth API documentation
sopyb Sep 20, 2023
a978396
Update package.json and package-lock.json versions in frontend and API
sopyb Sep 13, 2023
0a58c50
Handle null values in ExploreDB queries
sopyb Sep 14, 2023
669e099
Fix extra "("
sopyb Sep 14, 2023
b877118
Refactor ExploreDB methods for better readability and seperation of c…
sopyb Sep 14, 2023
61901c4
Version Bump
sopyb Sep 14, 2023
bef2e16
Modify query parameter handling in ExploreDB
sopyb Sep 15, 2023
95b663a
Version bump
sopyb Sep 15, 2023
188bf44
Count only views not impressions in roadmapController.ts and ExploreD…
sopyb Sep 15, 2023
d63aa7a
Refactor search parameter validation.
sopyb Sep 15, 2023
ade2c50
Version Bump
sopyb Sep 15, 2023
d17d129
Version Bump
sopyb Sep 16, 2023
1744d60
Update session validation and paths for like/dislike
sopyb Sep 16, 2023
68a319a
Fix direction for likes being opposite
sopyb Sep 16, 2023
3e86610
Version Bump
sopyb Sep 16, 2023
a5a2e21
Improved route in roadmaps and response handling
sopyb Sep 16, 2023
c7c4faa
Add search API documentation
sopyb Sep 20, 2023
ae37da4
Merge remote-tracking branch 'origin/master' into Docs-Update
sopyb Sep 20, 2023
43b9225
Add new API documentation for roadmap handling
sopyb Sep 20, 2023
19fd738
Remove 'isDraft' from roadmap validation as it's an optional parameter
sopyb Sep 20, 2023
7a12a66
Add new API routes in docs
sopyb Sep 20, 2023
d03db6f
Remove deprecated API documentation
sopyb Sep 20, 2023
1188d2d
Add new User API documentation
sopyb Sep 20, 2023
97f5d77
Add api documentation for user update features
sopyb Sep 20, 2023
e069550
Fix typo in API reference link
sopyb Sep 20, 2023
dce0f53
Fix: Add missing bio update functionality to user profile routes
sopyb Sep 20, 2023
cdd276e
Merge pull request #56 from NavigoLearn/Docs-Update
sopyb Sep 20, 2023
1dde5bf
Update minimum Node version and update README
sopyb Sep 21, 2023
77ab5f9
Update minimum Node.js version in package-lock.json
sopyb Sep 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved route in roadmaps and response handling
Implemented a new route in the roadmaps for fetching progress data and updated the Paths constants file with the new route. Also, added response handlers for situations when roadmap progress is found or not found. All these changes were done mainly for enhancement in data retrieval and user experience.
  • Loading branch information
sopyb committed Sep 20, 2023
commit a5a2e2105ea6193995c210cac7a26fe26a753e4c
1 change: 1 addition & 0 deletions src/constants/Paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const Paths = {
Get: {
Base: '/:roadmapId([0-9]+)?',
Roadmap: '/',
Progress: '/progress',
},
Update: {
Base: '/:roadmapId([0-9]+)',
Expand Down
23 changes: 22 additions & 1 deletion src/controllers/roadmapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
responseRoadmapCreated,
responseRoadmapDeleted,
responseRoadmapNotFound,
responseRoadmapNotRated, responseRoadmapProgressUpdated,
responseRoadmapNotRated,
responseRoadmapProgressFound, responseRoadmapProgressNotFound,
responseRoadmapProgressUpdated,
responseRoadmapRated,
responseRoadmapUnrated,
responseRoadmapUpdated,
Expand Down Expand Up @@ -513,6 +515,25 @@ export async function removeLikeRoadmap(
return responseServerError(res);
}

export async function getProgressDataRoadmap(
req: RequestWithSession,
res: Response,
) {
const roadmapId = req.params.roadmapId;
const userId = req.session?.userId;

if (!userId) return responseServerError(res);
if (!roadmapId) return responseServerError(res);

const db = new Database();

const progress = await getRoadmapProgress(db, userId, BigInt(roadmapId));

if (progress === null) return responseRoadmapProgressNotFound(res);

return responseRoadmapProgressFound(res, progress);
}

export async function updateProgressDataRoadmap(
req: RequestWithBody,
res: Response,
Expand Down
16 changes: 16 additions & 0 deletions src/helpers/responses/roadmapResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import HttpStatusCodes from '@src/constants/HttpStatusCodes';
import { JSONSafety } from '@src/util/misc';
import { ResRoadmap } from '@src/types/response/ResRoadmap';
import { ResFullRoadmap } from '@src/types/response/ResFullRoadmap';
import {RoadmapProgress} from '@src/types/models/RoadmapProgress';

export function responseRoadmap(res: Response, roadmap: ResFullRoadmap): void {
res
Expand Down Expand Up @@ -119,6 +120,21 @@ export function responseRoadmapUnrated(res: Response) {
});
}

export function responseRoadmapProgressNotFound(res: Response) {
return res.status(HttpStatusCodes.NOT_FOUND).json({
message: 'Roadmap progress not found',
success: false,
});
}

export function responseRoadmapProgressFound(res: Response, progress: RoadmapProgress) {
return res.status(HttpStatusCodes.OK).json({
data: progress.data,
message: 'Roadmap progress found',
success: true,
});
}

export function responseRoadmapProgressUpdated(res: Response) {
return res.status(HttpStatusCodes.OK).json({
message: 'Roadmap progress updated',
Expand Down
12 changes: 11 additions & 1 deletion src/routes/roadmapsRoutes/RoadmapsGet.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { Router } from 'express';
import Paths from '@src/constants/Paths';
import { getRoadmap } from '@src/controllers/roadmapController';
import {
getProgressDataRoadmap,
getRoadmap,
} from '@src/controllers/roadmapController';
import validateSession from '@src/middleware/validators/validateSession';

const RoadmapsGet = Router({ mergeParams: true });

RoadmapsGet.get(Paths.Roadmaps.Get.Roadmap, getRoadmap);

RoadmapsGet.get(
Paths.Roadmaps.Get.Progress,
validateSession,
getProgressDataRoadmap,
);

export default RoadmapsGet;