Create
/api/v2/badge/create
Post
badges
profiles
notifications
Purpose
To allow the admin to create a badge.
Body Content [input]
{
    secret: string,
    name: string,
    description: string,
    icon_type: string,
    membersID: string[]
}
Returns if valid [output]
{
    badgeID: string,
    error: 0
}
What the API does
- Checks if the value of the 
secretfield passed is valid [401]. - Checks that 
membersIDis not empty [400] and loops through each of its values to ensure that there is a correponding record in theprofilescollection with these values [404]. - Generates a unique 
badgeID. - Adds and saves a document in the 
badgescollection using thename,description,icon_typeandmembersIDfields passed, as well as the generatedbadgeID. - Loops through each value present in the 
membersIDfield passed and generates a newnotificationIDand atimestampcorresponding to the current date and time, and creates a new object in thenotificationscollection with the following data :{ uid: loop_value, notificationID: notificationID, content: `You have obtained a new badge! badge.${badge.icon_type}`, profileID: '_system', type: "new_badge", created_on: timestamp, read: false, redirect: `/profile/${loop_value}` }