@@ -1734,7 +1734,18 @@ app.post('/api/create-distance-to-campus', async (req, res) => {
17341734 }
17351735} ) ;
17361736
1737- // Endpoint to add a new folder for a user
1737+ /**
1738+ * Add Folder - Creates a new folder assigned to a specific user.
1739+ *
1740+ * @route POST /api/folders
1741+ *
1742+ * @input {string} req.body - The name of the new folder to be created
1743+ *
1744+ * @status
1745+ * - 201: Successfully created the folder
1746+ * - 400: Folder name is missing or invalid
1747+ * - 500: Error creating folder
1748+ */
17381749app . post ( '/api/folders' , authenticate , async ( req , res ) => {
17391750 try {
17401751 if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
@@ -1759,7 +1770,15 @@ app.post('/api/folders', authenticate, async (req, res) => {
17591770 }
17601771} ) ;
17611772
1762- // Endpoint to get all folders for a user
1773+ /**
1774+ * Get Folders - Fetches all folders assigned to a specific user.
1775+ *
1776+ * @route GET /api/folders
1777+ *
1778+ * @status
1779+ * - 200: Successfully retrieved folders
1780+ * - 500: Error fetching folders
1781+ */
17631782app . get ( '/api/folders' , authenticate , async ( req , res ) => {
17641783 try {
17651784 if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
@@ -1779,7 +1798,19 @@ app.get('/api/folders', authenticate, async (req, res) => {
17791798 }
17801799} ) ;
17811800
1782- // Endpoint to delete a folder by ID
1801+ /**
1802+ * Delete Folder - Deletes a folder by ID.
1803+ *
1804+ * @route DELETE /api/folders/:folderId
1805+ *
1806+ * @input {string} req.params.folderId - The ID of the folder to be deleted
1807+ *
1808+ * @status
1809+ * - 200: Successfully deleted folder
1810+ * - 403: Unauthorized to delete this folder (not the owner)
1811+ * - 404: Folder not found
1812+ * - 500: Error deleting folder
1813+ */
17831814app . delete ( '/api/folders/:folderId' , authenticate , async ( req , res ) => {
17841815 try {
17851816 if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
@@ -1805,7 +1836,19 @@ app.delete('/api/folders/:folderId', authenticate, async (req, res) => {
18051836 }
18061837} ) ;
18071838
1808- // Endpoint to rename a folder by ID
1839+ /**
1840+ * Rename Folder - Renames a folder by ID.
1841+ *
1842+ * @route PUT /api/folders/:folderId
1843+ *
1844+ * @input {string} req.params.folderId - The ID of the folder to be renamed
1845+ *
1846+ * @status
1847+ * - 200: Successfully renamed folder
1848+ * - 403: Unauthorized to rename this folder (not the owner)
1849+ * - 404: Folder not found
1850+ * - 500: Error renaming folder
1851+ */
18091852app . put ( '/api/folders/:folderId' , authenticate , async ( req , res ) => {
18101853 try {
18111854 if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
@@ -1832,7 +1875,21 @@ app.put('/api/folders/:folderId', authenticate, async (req, res) => {
18321875 }
18331876} ) ;
18341877
1835- // Endpoint to add an apartment to a folder
1878+ /**
1879+ * Add Apartment - Adds an apartment to a folder.
1880+ *
1881+ * @route POST /api/folders/:folderId/apartments
1882+ *
1883+ * @input {string} req.body - The id of the apartment to be added
1884+ * @input {string} req.params.folderId - The ID of the folder to add the apartment to
1885+ *
1886+ * @status
1887+ * - 200: Successfully added apartment to folder
1888+ * - 403: Unauthorized to modify this folder (not the owner)
1889+ * - 404: Folder not found
1890+ * - 400: Apartment already in folder
1891+ * - 500: Error adding apartment to folder
1892+ */
18361893app . post ( '/api/folders/:folderId/apartments' , authenticate , async ( req , res ) => {
18371894 try {
18381895 if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
@@ -1865,7 +1922,20 @@ app.post('/api/folders/:folderId/apartments', authenticate, async (req, res) =>
18651922 }
18661923} ) ;
18671924
1868- // Endpoint to remove an apartment from a folder
1925+ /**
1926+ * Remove Apartment - Removes an apartment from a folder.
1927+ *
1928+ * @route DELETE /api/folders/:folderId/apartments/:apartmentId
1929+ *
1930+ * @input {string} req.body - The id of the apartment to be removed
1931+ * @input {string} req.params.folderId - The ID of the folder to remove the apartment from
1932+ *
1933+ * @status
1934+ * - 200: Successfully removed apartment from folder
1935+ * - 403: Unauthorized to modify this folder (not the owner)
1936+ * - 404: Folder not found
1937+ * - 500: Error removing apartment from folder
1938+ */
18691939app . delete ( '/api/folders/:folderId/apartments/:apartmentId' , authenticate , async ( req , res ) => {
18701940 try {
18711941 if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
@@ -1893,7 +1963,19 @@ app.delete('/api/folders/:folderId/apartments/:apartmentId', authenticate, async
18931963 }
18941964} ) ;
18951965
1896- // Endpoint to get all apartments in a folder
1966+ /**
1967+ * Get Apartments in Folder - Retrieves all apartments in a specific folder.
1968+ *
1969+ * @route GET /api/folders/:folderId/apartments
1970+ *
1971+ * @input {string} req.params - The folderId of the folder to get apartments from
1972+ *
1973+ * @status
1974+ * - 200: Successfully retrieved apartments from folder
1975+ * - 403: Unauthorized to access this folder (not the owner)
1976+ * - 404: Folder not found
1977+ * - 500: Error fetching apartments from folder
1978+ */
18971979app . get ( '/api/folders/:folderId/apartments' , authenticate , async ( req , res ) => {
18981980 try {
18991981 if ( ! req . user ) throw new Error ( 'Not authenticated' ) ;
0 commit comments