Skip to content

zelkim/lasallian.me

Repository files navigation

Lasallian.me

Table of Contents


Development

node index.js

File Structure

  • index.js - the main entrypoint of the API
  • routes/ - all http-related things, uses services, return status codes
  • services/ (also known as handlers) - all business logic, uses db operations (CRUD), map db objects to models
  • models/ - all domain-related objects

API Documentation

Authentication

Important

FLOW goes like this: /user/register -> need /user/setup -> then /user/login -> get valid final session_token from login route

Note

  1. the session_token from the /user/register is "INCOMPLETE" and valid only for the /user/setup route
  2. use the valid, final session_token from the /user/login to access other routes

POST /user/register

  • Creates user credentials and links to user info.
  • Follows the models/UserCredentials schema.

Note

Password must contain at least 8 characters, one uppercase letter, one lowercase letter, one number, and one special character

  • Request:
{
    "credentials": {
        "email": "test101@dlsu.edu.ph",
        "password": "Qwerty123!"
    }
}

Request (via curl):

curl -X POST localhost:3000/user/register -H "Content-Type: application/json" -d '{"credentials": {"email": "test101@dlsu.edu.ph", "password": "Qwerty123!"}}'

Response:

{
    "status": "ok",
    "session_token": "token-here",
    "user": {
        "credentials": {
            "email": "test101@dlsu.edu.ph",
            "password": "hashed-password"
        },
        "meta": {
            "created_at": "2025-01-30T05:06:55.095Z",
            "updated_at": "2025-01-30T05:06:55.095Z"
        },
        "_id": "679b08ef4c305e30723ea908",
        "__v": 0
    }
}

POST /user/setup

  • Requires JWT session token as Authorization: Bearer <JWT> header
  • Follows the models/UserInfo schema.

Request:

// required fields only
{
    "info": {
        "name": {
            "first": "Test",
            "last": "User"
        },
        "username": "@testuser",
        "batchid": "123",
        "program": "BSCS-ST",
    }
}

// full
{
    "vanity": {
        "display_photo": "photolink",
        "cover_photo": "photolink",
        "badges": []
    },
    "info": {
        "name": {
            "first": "Test",
            "last": "User"
        },
        "username": "@testuser",
        "batchid": "123",
        "program": "BSCS-ST",
        "bio": "Test bio",
        "links": {
            "linkedin": "",
            "facebook": "",
            "instagram": "",
            "other": []
        }
    }
}

Request (via curl):

# required fields only
curl -X POST localhost:3000/user/setup \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <JWT-from-register-or-login>" \
-d '{
    "info": {
        "name": {
            "first": "Test",
            "last": "User"
        },
        "username": "@testuser",
        "batchid": "123",
        "program": "BSCS-ST",
    }
}'

# full
curl -X POST localhost:3000/user/setup \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <JWT-from-register-or-login>" \
-d '{
    "vanity": {
        "display_photo": "photolink",
        "cover_photo": "photolink",
        "badges": []
    },
    "info": {
        "name": {
            "first": "Test",
            "last": "User"
        },
        "username": "@testuser",
        "batchid": "123",
        "program": "BSCS-ST",
        "bio": "Test bio",
        "links": {
            "linkedin": "",
            "facebook": "",
            "instagram": "",
            "other": []
        }
    }
}'

Response:

Note

the credentials field here should match the credentials' _id returned on /user/register or /user/login

{
    "status": "ok",
    "user": {
        "credentials": "67bf6181633a58782901247c",
        "vanity": {
            "display_photo": "photolink",
            "cover_photo": "photolink",
            "badges": []
        },
        "info": {
            "name": {
                "first": "Test",
                "last": "User"
            },
            "username": "@testuser",
            "batchid": "123",
            "program": "BSCS-ST",
            "bio": "Test bio",
            "links": {
                "linkedin": "",
                "facebook": "",
                "instagram": "",
                "other": []
            }
        },
        "meta": {
            "created_at": "2025-02-26T18:47:25.218Z",
            "updated_at": "2025-02-26T18:47:25.218Z"
        },
        "_id": "67bf61bd633a58782901247e",
        "__v": 0
    }
}

POST /user/login

  • Authenticates user and returns session token to be used for Authorization Header.

Request:

curl -X POST localhost:3000/user/login -H "Content-Type: application/json" -d \
'{"credentials": {"email": "test101@dlsu.edu.ph", "password": "Qwerty123!"}}'

# output: returns session token to be used for Authorization Header

Response:

Note

the credentials field here should match the credentials' _id returned on /user/register or /user/login

{
    "status": "ok",
    "session_token": "<JWT-from-login>",
    "user": {
        "credentials": "67bf6181633a58782901247c",
        "vanity": {
            "display_photo": "photolink",
            "cover_photo": "photolink",
            "badges": []
        },
        "info": {
            "name": {
                "first": "Test",
                "last": "User"
            },
            "links": {
                "linkedin": "",
                "facebook": "",
                "instagram": "",
                "other": []
            },
            "username": "@testuser",
            "batchid": "123",
            "program": "BSCS-ST",
            "bio": "Test bio"
        },
        "meta": {
            "created_at": "2025-02-26T18:47:25.218Z",
            "updated_at": "2025-02-26T18:47:25.218Z"
        },
        "_id": "67bf61bd633a58782901247e",
        "__v": 0
    }
}

GET /user

  • Gets the currently authenticated user's information
  • Requires JWT session token as Authorization: Bearer <JWT> header

Request (via curl):

curl -X GET localhost:3000/user -H "Authorization: Bearer <token>"

Response:

{
    "credentials": {
        "email": "test@dlsu.edu.ph"
    },
    "vanity": {
        "display_photo": "photolink",
        "cover_photo": "photolink",
        "badges": []
    },
    "info": {
        "name": {
            "first": "Test",
            "last": "User"
        },
        "username": "@testuser",
        "batchid": "123",
        "program": "BSCS-ST",
        "bio": "Test bio",
        "links": {
            "linkedin": "",
            "facebook": "",
            "instagram": "",
            "other": []
        }
    },
    "meta": {
        "created_at": "2025-02-26T18:47:25.218Z",
        "updated_at": "2025-02-26T18:47:25.218Z"
    }
}

GET /user/orgs

  • Gets all organizations where the authenticated user is a member
  • Requires JWT session token as Authorization: Bearer <JWT> header
  • Returns an array of organizations and their details

Request (via curl):

curl -X GET localhost:3000/user/orgs \
-H "Authorization: Bearer <token>"

Response:

{
    "status": "success",
    "count": 2,
    "organizations": [
        {
            "vanity": {
                "display_photo": "org1-logo.jpg",
                "cover_photo": "org1-banner.jpg",
                "badges": []
            },
            "info": {
                "name": "La Salle Computer Society",
                "acronym": "LSCS",
                "founding": "1990-01-01T00:00:00.000Z",
                "office": "Gokongwei 201",
                "college": "CCS",
                "bio": "DLSU's premier computing society",
                "links": {
                    "linkedin": "https://linkedin.com/company/lscs",
                    "facebook": "https://facebook.com/lscs",
                    "instagram": "https://instagram.com/lscs",
                    "other": []
                }
            },
            "meta": {
                "created_at": "2024-03-01T00:00:00.000Z",
                "updated_at": "2024-03-01T00:00:00.000Z"
            }
        },
        {
            "vanity": {
                "display_photo": "org2-logo.jpg",
                "cover_photo": "org2-banner.jpg",
                "badges": []
            },
            "info": {
                "name": "Union of Students Inspired Towards Education",
                "acronym": "UNITED",
                "founding": "1995-01-01T00:00:00.000Z",
                "office": "Gokongwei 205",
                "college": "CCS",
                "bio": "DLSU's peer tutoring organization",
                "links": {
                    "linkedin": "https://linkedin.com/company/united",
                    "facebook": "https://facebook.com/united",
                    "instagram": "https://instagram.com/united",
                    "other": []
                }
            },
            "meta": {
                "created_at": "2024-03-01T00:00:00.000Z",
                "updated_at": "2024-03-01T00:00:00.000Z"
            }
        }
    ]
}

GET /user/:id/orgs

  • Gets all organizations where a specified user is a member
  • Requires JWT session token as Authorization: Bearer <JWT> header
  • Returns an array of organizations and their details for the specified user ID

Request (via curl):

curl -X POST localhost:3000/user/67c8478d8e9f541dfe96893e/orgs \
-H "Authorization: Bearer <token>"

Request Body: None required - uses ID from URL parameter

Response:

{
    "status": "success",
    "count": 2,
    "organizations": [
        {
            "vanity": {
                "display_photo": "org1-logo.jpg",
                "cover_photo": "org1-banner.jpg",
                "badges": []
            },
            "info": {
                "name": "La Salle Computer Society",
                "acronym": "LSCS",
                "founding": "1990-01-01T00:00:00.000Z",
                "office": "Gokongwei 201",
                "college": "CCS",
                "bio": "DLSU's premier computing society",
                "links": {
                    "linkedin": "https://linkedin.com/company/lscs",
                    "facebook": "https://facebook.com/lscs",
                    "instagram": "https://instagram.com/lscs",
                    "other": []
                }
            },
            "meta": {
                "created_at": "2024-03-01T00:00:00.000Z",
                "updated_at": "2024-03-01T00:00:00.000Z"
            }
        }
    ]
}

GET /user/:id

  • Gets user information by user ID
  • Requires JWT session token as Authorization: Bearer <JWT> header

Request (via curl):

curl -X GET localhost:3000/user/<user-id> -H "Authorization: Bearer <token>"

Response:

{
    "credentials": {
        "_id": "67bf6181633a58782901247c",
        "email": "test@dlsu.edu.ph"
    },
    "vanity": {
        "display_photo": "photolink",
        "cover_photo": "photolink",
        "badges": []
    },
    "info": {
        "name": {
            "first": "Test",
            "last": "User"
        },
        "username": "@testuser",
        "batchid": "123",
        "program": "BSCS-ST",
        "bio": "Test bio",
        "links": {
            "linkedin": "",
            "facebook": "",
            "instagram": "",
            "other": []
        }
    },
    "meta": {
        "created_at": "2025-02-26T18:47:25.218Z",
        "updated_at": "2025-02-26T18:47:25.218Z"
    },
    "_id": "67bf61bd633a58782901247e"
}

POST /user/get-by-email

  • Gets user information by email address
  • Requires JWT session token as Authorization: Bearer <JWT> header

Request:

// requires Authorization: Bearer <JWT>
{
    "email": "w2helloworld@dlsu.edu.ph"
}

Request (via curl):

curl -X POST localhost:3000/user/get-by-email \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{"email": "w2helloworld@dlsu.edu.ph"}'

Response:

{
    "credentials": {
        "_id": "67c846968e9f541dfe96893c",
        "email": "w2helloworld@dlsu.edu.ph"
    },
    "vanity": {
        "badges": []
    },
    "info": {
        "name": {
            "first": "w2helloworld",
            "last": "YES"
        },
        "links": {
            "other": []
        },
        "username": "@w2helloworld",
        "batchid": "123",
        "program": "BSIT"
    },
    "meta": {
        "created_at": "2025-03-05T12:46:05.075Z",
        "updated_at": "2025-03-05T12:46:05.075Z"
    },
    "_id": "67c8478d8e9f541dfe96893e"
}

PUT /user

  • Edit/Updates the user profile details of the currently authenticated user

    • This route can also be used to change the credentials of the user (read IMPORTANT note below)
  • Requires: Authorization: Bearer <token>

    • via the <token>, the server will know who is the currently authenticated user
  • See sample request for the request body (minimal and full)

Important

Everything is optional by default (only include what you want to edit/change/update: credentials, info, and/or vanity) - meaning this retains all of the other profile details if left unchanged

Request:

### update user profile (minimal changes)
PUT http://localhost:3000/user
Content-Type: application/json
Authorization: Bearer <token>

{
    "info": {
        "bio": "Updated bio text",
        "links": {
            "linkedin": "https://linkedin.com/in/newprofile"
        }
    }
}

### update user profile (many changes)
PUT http://localhost:3000/user
Content-Type: application/json
Authorization: Bearer <token>

{
    "credentials": {
        "email": "w2helloworld@dlsu.edu.ph",
        "password": "NewPassword123!"
    },
    "info": {
        "name": {
            "first": "w2",
            "last": "helloworld"
        },
        "username": "@w2helloworld",
        "batchid": "123",
        "program": "BSIT",
        "bio": "My updated professional bio",
        "links": {
            "linkedin": "https://linkedin.com/in/updated",
            "facebook": "https://facebook.com/updated",
            "instagram": "https://instagram.com/updated",
            "other": ["https://github.com/updated"]
        }
    },
    "vanity": {
        "display_photo": "https://new-photo-url.com/photo.jpg",
        "cover_photo": "https://new-photo-url.com/cover.jpg"
    }
}

Response:

// response for both requests
{
    "status": "success",
    "user": {
        "credentials": {
            "email": "w2helloworld@dlsu.edu.ph"
        },
        "vanity": {
            "badges": [],
            "cover_photo": "https://new-photo-url.com/cover.jpg",
            "display_photo": "https://new-photo-url.com/photo.jpg"
        },
        "info": {
            "name": {
                "first": "w2",
                "last": "helloworld"
            },
            "links": {
                "other": ["https://github.com/updated"],
                "linkedin": "https://linkedin.com/in/newprofile",
                "facebook": "https://facebook.com/updated",
                "instagram": "https://instagram.com/updated"
            },
            "username": "@w2helloworld",
            "batchid": "123",
            "program": "BSIT",
            "bio": "Updated bio text"
        },
        "meta": {
            "created_at": "2025-03-05T12:46:05.075Z",
            "updated_at": "2025-03-09T09:45:04.383Z"
        }
    }
}

Posts

GET /post/all

  • Gets all posts
  • mainly for testing

Request:

curl -X GET localhost:3000/post/all

Response:

Important

The author._id for each post determines who owns the post

[
    {
        "meta": {
            "created_at": "2025-03-04T11:22:41.892Z",
            "updated_at": "2025-03-04T11:54:22.043Z"
        },
        "type": "normal",
        "visibility": "public",
        "comments": [],
        "reactions": [],
        "_id": "67c6e2814911dd82e8dabb94",
        "title": "Updated Post Title",
        "content": {
            "text": "Updated post content"
        },
        "media": ["url string here"],
        "author": {
            "vanity": {
                "display_photo": "photolink",
                "cover_photo": "photolink",
                "badges": []
            },
            "info": {
                "name": {
                    "first": "Test",
                    "last": "User"
                },
                "links": {
                    "linkedin": "",
                    "facebook": "",
                    "instagram": "",
                    "other": []
                },
                "username": "@testuser",
                "batchid": "123",
                "program": "BSCS-ST",
                "bio": "Test bio"
            },
            "_id": "67bf5d822d93557c2e6aee28"
        },
        "__v": 0
    },
    {
        "meta": {
            "created_at": "2025-03-05T05:53:07.925Z",
            "updated_at": "2025-03-05T05:53:07.925Z"
        },
        "_id": "67c7e6c340f3e5260fc1089c",
        "title": "title, content, and type normal by test101",
        "content": {
            "text": "yes yes content example something"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "comments": [],
        "reactions": [],
        "author": {
            "vanity": {
                "display_photo": "photolink",
                "cover_photo": "photolink",
                "badges": []
            },
            "info": {
                "name": {
                    "first": "Test",
                    "last": "User"
                },
                "links": {
                    "linkedin": "",
                    "facebook": "",
                    "instagram": "",
                    "other": []
                },
                "username": "@testuser",
                "batchid": "123",
                "program": "BSCS-ST",
                "bio": "Test bio"
            },
            "_id": "67bf5d822d93557c2e6aee28"
        },
        "__v": 0
    }
]

GET /post/all/:id

  • Gets all posts created by a specific user
  • Requires JWT session token as Authorization: Bearer <JWT> header
  • Returns posts sorted by creation date (newest first)
  • Includes author details, reactions, comments, and organization info where applicable

Request:

### fetch all posts from specific user (by UserInfo _id)
GET http://localhost:3000/post/all/67c8478d8e9f541dfe96893e
Authorization: Bearer {{authToken}}

Response:

{
    "status": "success",
    "count": 7,
    "posts": [
        {
            "meta": {
                "created_at": "2025-03-09T12:23:00.148Z",
                "updated_at": "2025-03-09T12:23:00.148Z"
            },
            "_id": "67cd8824a05e28753681bdb2",
            "content": {
                "text": "NORMAL MINIMAL POST hehe"
            },
            "media": [],
            "type": "normal",
            "visibility": "public",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "comments": [],
            "hashtags": [],
            "reactions": [],
            "__v": 0
        },
        {
            "meta": {
                "created_at": "2025-03-09T12:22:06.882Z",
                "updated_at": "2025-03-09T12:22:06.882Z"
            },
            "_id": "67cd87eea05e28753681bdad",
            "title": "POST4 w2helloworld normal",
            "content": {
                "text": "Testing hastag post 2 #test #w2"
            },
            "media": ["url-string-test"],
            "type": "normal",
            "visibility": "public",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "comments": [],
            "hashtags": [
                {
                    "tag": "#test",
                    "_id": "67cd87eea05e28753681bdae"
                },
                {
                    "tag": "#w2",
                    "_id": "67cd87eea05e28753681bdaf"
                }
            ],
            "reactions": [],
            "__v": 0
        },
        {
            "meta": {
                "created_at": "2025-03-09T12:16:17.122Z",
                "updated_at": "2025-03-09T12:16:17.122Z"
            },
            "_id": "67cd869140d5b6ac12402dab",
            "title": "POST3 w2helloworld normal",
            "content": {
                "text": "Testing hastag post 2 #test #w2"
            },
            "media": [],
            "type": "normal",
            "visibility": "public",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "comments": [],
            "hashtags": [
                {
                    "tag": "#test",
                    "_id": "67cd869140d5b6ac12402dac"
                },
                {
                    "tag": "#w2",
                    "_id": "67cd869140d5b6ac12402dad"
                }
            ],
            "reactions": [],
            "__v": 0
        },
        {
            "meta": {
                "created_at": "2025-03-09T12:01:01.702Z",
                "updated_at": "2025-03-09T12:01:01.703Z"
            },
            "_id": "67cd82fd7ee3f662874eea5c",
            "title": "POST2 w2helloworld normal",
            "content": {
                "text": "Testing hastag post 2 #test"
            },
            "media": [],
            "type": "normal",
            "visibility": "public",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "comments": [],
            "hashtags": [
                {
                    "tag": "#test",
                    "_id": "67cd82fd7ee3f662874eea5d"
                }
            ],
            "reactions": [],
            "__v": 0
        },
        {
            "meta": {
                "created_at": "2025-03-09T09:01:07.492Z",
                "updated_at": "2025-03-09T09:01:07.492Z"
            },
            "comments": [],
            "reactions": [],
            "_id": "67cd58d32287dd04c274682d",
            "title": "POST w2helloworld normal",
            "content": {
                "text": "Testing hastag post 2 #test"
            },
            "media": [],
            "type": "normal",
            "visibility": "public",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "hashtags": [
                {
                    "tag": "#test",
                    "_id": "67cd58d32287dd04c274682e"
                }
            ],
            "__v": 0
        },
        {
            "meta": {
                "created_at": "2025-03-09T08:44:48.519Z",
                "updated_at": "2025-03-09T08:44:48.519Z"
            },
            "comments": [],
            "reactions": [],
            "_id": "67cd5500303878647c86348d",
            "title": "POST w2helloworld project",
            "content": {
                "text": "Testing hastag post 2 #test"
            },
            "media": [],
            "type": "project",
            "visibility": "public",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "hashtags": [
                {
                    "tag": "#test",
                    "_id": "67cd5500303878647c86348e"
                }
            ],
            "__v": 0
        },
        {
            "meta": {
                "created_at": "2025-03-07T06:45:57.545Z",
                "updated_at": "2025-03-07T06:45:57.545Z"
            },
            "reactions": [],
            "_id": "67ca96256d1229bbc5009f47",
            "title": "Post with hashtags 4",
            "content": {
                "text": "Testing hastag post 2#test"
            },
            "media": [],
            "type": "normal",
            "visibility": "public",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "hashtags": [
                {
                    "tag": "#test",
                    "_id": "67ca96256d1229bbc5009f48"
                }
            ],
            "__v": 1,
            "comments": []
        }
    ]
}

GET /post/hashtag/:tag

  • Gets all posts containing the specified hashtag
  • Requires JWT session token as Authorization: Bearer <JWT> header

Request (via curl):

curl -X GET localhost:3000/post/hashtag/<hashtag> -H "Authorization: Bearer <token>"

# example with "test" hashtag
curl -X GET localhost:3000/post/hashtag/test -H "Authorization: Bearer <token>"

Response:

// with "test" hashtag
[
    {
        "meta": {
            "created_at": "2025-03-07T06:45:57.545Z",
            "updated_at": "2025-03-07T06:45:57.545Z"
        },
        "reactions": [],
        "_id": "67ca96256d1229bbc5009f47",
        "title": "Post with hashtags 4",
        "content": {
            "text": "Testing hastag post 2#test"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67ca96256d1229bbc5009f48"
            }
        ],
        "__v": 1,
        "comments": []
    },
    {
        "meta": {
            "created_at": "2025-03-09T08:44:48.519Z",
            "updated_at": "2025-03-09T08:44:48.519Z"
        },
        "comments": [],
        "reactions": [],
        "_id": "67cd5500303878647c86348d",
        "title": "POST w2helloworld project",
        "content": {
            "text": "Testing hastag post 2 #test"
        },
        "media": [],
        "type": "project",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67cd5500303878647c86348e"
            }
        ],
        "__v": 0
    },
    {
        "meta": {
            "created_at": "2025-03-09T09:01:07.492Z",
            "updated_at": "2025-03-09T09:01:07.492Z"
        },
        "comments": [],
        "reactions": [],
        "_id": "67cd58d32287dd04c274682d",
        "title": "POST w2helloworld normal",
        "content": {
            "text": "Testing hastag post 2 #test"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67cd58d32287dd04c274682e"
            }
        ],
        "__v": 0
    },
    {
        "meta": {
            "created_at": "2025-03-09T12:01:01.702Z",
            "updated_at": "2025-03-09T12:01:01.703Z"
        },
        "_id": "67cd82fd7ee3f662874eea5c",
        "title": "POST2 w2helloworld normal",
        "content": {
            "text": "Testing hastag post 2 #test"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "comments": [],
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67cd82fd7ee3f662874eea5d"
            }
        ],
        "reactions": [],
        "__v": 0
    },
    {
        "meta": {
            "created_at": "2025-03-09T12:16:17.122Z",
            "updated_at": "2025-03-09T12:16:17.122Z"
        },
        "_id": "67cd869140d5b6ac12402dab",
        "title": "POST3 w2helloworld normal",
        "content": {
            "text": "Testing hastag post 2 #test #w2"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "comments": [],
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67cd869140d5b6ac12402dac"
            },
            {
                "tag": "#w2",
                "_id": "67cd869140d5b6ac12402dad"
            }
        ],
        "reactions": [],
        "__v": 0
    },
    {
        "meta": {
            "created_at": "2025-03-09T12:22:06.882Z",
            "updated_at": "2025-03-09T12:22:06.882Z"
        },
        "_id": "67cd87eea05e28753681bdad",
        "title": "POST4 w2helloworld normal",
        "content": {
            "text": "Testing hastag post 2 #test #w2"
        },
        "media": ["url-string-test"],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "comments": [],
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67cd87eea05e28753681bdae"
            },
            {
                "tag": "#w2",
                "_id": "67cd87eea05e28753681bdaf"
            }
        ],
        "reactions": [],
        "__v": 0
    }
]

GET /post/normal

  • Gets ALL NORMAL posts made by the current authenticated user

Request:

curl -X GET localhost:3000/post/normal -H "Authorization: Bearer <token>"

Response:

[
    {
        "meta": {
            "created_at": "2025-03-07T06:45:57.545Z",
            "updated_at": "2025-03-07T06:45:57.545Z"
        },
        "reactions": [],
        "_id": "67ca96256d1229bbc5009f47",
        "title": "Post with hashtags 4",
        "content": {
            "text": "Testing hastag post 2#test"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67ca96256d1229bbc5009f48"
            }
        ],
        "__v": 1,
        "comments": [
            {
                "meta": {
                    "created_at": "2025-03-09T11:14:40.127Z",
                    "updated_at": "2025-03-09T11:14:40.127Z"
                },
                "reactions": [],
                "_id": "67cd782026e24242b1e25f8f",
                "author": {
                    "vanity": {
                        "badges": []
                    },
                    "info": {
                        "name": {
                            "first": "w2helloworld123",
                            "last": "YES"
                        },
                        "links": {
                            "other": []
                        },
                        "username": "@w2helloworld123",
                        "batchid": "123",
                        "program": "BSIT"
                    },
                    "_id": "67ca8695962e856f3a0ccb21"
                },
                "content": "harru warudo",
                "post": "67ca96256d1229bbc5009f47",
                "__v": 0
            }
        ]
    },
    {
        "meta": {
            "created_at": "2025-03-09T09:01:07.492Z",
            "updated_at": "2025-03-09T09:01:07.492Z"
        },
        "comments": [],
        "reactions": [],
        "_id": "67cd58d32287dd04c274682d",
        "title": "POST w2helloworld normal",
        "content": {
            "text": "Testing hastag post 2 #test"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67cd58d32287dd04c274682e"
            }
        ],
        "__v": 0
    },
    {
        "meta": {
            "created_at": "2025-03-09T12:01:01.702Z",
            "updated_at": "2025-03-09T12:01:01.703Z"
        },
        "_id": "67cd82fd7ee3f662874eea5c",
        "title": "POST2 w2helloworld normal",
        "content": {
            "text": "Testing hastag post 2 #test"
        },
        "media": [],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "badges": [],
                "cover_photo": "https://new-photo-url.com/cover.jpg",
                "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
                "name": {
                    "first": "w2",
                    "last": "helloworld"
                },
                "links": {
                    "other": ["https://github.com/updated"],
                    "linkedin": "https://linkedin.com/in/newprofile",
                    "facebook": "https://facebook.com/updated",
                    "instagram": "https://instagram.com/updated"
                },
                "username": "@w2helloworld",
                "batchid": "123",
                "program": "BSIT",
                "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
        },
        "comments": [],
        "hashtags": [
            {
                "tag": "#test",
                "_id": "67cd82fd7ee3f662874eea5d"
            }
        ],
        "reactions": [],
        "__v": 0
    }
]

GET /post/project

  • Gets ALL PROJECT posts made by the current authenticated user
  • Needs Authorization: Bearer <token> in request headers
  • Returns array of project posts where the authenticated user is the author

Request:

curl -X GET localhost:3000/post/project -H "Authorization: Bearer <token>"

Response:

[
    {
        "meta": {
            "created_at": "2025-03-04T11:19:11.061Z",
            "updated_at": "2025-03-04T11:19:11.061Z"
        },
        "_id": "67c6e1af4911dd82e8dabb78",
        "title": "Personal Portfolio Website",
        "content": {
            "text": "A showcase of my web development skills",
            "technologies": ["React", "TailwindCSS"],
            "github": "https://github.com/username/portfolio"
        },
        "media": ["screenshot1.jpg", "screenshot2.jpg"],
        "type": "project",
        "visibility": "public",
        "comments": [],
        "author": {
            "vanity": {
                "display_photo": "photolink",
                "cover_photo": "photolink",
                "badges": []
            },
            "info": {
                "name": {
                    "first": "Test",
                    "last": "User"
                },
                "links": {
                    "linkedin": "",
                    "facebook": "",
                    "instagram": "",
                    "other": []
                },
                "username": "@testuser",
                "batchid": "123",
                "program": "BSCS-ST",
                "bio": "Test bio"
            },
            "_id": "67bf5b7efd7bafc4558be3bc"
        },
        "__v": 0
    },
    {
        "meta": {
            "created_at": "2025-03-04T11:20:10.770Z",
            "updated_at": "2025-03-04T11:20:10.770Z"
        },
        "_id": "67c6e1ea4911dd82e8dabb89",
        "title": "Mobile App Project",
        "content": {
            "text": "A cross-platform mobile application",
            "technologies": ["React Native", "Firebase"],
            "playstore": "https://play.google.com/store/apps/details?id=com.example"
        },
        "media": ["app-preview.gif"],
        "type": "project",
        "visibility": "public",
        "comments": [],
        "author": {
            "vanity": {
                "display_photo": "photolink",
                "cover_photo": "photolink",
                "badges": []
            },
            "info": {
                "name": {
                    "first": "Test",
                    "last": "User"
                },
                "links": {
                    "linkedin": "",
                    "facebook": "",
                    "instagram": "",
                    "other": []
                },
                "username": "@testuser",
                "batchid": "123",
                "program": "BSCS-ST",
                "bio": "Test bio"
            },
            "_id": "67bf5b7efd7bafc4558be3bc"
        },
        "__v": 0
    }
]

GET /post/event

  • Gets ALL EVENT posts made by the current authenticated user
  • Needs Authorization: Bearer <token> in request headers
  • Returns array of event posts where the authenticated user is the author
  • Includes organization details for each event
  • Only returns events that are either public or belong to the user's organization

Request:

curl -X GET localhost:3000/post/event -H "Authorization: Bearer <token>"

Response:

[
    {
        "meta": {
            "created_at": "2025-03-04T11:19:11.061Z",
            "updated_at": "2025-03-04T11:19:11.061Z"
        },
        "_id": "67c6e1af4911dd82e8dabb78",
        "title": "Tech Talk 2025",
        "content": {
            "text": "Join us for an evening of technology insights",
            "date": "2025-04-15T18:00:00.000Z",
            "venue": "Andrew Building Room 1880",
            "registration_link": "https://example.com/register"
        },
        "media": ["event-poster.jpg"],
        "type": "event",
        "visibility": "public",
        "comments": [],
        "author": {
            "vanity": {
                "display_photo": "photolink",
                "cover_photo": "photolink",
                "badges": []
            },
            "info": {
                "name": {
                    "first": "Test",
                    "last": "User"
                },
                "links": {
                    "linkedin": "",
                    "facebook": "",
                    "instagram": "",
                    "other": []
                },
                "username": "@testuser",
                "batchid": "123",
                "program": "BSCS-ST",
                "bio": "Test bio"
            },
            "_id": "67bf5b7efd7bafc4558be3bc"
        },
        "organization": {
            "vanity": {
                "display_photo": "org-logo.jpg",
                "cover_photo": "org-banner.jpg",
                "badges": []
            },
            "info": {
                "name": "La Salle Computer Society",
                "acronym": "LSCS",
                "founding": "1990-01-01T00:00:00.000Z",
                "bio": "DLSU's premier computing society"
            },
            "_id": "67bf5d822d93557c2e6aee30"
        },
        "__v": 0
    }
]

GET /post/normal/:id

  • gets specific post, given the post _id as path parameter

Request:

GET http://localhost:3000/post/normal/67cd3b750ddeeaa2a76f833f
Authorization: Bearer {{authToken}}

Response:

{
    "meta": {
        "created_at": "2025-03-09T06:55:49.359Z",
        "updated_at": "2025-03-09T06:55:49.359Z"
    },
    "_id": "67cd3b750ddeeaa2a76f833f",
    "content": {
        "text": "what the sigma #boy"
    },
    "media": [],
    "type": "normal",
    "visibility": "public",
    "author": {
        "vanity": {
            "badges": []
        },
        "info": {
            "name": {
                "first": "Sean Denzel",
                "last": "Robenta"
            },
            "links": {
                "other": []
            },
            "username": "@zelkim",
            "batchid": "123",
            "program": "BS Computer Science Major in Software Technology",
            "bio": "titrebio"
        },
        "_id": "67cd35870ddeeaa2a76f82f0"
    },
    "hashtags": [
        {
            "tag": "#boy",
            "_id": "67cd3b750ddeeaa2a76f8340"
        }
    ],
    "__v": 2,
    "comments": [
        {
            "meta": {
                "created_at": "2025-03-09T12:30:54.795Z",
                "updated_at": "2025-03-09T12:30:54.795Z"
            },
            "_id": "67cd89fe21009c70077678e6",
            "author": {
                "vanity": {
                    "badges": [],
                    "cover_photo": "https://new-photo-url.com/cover.jpg",
                    "display_photo": "https://new-photo-url.com/photo.jpg"
                },
                "info": {
                    "name": {
                        "first": "w2",
                        "last": "helloworld"
                    },
                    "links": {
                        "other": ["https://github.com/updated"],
                        "linkedin": "https://linkedin.com/in/newprofile",
                        "facebook": "https://facebook.com/updated",
                        "instagram": "https://instagram.com/updated"
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT",
                    "bio": "Updated bio text"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "content": "test comment",
            "post": "67cd3b750ddeeaa2a76f833f",
            "reactions": [],
            "__v": 0
        }
    ],
    "reactions": []
}

GET /post/project/:id

  • Gets a specific project post, given the post _id as path parameter
  • Needs Authorization: Bearer <token> in request headers
  • Will only return posts of type "project"

Request:

curl -X GET localhost:3000/post/project/<post-id> -H "Authorization: Bearer <token>"

# example request with post's _id as path parameter
curl -X GET localhost:3000/post/project/67c6e2814911dd82e8dabb94 -H "Authorization: Bearer <token>"

Response:

{
    "meta": {
        "created_at": "2025-03-05T05:53:07.925Z",
        "updated_at": "2025-03-05T05:53:07.925Z"
    },
    "_id": "67c7e6c340f3e5260fc1089c",
    "title": "My Portfolio Project",
    "content": {
        "text": "Project description here",
        "technologies": ["React", "Node.js"]
    },
    "media": ["project-screenshot.jpg"],
    "type": "project",
    "visibility": "public",
    "comments": [],
    "author": {
        "vanity": {
            "display_photo": "photolink",
            "cover_photo": "photolink",
            "badges": []
        },
        "info": {
            "name": {
                "first": "Test",
                "last": "User"
            },
            "links": {
                "linkedin": "",
                "facebook": "",
                "instagram": "",
                "other": []
            },
            "username": "@testuser",
            "batchid": "123",
            "program": "BSCS-ST",
            "bio": "Test bio"
        },
        "_id": "67bf5d822d93557c2e6aee28"
    },
    "__v": 0
}

GET /post/event/:id

  • Gets a specific event post, given the post _id as path parameter
  • Needs Authorization: Bearer <token> in request headers
  • Will only return posts of type "event"
  • Includes organization details since events are organization-specific

Request:

curl -X GET localhost:3000/post/event/<post-id> -H "Authorization: Bearer <token>"

# example request with post's _id as path parameter
curl -X GET localhost:3000/post/event/67c6e2814911dd82e8dabb94 -H "Authorization: Bearer <token>"

Response:

{
    "meta": {
        "created_at": "2025-03-05T05:53:07.925Z",
        "updated_at": "2025-03-05T05:53:07.925Z"
    },
    "_id": "67c7e6c340f3e5260fc1089c",
    "title": "Annual Tech Conference",
    "content": {
        "text": "Join us for our annual tech conference!",
        "date": "2025-04-01T09:00:00.000Z",
        "location": "Henry Sy Sr. Hall"
    },
    "media": ["event-banner.jpg"],
    "type": "event",
    "visibility": "public",
    "author": {
        "vanity": {
            "display_photo": "photolink",
            "cover_photo": "photolink",
            "badges": []
        },
        "info": {
            "name": {
                "first": "Test",
                "last": "User"
            },
            "links": {
                "linkedin": "",
                "facebook": "",
                "instagram": "",
                "other": []
            },
            "username": "@testuser",
            "batchid": "123",
            "program": "BSCS-ST",
            "bio": "Test bio"
        },
        "_id": "67bf5d822d93557c2e6aee28"
    },
    "organization": {
        "vanity": {
            "display_photo": "org-photo.jpg",
            "cover_photo": "org-cover.jpg",
            "badges": []
        },
        "info": {
            "name": "La Salle Computer Society",
            "acronym": "LSCS",
            "founding": "1990-01-01T00:00:00.000Z",
            "bio": "DLSU's premier computing society"
        },
        "_id": "67bf5d822d93557c2e6aee30"
    },
    "__v": 0
}

Generic Post Routes

  • for creating a post regardless of type: POST /post
  • for updating a post: PUT /post/:id
  • for deleting a post: DELETE /post/:id
  • for search a post with query parameters GET /post/search

POST /post

  • creates a post with author as the authenticated user

  • needs Authorization: Bearer token in request headers

  • required fields in request body:

    • content (Object)
  • optional fields in request body:

    • title (string)
    • media (string array)
    • type (only: normal, project, or event) - by default this is set to be normal
    • visibility (only: public, organization, private) - by default this is set to be public

Important

This route is used to create ALL TYPES of post

Request:

### create post (minimal)
POST http://localhost:3000/post
Content-Type: application/json
Authorization: Bearer {{authToken}}

{
    "content": {
        "text": "NORMAL MINIMAL POST hehe"
    }
}

### create post with all the optional fields
POST http://localhost:3000/post
Content-Type: application/json
Authorization: Bearer {{authToken}}

{
    "title": "POST4 w2helloworld normal",
    "content": {
        "text": "Testing hastag post 2 #test #w2"
    },
    "type": "normal",
    "visibility": "public",
    "media": ["url-string-test"]
}

Response:

// create post with required fields only (minimal)
{
  "status": "success",
  "savedPost": {
    "content": {
      "text": "NORMAL MINIMAL POST hehe"
    },
    "media": [],
    "type": "normal",
    "visibility": "public",
    "meta": {
      "created_at": "2025-03-09T12:23:00.148Z",
      "updated_at": "2025-03-09T12:23:00.148Z"
    },
    "author": "67c8478d8e9f541dfe96893e",
    "comments": [],
    "hashtags": [],
    "reactions": [],
    "_id": "67cd8824a05e28753681bdb2",
    "__v": 0
  }
}

// with all the optional fields
{
  "status": "success",
  "savedPost": {
    "title": "POST4 w2helloworld normal",
    "content": {
      "text": "Testing hastag post 2 #test #w2"
    },
    "media": [
      "url-string-test"
    ],
    "type": "normal",
    "visibility": "public",
    "meta": {
      "created_at": "2025-03-09T12:22:06.882Z",
      "updated_at": "2025-03-09T12:22:06.882Z"
    },
    "author": "67c8478d8e9f541dfe96893e",
    "comments": [],
    "hashtags": [
      {
        "tag": "#test",
        "_id": "67cd87eea05e28753681bdae"
      },
      {
        "tag": "#w2",
        "_id": "67cd87eea05e28753681bdaf"
      }
    ],
    "reactions": [],
    "_id": "67cd87eea05e28753681bdad",
    "__v": 0
  }
}

PUT /post/:id

  • updates a specific post given the post's _id in the path parameter

  • needs Authorization: Bearer <token> in the request headers

  • required fields in request body:

    • title (string)
    • content (Object)
  • optional fields in request body:

    • media (string array)
    • type (only: normal, project, or event) - by default this is set to be normal
    • visibility (only: public, organization, private) - by default this is set to be public

Request:

[!IMPORTANT] > content is of type Object so the structure is like this

# all required fields (title and content only)
curl -X PUT "http://localhost:3000/post/<post-id>" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
  "title": "Updated Post Title",
  "content": {"text": "Updated post content"}
}'

# with optional fields
curl -X PUT "http://localhost:3000/post/<post-id>" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
  "title": "NEW Updated Post Title with media",
  "content": {"text": "NEW Updated post content with media"},
  "media": ["url string here"],
  "visibility": "private",
  "type": "normal",
}'

Response (with all required fields: title and content):

{
    "status": "success",
    "post": {
        "meta": {
            "created_at": "2025-03-05T06:05:42.969Z",
            "updated_at": "2025-03-05T06:20:23.682Z"
        },
        "_id": "67c7e9b634e511d4d78edc94",
        "title": "NEW Updated Post Title",
        "content": {
            "text": "NEW Updated post content"
        },
        "media": ["url string here"],
        "type": "normal",
        "visibility": "public",
        "author": {
            "vanity": {
                "display_photo": "photolink",
                "cover_photo": "photolink",
                "badges": []
            },
            "info": {
                "name": {
                    "first": "Test",
                    "last": "User"
                },
                "links": {
                    "linkedin": "",
                    "facebook": "",
                    "instagram": "",
                    "other": []
                },
                "username": "@testuser",
                "batchid": "123",
                "program": "BSCS-ST",
                "bio": "Test bio"
            },
            "_id": "67bf5d822d93557c2e6aee28"
        },
        "__v": 0
    }
}

Response (with the optional fields):

{
    "status": "success",
    "post": {
        "meta": {
            "created_at": "2025-03-05T06:33:36.461Z",
            "updated_at": "2025-03-05T06:45:54.846Z"
        },
        "_id": "67c7f04093bca7c3aa369100",
        "title": "NEW Updated Post Title",
        "content": {
            "text": "NEW Updated post content"
        },
        "media": ["url string here"],
        "type": "normal",
        "visibility": "private",
        "author": {
            "vanity": {
                "display_photo": "photolink",
                "cover_photo": "photolink",
                "badges": []
            },
            "info": {
                "name": {
                    "first": "Test",
                    "last": "User"
                },
                "links": {
                    "linkedin": "",
                    "facebook": "",
                    "instagram": "",
                    "other": []
                },
                "username": "@testuser",
                "batchid": "123",
                "program": "BSCS-ST",
                "bio": "Test bio"
            },
            "_id": "67bf5d822d93557c2e6aee28"
        },
        "__v": 0
    }
}

DELETE /post/:id

  • deletes a specific post, given the post _id path parameter

Request:

curl -X DELETE localhost:3000/post/normal/<post-id> -H "Authorization: Bearer <token>"

Response:

{
    "status": "success",
    "message": "Post deleted successfully."
}

GET /post/search

  • Searches for posts across title, content, and hashtags
  • Requires JWT session token as Authorization: Bearer <JWT> header
  • Returns posts that match the search criteria and are visible to the user

Query Parameters:

  • query (required - Search term to look for in post titles, content, and hashtags
  • type (optional) - Filter by post type (normal, project, or event)
  • visibility (optional) - Filter by post visibility (public, organization, or private)
  • limit (optional) - Maximum number of results to return (default: 10)

Request:

### Basic search (defaults to limit: 10)
GET http://localhost:3000/post/search?query=test
Authorization: Bearer <token>

### Search will all filters
# ---> this searches 15 posts matching:
# 1. posts marked as type: normal, visibility: public
# 2. has "test" in any of the Post's title, content.text, hashtags
GET http://localhost:3000/post/search?query=test&type=normal&visibility=public&limit=15
Authorization: Bearer <token>

Request (via curl):

# Basic search (defaults to limit: 10)
curl -X GET "localhost:3000/post/search?query=test" \
-H "Authorization: Bearer <token>"

# Search with all filters
curl -X GET "localhost:3000/post/search?query=test&type=normal&visibility=public&limit=15" \
-H "Authorization: Bearer <token>"

Response:

// Search with query='sigma'
{
  "status": "success",
  "count": 1,
  "posts": [
    {
      "meta": {
        "created_at": "2025-03-09T06:55:49.359Z",
        "updated_at": "2025-03-09T06:55:49.359Z"
      },
      "_id": "67cd3b750ddeeaa2a76f833f",
      "content": {
        "text": "what the sigma #boy"
      },
      "media": [],
      "type": "normal",
      "visibility": "public",
      "author": {
        "vanity": {
          "badges": []
        },
        "info": {
          "name": {
            "first": "Sean Denzel",
            "last": "Robenta"
          },
          "links": {
            "other": []
          },
          "username": "@zelkim",
          "batchid": "123",
          "program": "BS Computer Science Major in Software Technology",
          "bio": "titrebio"
        },
        "_id": "67cd35870ddeeaa2a76f82f0"
      },
      "hashtags": [
        {
          "tag": "#boy",
          "_id": "67cd3b750ddeeaa2a76f8340"
        }
      ],
      "__v": 2,
      "comments": [
        {
          "meta": {
            "created_at": "2025-03-09T12:30:54.795Z",
            "updated_at": "2025-03-09T12:30:54.795Z"
          },
          "_id": "67cd89fe21009c70077678e6",
          "author": {
            "vanity": {
              "badges": [],
              "cover_photo": "https://new-photo-url.com/cover.jpg",
              "display_photo": "https://new-photo-url.com/photo.jpg"
            },
            "info": {
              "name": {
                "first": "w2",
                "last": "helloworld"
              },
              "links": {
                "other": [
                  "https://github.com/updated"
                ],
                "linkedin": "https://linkedin.com/in/newprofile",
                "facebook": "https://facebook.com/updated",
                "instagram": "https://instagram.com/updated"
              },
              "username": "@w2helloworld",
              "batchid": "123",
              "program": "BSIT",
              "bio": "Updated bio text"
            },
            "_id": "67c8478d8e9f541dfe96893e"
          },
          "content": "test comment",
          "post": "67cd3b750ddeeaa2a76f833f",
          "reactions": [],
          "__v": 0
        }
      ],
      "reactions": []
    }
  ]
}


// Search with all filters response
{
  "status": "success",
  "count": 3,
  "posts": [
    {
      "meta": {
        "created_at": "2025-03-09T12:01:01.702Z",
        "updated_at": "2025-03-09T12:01:01.703Z"
      },
      "_id": "67cd82fd7ee3f662874eea5c",
      "title": "POST2 w2helloworld normal",
      "content": {
        "text": "Testing hastag post 2 #test"
      },
      "media": [],
      "type": "normal",
      "visibility": "public",
      "author": {
        "vanity": {
          "badges": [],
          "cover_photo": "https://new-photo-url.com/cover.jpg",
          "display_photo": "https://new-photo-url.com/photo.jpg"
        },
        "info": {
          "name": {
            "first": "w2",
            "last": "helloworld"
          },
          "links": {
            "other": [
              "https://github.com/updated"
            ],
            "linkedin": "https://linkedin.com/in/newprofile",
            "facebook": "https://facebook.com/updated",
            "instagram": "https://instagram.com/updated"
          },
          "username": "@w2helloworld",
          "batchid": "123",
          "program": "BSIT",
          "bio": "Updated bio text"
        },
        "_id": "67c8478d8e9f541dfe96893e"
      },
      "comments": [],
      "hashtags": [
        {
          "tag": "#test",
          "_id": "67cd82fd7ee3f662874eea5d"
        }
      ],
      "reactions": [],
      "__v": 0
    },
    {
      "meta": {
        "created_at": "2025-03-09T09:01:07.492Z",
        "updated_at": "2025-03-09T09:01:07.492Z"
      },
      "comments": [],
      "reactions": [],
      "_id": "67cd58d32287dd04c274682d",
      "title": "POST w2helloworld normal",
      "content": {
        "text": "Testing hastag post 2 #test"
      },
      "media": [],
      "type": "normal",
      "visibility": "public",
      "author": {
        "vanity": {
          "badges": [],
          "cover_photo": "https://new-photo-url.com/cover.jpg",
          "display_photo": "https://new-photo-url.com/photo.jpg"
        },
        "info": {
          "name": {
            "first": "w2",
            "last": "helloworld"
          },
          "links": {
            "other": [
              "https://github.com/updated"
            ],
            "linkedin": "https://linkedin.com/in/newprofile",
            "facebook": "https://facebook.com/updated",
            "instagram": "https://instagram.com/updated"
          },
          "username": "@w2helloworld",
          "batchid": "123",
          "program": "BSIT",
          "bio": "Updated bio text"
        },
        "_id": "67c8478d8e9f541dfe96893e"
      },
      "hashtags": [
        {
          "tag": "#test",
          "_id": "67cd58d32287dd04c274682e"
        }
      ],
      "__v": 0
    },
    {
      "meta": {
        "created_at": "2025-03-07T06:45:57.545Z",
        "updated_at": "2025-03-07T06:45:57.545Z"
      },
      "reactions": [],
      "_id": "67ca96256d1229bbc5009f47",
      "title": "Post with hashtags 4",
      "content": {
        "text": "Testing hastag post 2#test"
      },
      "media": [],
      "type": "normal",
      "visibility": "public",
      "author": {
        "vanity": {
          "badges": [],
          "cover_photo": "https://new-photo-url.com/cover.jpg",
          "display_photo": "https://new-photo-url.com/photo.jpg"
        },
        "info": {
          "name": {
            "first": "w2",
            "last": "helloworld"
          },
          "links": {
            "other": [
              "https://github.com/updated"
            ],
            "linkedin": "https://linkedin.com/in/newprofile",
            "facebook": "https://facebook.com/updated",
            "instagram": "https://instagram.com/updated"
          },
          "username": "@w2helloworld",
          "batchid": "123",
          "program": "BSIT",
          "bio": "Updated bio text"
        },
        "_id": "67c8478d8e9f541dfe96893e"
      },
      "hashtags": [
        {
          "tag": "#test",
          "_id": "67ca96256d1229bbc5009f48"
        }
      ],
      "__v": 1,
      "comments": [
        {
          "meta": {
            "created_at": "2025-03-09T11:14:40.127Z",
            "updated_at": "2025-03-09T11:14:40.127Z"
          },
          "reactions": [],
          "_id": "67cd782026e24242b1e25f8f",
          "author": {
            "vanity": {
              "badges": []
            },
            "info": {
              "name": {
                "first": "w2helloworld123",
                "last": "YES"
              },
              "links": {
                "other": []
              },
              "username": "@w2helloworld123",
              "batchid": "123",
              "program": "BSIT"
            },
            "_id": "67ca8695962e856f3a0ccb21"
          },
          "content": "harru warudo",
          "post": "67ca96256d1229bbc5009f47",
          "__v": 0
        }
      ]
    }
  ]
}

Note

  • Search is case-insensitive
  • Results are sorted by creation date (newest first)
  • Only returns posts that the authenticated user has permission to view
  • The limit parameter must be a positive number

# Hashtag Routes

### GET /hashtag/:tag

- Searches for hashtags matching the given tag
- Requires JWT session token as `Authorization: Bearer <JWT>` header

**Request:**

```bash
curl -X GET localhost:3000/hashtag/test -H "Authorization: Bearer <token>"

Response:

[
    {
        "tag": "#test",
        "postCount": 2,
        "posts": [
            {
                "postId": "67ca905ed2ec1cc0267c90c7",
                "title": "Post with hashtags 3",
                "type": "normal",
                "visibility": "public"
            },
            {
                "postId": "67ca96256d1229bbc5009f47",
                "title": "Post with hashtags 4",
                "type": "normal",
                "visibility": "public"
            }
        ]
    }
]

Organization

Create a New Organization

Endpoint:

POST /org/

Description:

  • Creates a new organization.
  • Requires Authorization: Bearer <JWT> header

Request Body:

{
    "info": {
        "name": "Sample Organization",
        "office": "Sample Office",
        "college": "Sample College",
        "acronym": "SORG",
        "founding": "2024-03-01",
        "bio": "A sample organization for testing",
        "links": {
            "linkedin": "https://linkedin.com/sampleorg",
            "facebook": "https://facebook.com/sampleorg",
            "instagram": "https://instagram.com/sampleorg",
            "other": ["https://other-link.com"]
        }
    },
    "vanity": {
        "display_photo": "https://example.com/display.jpg",
        "cover_photo": "https://example.com/cover.jpg",
        "badges": []
    }
}

Response:

{
    "status": "ok",
    "msg": "Organization created.",
    "data": {
        "vanity": {
            "display_photo": "https://example.com/display.jpg",
            "cover_photo": "https://example.com/cover.jpg",
            "badges": []
        },
        "info": {
            "name": "Sample Organization",
            "acronym": "SORG",
            "founding": "2024-03-01T00:00:00.000Z",
            "bio": "A sample organization for testing",
            "links": {
                "linkedin": "https://linkedin.com/sampleorg",
                "facebook": "https://facebook.com/sampleorg",
                "instagram": "https://instagram.com/sampleorg",
                "other": ["https://other-link.com"]
            }
        },
        "members": [],
        "meta": {
            "created_at": "2024-03-07T06:21:18.952Z",
            "updated_at": "2024-03-07T06:21:18.952Z"
        },
        "_id": "67ca905ed2ec1cc0267c90c7"
    }
}

Get Organization by ID

Endpoint:

GET /org/:id

Response:

{
    "status": "ok",
    "data": {
        "vanity": {
            "badges": [],
            "display_photo": "https://example.com/new-display.jpg"
        },
        "info": {
            "links": {
                "other": [],
                "linkedin": "https://linkedin.com/updated",
                "facebook": "https://facebook.com/updated"
            },
            "name": "Updated Organization Name",
            "acronym": "SORG",
            "bio": "Updated organization description"
        },
        "meta": {
            "created_at": "2025-03-06T11:05:39.032Z",
            "updated_at": "2025-03-06T15:35:10.546Z"
        },
        "_id": "67c981837c12b0d3b83b702d",
        "members": ["67c9c0aec3169561f04ecf77"],
        "__v": 0
    }
}

Get Organization by Acronym

Endpoint:

GET /org/acronym/:acronym

Response: Same format as Get Organization by ID.

Update Organization

Endpoint:

PUT /org/:id

Description: Updates an existing organization. Requires authentication.

Request Body: (include only fields to update)

{
    "info": {
        "name": "Updated Organization Name",
        "acronym": "SORG",
        "bio": "Updated organization description",
        "links": {
            "linkedin": "https://linkedin.com/updated",
            "facebook": "https://facebook.com/updated"
        }
    },
    "vanity": {
        "display_photo": "https://example.com/new-display.jpg"
    }
}

Response:

{
    "status": "success",
    "organization": {
        // Updated organization object
    }
}

Delete Organization

Endpoint:

DELETE /org/:id

Description: Deletes an organization. Requires authentication.

Response:

{
    "status": "success",
    "message": "Organization deleted successfully."
}

Add Member to Organization

Endpoint:

POST /org/:orgId/members

Description: Adds the authenticated user as a member of the organization.

Request Body: (optional)

{
    "position": "MEM" // Optional: Default is "MEM"
}

Response:

{
    "status": "success",
    "member": {
        "author": "user_id",
        "org": "org_id",
        "joindate": "2024-03-07T06:21:18.952Z",
        "position": "MEM",
        "meta": {
            "created_at": "2024-03-07T06:21:18.952Z",
            "updated_at": "2024-03-07T06:21:18.952Z"
        }
    }
}

Get Organization Members

Endpoint:

GET /org/:orgId/members

Description: Gets all members of an organization. Requires authentication.

Response:

{
    "status": "success",
    "count": 1,
    "members": [
        {
            "_id": "67c9c0aec3169561f04ecf77",
            "user": {
                "vanity": {
                    "badges": []
                },
                "info": {
                    "name": {
                        "first": "w2helloworld",
                        "last": "YES"
                    },
                    "links": {
                        "other": []
                    },
                    "username": "@w2helloworld",
                    "batchid": "123",
                    "program": "BSIT"
                },
                "meta": {
                    "created_at": "2025-03-05T12:46:05.075Z",
                    "updated_at": "2025-03-05T12:46:05.075Z"
                },
                "_id": "67c8478d8e9f541dfe96893e"
            },
            "position": "MEM",
            "joindate": "2025-03-06T15:35:10.481Z",
            "meta": {
                "created_at": "2025-03-06T15:35:10.481Z",
                "updated_at": "2025-03-06T15:35:10.481Z"
            }
        }
    ]
}

Comment Routes

POST /comment/

  • Creates a new comment on a post.
  • Requires a valid session token as Authorization: Bearer <JWT> header.

Note

The post_id must be a valid ID of an existing post.

  • Request:
{
    "post_id": "60d5f9b5e813f8b5d6c4c123",
    "content": "This is a test comment."
}

Request (via curl):

curl -X POST localhost:3000/comment/ \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer <JWT>" \
     -d '{"post_id": "60d5f9b5e813f8b5d6c4c123", "content": "This is a test comment."}'

Response:

{
    "status": "ok",
    "msg": "Comment created.",
    "data": {
        "author": "user_id",
        "post": "60d5f9b5e813f8b5d6c4c123",
        "content": "This is a test comment.",
        "_id": "comment_id",
        "createdAt": "2025-03-09T12:00:00Z"
    }
}

GET /comment/post/:postid

  • Retrieves all comments associated with a specific post.
  • Requires a valid session token.
  • Request:
curl -X GET localhost:3000/comment/post/60d5f9b5e813f8b5d6c4c123 \
     -H "Authorization: Bearer <JWT>"

Response:

{
    "status": "ok",
    "data": [
        {
            "author": "user_id",
            "post": "60d5f9b5e813f8b5d6c4c123",
            "content": "This is a test comment.",
            "_id": "comment_id",
            "createdAt": "2025-03-09T12:00:00Z"
        }
    ]
}

GET /comment/user/:userid

  • Retrieves all comments made by a specific user.
  • Requires a valid session token.
  • Request:
curl -X GET localhost:3000/comment/user/user_id \
     -H "Authorization: Bearer <JWT>"

Response:

{
    "status": "ok",
    "data": [
        {
            "post": "60d5f9b5e813f8b5d6c4c123",
            "content": "This is a test comment.",
            "_id": "comment_id",
            "createdAt": "2025-03-09T12:00:00Z"
        }
    ]
}

GET /comment/:commentid

  • Retrieves a specific comment by its ID.
  • Requires a valid session token.
  • Request:
curl -X GET localhost:3000/comment/comment_id \
     -H "Authorization: Bearer <JWT>"

Response:

{
    "status": "ok",
    "data": {
        "post": "60d5f9b5e813f8b5d6c4c123",
        "content": "This is a test comment.",
        "_id": "comment_id",
        "createdAt": "2025-03-09T12:00:00Z"
    }
}

PUT /comment/:commentid

  • Updates a specific comment.
  • Requires a valid session token.
  • Request:
{
    "content": "Updated comment content."
}

Request (via curl):

curl -X PUT localhost:3000/comment/comment_id \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer <JWT>" \
     -d '{"content": "Updated comment content."}'

Response:

{
    "status": "ok",
    "msg": "Comment updated.",
    "data": {
        "post": "60d5f9b5e813f8b5d6c4c123",
        "content": "Updated comment content.",
        "_id": "comment_id",
        "updatedAt": "2025-03-09T12:05:00Z"
    }
}

DELETE /comment/:commentid

  • Deletes a specific comment.
  • Requires a valid session token.
  • Request:
curl -X DELETE localhost:3000/comment/comment_id \
     -H "Authorization: Bearer <JWT>"

Response:

{
    "status": "ok",
    "msg": "Comment deleted."
}

Reaction Routes

POST /reaction/post

  • Adds a reaction to a post.
  • Requires a valid session token as Authorization: Bearer <JWT> header.
  • Allowed reactions: ❤️, 👏, 😂, 😢, 😡

Request

{
    "postid": "60d5f9b5e813f8b5d6c4c123",
    "reaction": "❤️"
}

Response

{
    "message": "Reaction added.",
    "newReaction": {
        "user": "user_id",
        "target": "60d5f9b5e813f8b5d6c4c123",
        "type": "❤️",
        "_id": "reaction_id"
    }
}

DELETE /reaction/post

  • Removes a reaction from a post.
  • Requires a valid session token.

Request

{
    "postid": "60d5f9b5e813f8b5d6c4c123"
}

Response

{
    "message": "Reaction removed."
}

PUT /reaction/post

  • Updates an existing reaction on a post.
  • Requires a valid session token.
  • Allowed reactions: ❤️, 👏, 😂, 😢, 😡

Request

{
    "postid": "60d5f9b5e813f8b5d6c4c123",
    "reaction": "👏"
}

Response

{
    "message": "Reaction updated.",
    "newReaction": {
        "user": "user_id",
        "target": "60d5f9b5e813f8b5d6c4c123",
        "type": "👏",
        "_id": "reaction_id"
    }
}

POST /reaction/comment

  • Adds a reaction to a comment.
  • Requires a valid session token.
  • Allowed reactions: ❤️, 👏, 😂, 😢, 😡

Request

{
    "commentid": "60d5f9b5e813f8b5d6c4c456",
    "reaction": "😂"
}

Response

{
    "message": "Reaction added.",
    "newReaction": {
        "user": "user_id",
        "target": "60d5f9b5e813f8b5d6c4c456",
        "type": "😂",
        "_id": "reaction_id"
    }
}

DELETE /reaction/comment

  • Removes a reaction from a comment.
  • Requires a valid session token.

Request

{
    "commentid": "60d5f9b5e813f8b5d6c4c456"
}

Response

{
    "message": "Reaction removed."
}

PUT /reaction/comment

  • Updates an existing reaction on a comment.
  • Requires a valid session token.
  • Allowed reactions: ❤️, 👏, 😂, 😢, 😡

Request

{
    "commentid": "60d5f9b5e813f8b5d6c4c456",
    "reaction": "😢"
}

Response

{
    "message": "Reaction updated.",
    "newReaction": {
        "user": "user_id",
        "target": "60d5f9b5e813f8b5d6c4c456",
        "type": "😢",
        "_id": "reaction_id"
    }
}

Notes:

  • The reaction field must be one of the predefined values in ReactionType: ❤️, 👏, 😂, 😢, 😡.
  • Invalid reaction types will result in an error.

Badge Routes

  • Badges require the following fields:
  • badge_type: user or organization
  • badge_key: string
  • main_text_color: valid hex code (string)
  • sub_text_color: valid hex code (string)
  • main_color: valid hex code (string)
  • sub_color: valid hex code (string)
  • main_title: string
  • sub_title: string
  • badge_expiry: date (optional)

Get API endpoints

  • These are the API endpoints for getting badges.

GET /badge/:id

  • Gets the badge information of the given badge id

Response

{
	"_id": "67dc390ff39de3835941e5c2",
	"badge_type": "user",
	"badge_key": "GDSCMKT",
	"main_text_color": "#fff",
	"sub_text_color": "#FFFFFF",
	"main_title": "GDSC",
	"main_color": "#FFCD05",
	"sub_title": "MKT",
	"sub_color": "#313131",
	"badge_expiry": null,
	"__v": 0
}

GET /badge

  • Gets all the badges in the collection, and sends it back as an array

Response

[
	{
		"_id": "67da9403738958467c01258d",
		"badge_type": "organization",
		"badge_key": "CSO#2",
		"text_color": "#AAFFB7",
		"main_title": "CSO",
		"main_color": "#007D3F",
		"sub_title": "#2",
		"sub_color": "#CDCDCD",
		"badge_expiry": null,
		"__v": 0
	},
	{
		"_id": "67da9425738958467c01258f",
		"badge_type": "user",
		"badge_key": "CCS123",
		"text_color": "#ffffff",
		"main_title": "CCS",
		"main_color": "#ff4c27",
		"sub_title": "123",
		"sub_color": "#ff7f64",
		"badge_expiry": "2025-06-06T00:00:00.000Z",
		"__v": 0
	},
	{
		"_id": "67da9449738958467c012591",
		"badge_type": "organization",
		"badge_key": "LSCSVP",
		"text_color": "#AAFFB7",
		"main_title": "LSCS",
		"main_color": "#220088",
		"sub_title": "VP",
		"sub_color": "#313131",
		"badge_expiry": null,
		"__v": 0
	},
	{
		"_id": "67da946a738958467c012593",
		"badge_type": "user",
		"badge_key": "TLSWEB",
		"text_color": "#AAFFB7",
		"main_title": "TLS",
		"main_color": "#007D3F",
		"sub_title": "WEB",
		"sub_color": "#313131",
		"badge_expiry": null,
		"__v": 0
	}
]

POST /badge/get-by-id-array

  • Returns the badge data of the given badge ids

Request

{
	"badgeIds": [
		"67dc2c64f39de3835941e555",
		"67dc2c70f39de3835941e557",
		"67dc2c50f39de3835941e553"
	]
}

Response

[
	{
		"_id": "67dc2c50f39de3835941e553",
		"badge_type": "user",
		"badge_key": "CCS123",
		"main_text_color": "#ffffff",
		"sub_text_color": "#262626",
		"main_title": "CCS",
		"main_color": "#087830",
		"sub_title": "123",
		"sub_color": "#f5f5f5",
		"badge_expiry": "2025-06-06T00:00:00.000Z",
		"__v": 0
	},
	{
		"_id": "67dc2c64f39de3835941e555",
		"badge_type": "organization",
		"badge_key": "CSO#2",
		"main_text_color": "#AAFFB7",
		"sub_text_color": "#ffffff",
		"main_title": "CSO",
		"main_color": "#007D3F",
		"sub_title": "#2",
		"sub_color": "#CDCDCD",
		"badge_expiry": null,
		"__v": 0
	},
	{
		"_id": "67dc2c70f39de3835941e557",
		"badge_type": "user",
		"badge_key": "LSCSVP",
		"main_text_color": "#AAFFB7",
		"sub_text_color": "#ffffff",
		"main_title": "LSCS",
		"main_color": "#220088",
		"sub_title": "VP",
		"sub_color": "#313131",
		"badge_expiry": null,
		"__v": 0
	}
]

Manage Badge API endpoints

  • These are the API endpoints for the CRUD operations for badges

POST /badge

  • Creates a new badge

Request

{
	"badge_type": "user",
	"badge_key": "TLSWEB",
	"main_text_color": "#AAFFB7",
	"sub_text_color": "#FFFFFF",
	"main_title": "TLS",
	"main_color": "#007D3F",
	"sub_title": "WEB",
	"sub_color": "#313131",
    "description": "TLS Web Developer"
}

Response

{
	"status": "ok",
	"msg": "badge created",
	"data": {
		"badge_type": "user",
		"badge_key": "TLSWEB",
		"main_text_color": "#AAFFB7",
		"sub_text_color": "#FFFFFF",
		"main_title": "TLS",
		"main_color": "#007D3F",
		"sub_title": "WEB",
		"sub_color": "#313131",
		"badge_expiry": null,
		"description": "TLS Web Developer",
		"_id": "67ed3e7679c548d1406670f7",
		"__v": 0
	}
}

PUT /badge/:id

  • Updates the given badge associated with the id parameter
  • Only include fields you want to change

Request

{
	"badge_type": "user",
	"badge_key": "GDSCMKT",
	"main_text_color": "#fff",
	"sub_text_color": "#FFFFFF",
	"main_title": "GDSC",
	"main_color": "#FFCD05",
	"sub_title": "MKT",
	"sub_color": "#313131"
}

Response

{
	"status": "ok",
	"old": {
		"_id": "67ed3e7679c548d1406670f7",
		"badge_type": "user",
		"badge_key": "TLSWEB",
		"main_text_color": "#AAFFB7",
		"sub_text_color": "#FFFFFF",
		"main_title": "TLS",
		"main_color": "#007D3F",
		"sub_title": "WEB",
		"sub_color": "#313131",
		"badge_expiry": null,
		"description": "TLS Web Developer",
		"__v": 0
	},
	"updated": {
		"_id": "67ed3e7679c548d1406670f7",
		"badge_type": "user",
		"badge_key": "GDSCMKT",
		"main_text_color": "#fff",
		"sub_text_color": "#FFFFFF",
		"main_title": "GDSC",
		"main_color": "#FFCD05",
		"sub_title": "MKT",
		"sub_color": "#313131",
		"badge_expiry": null,
		"description": "TLS Web Developer",
		"__v": 0
	}
}

DELETE /badge/:id

  • Deletes the given badge associated with the id parameter

Response

{
	"_id": "67a44e5779931ba6c9c39465",
	"badge_type": "user",
	"badge_key": "CCS124",
	"text_color": "#ffffff",
	"main_title": "CCS",
	"main_color": "#ff4c27",
	"sub_title": "124",
	"sub_color": "#ff7f64",
	"badge_expiry": "2040-01-01T00:00:00.000Z",
    "description": "CCS ID 124 - Student",
	"__v": 0
}

Giving or Revoking Badges

  • These are the API endpoints for giving or revoking badges.
  • target_id is the recipient of the badge
  • badge_id is the badge to give
  • type is either user or organization

POST /badge/give-badge

  • Gives a badge to a user or organization

Request

{
	"target_id": "67ea71f937fa775f4088f17d",
	"badge_id": "67ea73ae37fa775f4088f2b9",
	"type": "user"
}

Response

{
	"status": "Successfully added badge to user",
	"user": {
		"vanity": {
			"badges": [
				"67ea73ae37fa775f4088f2b9"
			]
		},
		"info": {
			"name": {
				"first": "Bad",
				"last": "Badger"
			},
			"links": {
				"other": []
			},
			"username": "TestAccountForBadge",
			"batchid": "120",
			"program": "CSCSCS",
			"bio": ""
		},
		"meta": {
			"created_at": "2025-03-31T10:44:09.285Z",
			"updated_at": "2025-03-31T10:44:09.285Z"
		},
		"_id": "67ea71f937fa775f4088f17d",
		"credentials": "67ea71df37fa775f4088f171",
		"__v": 0
	}
}

DELETE /badge/revoke-badge

  • Revokes a badge from a given user or organization

Request

{
	"target_id": "67ecb19b8a4418423dec900e",
	"badge_id": "67ed416979c548d1406670fd",
	"type": "user"
}

Response

{
	"status": "Successfully removed badge from user",
	"user": {
		"vanity": {
			"badges": []
		},
		"info": {
			"name": {
				"first": "Bad",
				"last": "Badger"
			},
			"links": {
				"other": []
			},
			"username": "@ABern",
			"batchid": "121",
			"program": "CSST",
			"bio": ""
		},
		"meta": {
			"created_at": "2025-04-02T03:40:11.957Z",
			"updated_at": "2025-04-02T03:40:11.957Z"
		},
		"_id": "67ecb19b8a4418423dec900e",
		"credentials": "67ecb17a8a4418423dec900c",
		"__v": 0
	}
}

Password Reset API Documentation

Important

FLOW:

  1. /resetpassword/create -> create a password reset "session"
  2. frontend doesn't handle this response, as it will be sent thru email, just say "if your email is valid, you will be emailed a link"
  3. user will be sent a link thru email like: https://lasallian.me/resetpassword/67e3dd34eaa6754e71f46eae
  4. Frontend should create a view for that link, you can use the /resetpassword/validate route to validate the token
  5. Handle actual password reset through POST /resetpassword/

POST /resetpassword/create

  • Creates a password reset session for a user.
  • If the email exists, a reset link is sent.

Request

{
    "email": "user@example.com"
}

Response

{
    "message": "If your email is registered, you will be sent password reset instructions in your email."
}

Possible Errors

  • 400 Bad Request: "Email is required."
  • 429 Too Many Requests: "You can only request a password reset every 60 seconds."
  • 500 Internal Server Error: "An error occurred while processing your request."

GET /resetpassword/:id

  • Validates a password reset session.

Response

{
    "_id": "reset_token_id",
    "email": "user@example.com",
    "createdAt": "2025-03-26T12:00:00Z"
}

Possible Errors

  • 404 Not Found: "Invalid password reset instance."
  • 500 Internal Server Error: "An error occurred while validating the password reset instance."

POST /resetpassword/

  • Resets a user's password using a valid reset token.

Request

{
    "token": "reset_token_id",
    "password": "new_secure_password"
}

Response

{
    "message": "Password updated successfully."
}

Possible Errors

  • 400 Bad Request: "Incorrect parameters length."
  • 400 Bad Request: "Invalid passresettoken."
  • 404 Not Found: "Invalid Password Reset Session."
  • 500 Internal Server Error: "Internal server error."

Notes

  • Passwords are hashed using bcrypt before being stored.
  • Users can request a reset every 60 seconds.
  • Reset links expire once used.

About

A social network for Lasallians, by Lasallians. | In submission to CCAPDEV.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors