Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 15 additions & 2 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion backend/seed-data/seed-students.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const preservedUserIds: string[] = [];

const sampleStudents = [
{
_id: "student_001",
email: "alex.chen@university.edu",
name: "Alex Chen",
profilePicture:
Expand All @@ -38,8 +39,10 @@ const sampleStudents = [
organizations: ["Computer Science Society"],
specializations: ["Web Systems"],
school: "Tech University",
shareProfile: true,
},
{
_id: "student_002",
email: "maya.patel@state.edu",
name: "Maya Patel",
profilePicture:
Expand All @@ -56,8 +59,10 @@ const sampleStudents = [
organizations: ["Women in STEM"],
specializations: ["Artificial Intelligence"],
school: "State University",
shareProfile: true,
},
{
_id: "student_003",
email: "jordan.smith@college.edu",
name: "Jordan Smith",
profilePicture:
Expand All @@ -74,8 +79,10 @@ const sampleStudents = [
organizations: ["Cyber Defense Club"],
specializations: ["Infrastructure"],
school: "Institute of Technology",
shareProfile: false,
},
{
_id: "student_004",
email: "liam.nguyen@uni.edu",
name: "Liam Nguyen",
profilePicture:
Expand All @@ -92,8 +99,10 @@ const sampleStudents = [
organizations: ["Game Dev Guild"],
specializations: ["Interactive Media"],
school: "Academy of Arts",
shareProfile: true,
},
{
_id: "student_005",
email: "sarah.kim@global.edu",
name: "Sarah Kim",
profilePicture:
Expand All @@ -110,8 +119,10 @@ const sampleStudents = [
organizations: ["Finance Association"],
specializations: ["Econometrics"],
school: "Global Business School",
shareProfile: false,
},
{
_id: "student_006",
email: "oscar.rodriguez@tech.edu",
name: "Oscar Rodriguez",
profilePicture:
Expand All @@ -128,8 +139,10 @@ const sampleStudents = [
organizations: ["Design Collective"],
specializations: ["User Experience"],
school: "Design Institute",
shareProfile: true,
},
{
_id: "student_007",
email: "chloe.wilson@state.edu",
name: "Chloe Wilson",
profilePicture: "https://images.unsplash.com/photo-1544005313-94ddf0286df2",
Expand All @@ -145,8 +158,10 @@ const sampleStudents = [
organizations: ["Cloud Computing Group"],
specializations: ["Distrubuted Systems"],
school: "Western University",
shareProfile: true,
},
{
_id: "student_008",
email: "ethan.brown@poly.edu",
name: "Ethan Brown",
profilePicture:
Expand All @@ -163,8 +178,10 @@ const sampleStudents = [
organizations: ["IEEE Student Branch"],
specializations: ["Microprocessors"],
school: "Polytechnic University",
shareProfile: false,
},
{
_id: "student_009",
email: "isabella.white@uni.edu",
name: "Isabella White",
profilePicture: "https://images.unsplash.com/photo-1554151228-14d9def656e4",
Expand All @@ -180,8 +197,10 @@ const sampleStudents = [
organizations: ["App Developers Club"],
specializations: ["Interface Design"],
school: "Central University",
shareProfile: true,
},
{
_id: "student_10",
email: "noah.davis@college.edu",
name: "Noah Davis",
profilePicture: "https://images.unsplash.com/photo-1552058544-f2b08422138a",
Expand All @@ -197,6 +216,7 @@ const sampleStudents = [
organizations: ["MIS Society"],
specializations: ["Information Security"],
school: "Business College",
shareProfile: false,
},
];

Expand Down Expand Up @@ -232,4 +252,4 @@ async function seedStudents() {
}
}

seedStudents();
seedStudents();
37 changes: 37 additions & 0 deletions backend/src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,43 @@ export const getOpenAlumni = asyncHandler(async (req, res, next) => {
});
});

// @desc Get students willing to share profile
// @route GET /api/users/student
// @access Private
export const getOpenStudents = asyncHandler(async (req, res, next) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return next(createHttpError(400, validationErrorParser(errors)));
}

const { page, perPage } = matchedData(req, {
locations: ["query"],
});

const dbQuery = User.find({
type: UserType.Student,
});

// ensure count and paginate do not conflict
const countQuery = dbQuery.clone();

// count total results, populate company, and paginate in parallel
const [total, users] = await Promise.all([
countQuery.countDocuments(),
dbQuery
.skip(page * perPage)
.limit(perPage)
.exec(),
]);

res.status(200).json({
page,
perPage,
total,
data: users,
});
});

export const getAlumniSimilarities = asyncHandler(async (req, res, next) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
Expand Down
6 changes: 6 additions & 0 deletions backend/src/routes/userRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ userRouter.get(
userController.getOpenAlumni,
);

userRouter.get(
"/student",
userValidator.getOpenStudentsValidator,
userController.getOpenStudents,
);

userRouter.get(
"/:id",
userValidator.getUservalidator,
Expand Down
8 changes: 8 additions & 0 deletions backend/src/validators/userValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@ export const getOpenAlumniValidator = [
validateIndustry,
];

export const getOpenStudentsValidator = [
validatePage,
validatePerPage,
validateQuery,
validateMajor,
validateClassLevel,
];

export const getSimilaritiesValidator = [
param("studentId")
.isString()
Expand Down
Loading
Loading