Skip to content

Users Endpoints

N Vijay Narayanan edited this page Aug 16, 2022 · 12 revisions

Get all users

GET: /api/users

  • Authorization Required: authorizeAdmin
Query Params Description Optional
cohortYear Cohort year of the projects false
role Users that are a specific role for the current specified cohort year (Returns all roles if unspecified) Valid Roles: ["Student", "Mentor", "Adviser"] true
page Offset of the records to return (For pagination) true
limit Limit of the records to return (For pagination) true
search Query to search for users via the student names true

Response Body:

{
    users: [
        {
            id: number;
            name: string;
            email: string;
            profilePicUrl?: string;
            githubUrl?: string;
            linkedinUrl?: string;
            personalSiteUrl?: string;
            selfIntro?: string;
            student: {
                ...
            },
            adviser: {
                ..
            },
            mentor: {
                ...
            },
            facilitator: {
                ...
            },
        }
    ]
}

Get all lean users (name and user ID)

GET: /api/users/lean

  • Authorization Required: authorizeAdmin
Query Params Description Optional
cohortYear Cohort year of the projects (Returns users from all cohorts if unspecified) true
role Users that are a specific role for the current specified cohort year (Returns users with any role if unspecified) true
excludeRole Users of that role to exclude from the list true

Either provide:

  1. cohortYear and role
  2. cohortYear and excludeRole

Response Body:

{
    users: [
        {
            name: string;
            student: {
                ...
            },
            adviser: {
                ..
            },
            mentor: {
                ...
            },
            administrator: {
                ...
            }
        }
    ]
}

Update a user

PUT: /api/users/:userId

  • Authorization Required: authorizeAdmin OR authorizeSelf

Request Body:

{
    user: {
        name?: string;
        email?: string;
        profilePicUrl?: string;
        githubUrl?: string;
        linkedinUrl?: string;
        personalSiteUrl?: string;
        selfIntro?: string;
    }
}

Adding a role to multiple accounts

PUT: /api/users/:role

  • Authorization Required: authorizeAdmin

Request Parameter: role: "Students" | "Advisers" | "Mentors" | "Administrators" (not optional)

Request Body:

{
    cohortYear: number,
    userIds: number[],
}

Delete a user

DELETE: /api/users/:userId

  • Authorization Required: authorizeAdmin

NUS Skylab v2 - Backend

Introduction

Project Organization

Project Requirements

Endpoints

Clone this wiki locally