From 53650cf7f699157fd90b4da7d39bf56d5a12f46e Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Thu, 24 Oct 2024 14:15:10 -0700 Subject: [PATCH] Fix old routes --- backend/api/src/app.ts | 2 + backend/api/src/old-routes.ts | 198 ++++++++++++++++++---------------- 2 files changed, 106 insertions(+), 94 deletions(-) diff --git a/backend/api/src/app.ts b/backend/api/src/app.ts index e1fce8ead7..0b38c5767b 100644 --- a/backend/api/src/app.ts +++ b/backend/api/src/app.ts @@ -10,6 +10,7 @@ import { assertUnreachable } from 'common/util/types' import { typedEndpoint } from './helpers/endpoint' import { randomString } from 'common/util/random' import { handlers } from './routes' +import { addOldRoutes } from './old-routes' export const allowCorsUnrestricted: RequestHandler = cors({}) @@ -124,3 +125,4 @@ Object.entries(handlers).forEach(([path, handler]) => { assertUnreachable(api, 'Unsupported API method') } }) +addOldRoutes(app) diff --git a/backend/api/src/old-routes.ts b/backend/api/src/old-routes.ts index b2aa92e78d..8a086a8230 100644 --- a/backend/api/src/old-routes.ts +++ b/backend/api/src/old-routes.ts @@ -58,7 +58,7 @@ import { deletechartannotation } from 'api/delete-chart-annotation' import { deletetv, settv } from './set-tv' -import { allowCorsUnrestricted, apiErrorHandler, app } from './app' +import { allowCorsUnrestricted, apiErrorHandler } from './app' import { RequestHandler } from 'express' const apiRoute = (endpoint: RequestHandler) => { @@ -69,100 +69,110 @@ const apiRoute = (endpoint: RequestHandler) => { apiErrorHandler, ] as const } -app.get('/health', ...apiRoute(health)) -app.get('/unsubscribe', ...apiRoute(unsubscribe)) -app.post('/editcomment', ...apiRoute(editcomment)) -app.post('/claimmanalink', ...apiRoute(claimmanalink)) -app.post('/creategroup', ...apiRoute(creategroup)) -app.post('/updategroup', ...apiRoute(updategroup)) -app.post('/validateIap', ...apiRoute(validateiap)) -app.post('/markallnotifications', ...apiRoute(markallnotifications)) -app.post('/updatememberrole', ...apiRoute(updatememberrole)) -app.post('/updategroupprivacy', ...apiRoute(updategroupprivacy)) -app.post('/registerdiscordid', ...apiRoute(registerdiscordid)) -app.post('/getuserisgroupmember', ...apiRoute(getuserisgroupmember)) -app.post('/completequest', ...apiRoute(completequest)) -app.post( - '/update-user-disinterest-embedding', - ...apiRoute(updateUserDisinterestEmbedding) -) -app.get('/getsupabasetoken', ...apiRoute(getsupabasetoken)) -app.post('/delete-market', ...apiRoute(deleteMarket)) -app.post('/save-topic', ...apiRoute(saveTopic)) -app.post('/boost-market', ...apiRoute(boostmarket)) -app.post('/redeem-boost', ...apiRoute(redeemboost)) +export const addOldRoutes = (app: express.Application) => { + app.get('/health', ...apiRoute(health)) + app.get('/unsubscribe', ...apiRoute(unsubscribe)) + app.post('/editcomment', ...apiRoute(editcomment)) -app.post('/createcheckoutsession', allowCorsUnrestricted, createcheckoutsession) -app.post( - '/stripewebhook', - allowCorsUnrestricted, - express.raw({ type: '*/*' }), - stripewebhook -) -app.post('/follow-topic', ...apiRoute(followtopic)) -app.post('/league-activity', ...apiRoute(leagueActivity)) -app.post('/cancel-bounty', ...apiRoute(cancelbounty)) -app.post('/edit-answer-cpmm', ...apiRoute(editanswercpmm)) -app.post('/searchgiphy', ...apiRoute(searchgiphy)) -app.post('/manachantweet', ...apiRoute(manachantweet)) -app.post('/leave-review', ...apiRoute(leavereview)) -app.post( - '/get-user-contract-metrics-with-contracts', - ...apiRoute(getusercontractmetricswithcontracts) -) -app.post('/cast-poll-vote', ...apiRoute(castpollvote)) -app.post( - '/get-similar-groups-to-contract', - ...apiRoute(getsimilargroupstocontract) -) -app.post('/follow-user', ...apiRoute(followUser)) -app.post('/report', ...apiRoute(report)) + app.post('/claimmanalink', ...apiRoute(claimmanalink)) + app.post('/creategroup', ...apiRoute(creategroup)) + app.post('/updategroup', ...apiRoute(updategroup)) + app.post('/validateIap', ...apiRoute(validateiap)) + app.post('/markallnotifications', ...apiRoute(markallnotifications)) + app.post('/updatememberrole', ...apiRoute(updatememberrole)) + app.post('/updategroupprivacy', ...apiRoute(updategroupprivacy)) + app.post('/registerdiscordid', ...apiRoute(registerdiscordid)) + app.post('/getuserisgroupmember', ...apiRoute(getuserisgroupmember)) + app.post('/completequest', ...apiRoute(completequest)) + app.post( + '/update-user-disinterest-embedding', + ...apiRoute(updateUserDisinterestEmbedding) + ) + app.get('/getsupabasetoken', ...apiRoute(getsupabasetoken)) + app.post('/delete-market', ...apiRoute(deleteMarket)) + app.post('/save-topic', ...apiRoute(saveTopic)) + app.post('/boost-market', ...apiRoute(boostmarket)) + app.post('/redeem-boost', ...apiRoute(redeemboost)) -app.post('/settv', ...apiRoute(settv)) -app.post('/deletetv', ...apiRoute(deletetv)) + app.post( + '/createcheckoutsession', + allowCorsUnrestricted, + createcheckoutsession + ) + app.post( + '/stripewebhook', + allowCorsUnrestricted, + express.raw({ type: '*/*' }), + stripewebhook + ) + app.post('/follow-topic', ...apiRoute(followtopic)) + app.post('/league-activity', ...apiRoute(leagueActivity)) + app.post('/cancel-bounty', ...apiRoute(cancelbounty)) + app.post('/edit-answer-cpmm', ...apiRoute(editanswercpmm)) + app.post('/searchgiphy', ...apiRoute(searchgiphy)) + app.post('/manachantweet', ...apiRoute(manachantweet)) + app.post('/leave-review', ...apiRoute(leavereview)) + app.post( + '/get-user-contract-metrics-with-contracts', + ...apiRoute(getusercontractmetricswithcontracts) + ) + app.post('/cast-poll-vote', ...apiRoute(castpollvote)) + app.post( + '/get-similar-groups-to-contract', + ...apiRoute(getsimilargroupstocontract) + ) + app.post('/follow-user', ...apiRoute(followUser)) + app.post('/report', ...apiRoute(report)) -app.post('/createdashboard', ...apiRoute(createdashboard)) -app.post('/getyourdashboards', ...apiRoute(getyourdashboards)) -app.post('/followdashboard', ...apiRoute(followdashboard)) -app.post('/supabasesearchdashboards', ...apiRoute(supabasesearchdashboards)) -app.post('/getyourfolloweddashboards', ...apiRoute(getyourfolloweddashboards)) -app.post('/updatedashboard', ...apiRoute(updatedashboard)) -app.post('/delete-dashboard', ...apiRoute(deletedashboard)) -app.get('/get-news-dashboards', ...apiRoute(getnews)) -app.post('/getdashboardfromslug', ...apiRoute(getdashboardfromslug)) -app.post('/ban-user', ...apiRoute(banuser)) -app.post('/create-private-user-message', ...apiRoute(createprivateusermessage)) -app.post( - '/create-private-user-message-channel', - ...apiRoute(createprivateusermessagechannel) -) -app.post( - '/leave-private-user-message-channel', - ...apiRoute(leaveprivateusermessagechannel) -) -app.post( - '/update-private-user-message-channel', - ...apiRoute(updateprivateusermessagechannel) -) -app.post('/create-lover', ...apiRoute(createlover)) -app.post('/update-lover', ...apiRoute(updatelover)) -app.post('/create-comment-on-lover', ...apiRoute(createcommentonlover)) -app.post('/hide-comment-on-lover', ...apiRoute(hidecommentonlover)) -app.post('/searchlocation', ...apiRoute(searchlocation)) -app.post('/searchnearcity', ...apiRoute(searchnearcity)) -app.post( - '/createlovecompatibilityquestion', - ...apiRoute(createlovecompatibilityquestion) -) -app.post('/create-chart-annotation', ...apiRoute(createchartannotation)) -app.post('/delete-chart-annotation', ...apiRoute(deletechartannotation)) -// Catch 404 errors - this should be the last route -app.use(allowCorsUnrestricted, (req, res) => { - res - .status(404) - .set('Content-Type', 'application/json') - .json({ - message: `The requested route '${req.path}' does not exist. Please check your URL for any misspellings or refer to app.ts`, - }) -}) + app.post('/settv', ...apiRoute(settv)) + app.post('/deletetv', ...apiRoute(deletetv)) + + app.post('/createdashboard', ...apiRoute(createdashboard)) + app.post('/getyourdashboards', ...apiRoute(getyourdashboards)) + app.post('/followdashboard', ...apiRoute(followdashboard)) + app.post('/supabasesearchdashboards', ...apiRoute(supabasesearchdashboards)) + app.post('/getyourfolloweddashboards', ...apiRoute(getyourfolloweddashboards)) + app.post('/updatedashboard', ...apiRoute(updatedashboard)) + app.post('/delete-dashboard', ...apiRoute(deletedashboard)) + app.get('/get-news-dashboards', ...apiRoute(getnews)) + app.post('/getdashboardfromslug', ...apiRoute(getdashboardfromslug)) + app.post('/ban-user', ...apiRoute(banuser)) + app.post( + '/create-private-user-message', + ...apiRoute(createprivateusermessage) + ) + app.post( + '/create-private-user-message-channel', + ...apiRoute(createprivateusermessagechannel) + ) + app.post( + '/leave-private-user-message-channel', + ...apiRoute(leaveprivateusermessagechannel) + ) + app.post( + '/update-private-user-message-channel', + ...apiRoute(updateprivateusermessagechannel) + ) + app.post('/create-lover', ...apiRoute(createlover)) + app.post('/update-lover', ...apiRoute(updatelover)) + app.post('/create-comment-on-lover', ...apiRoute(createcommentonlover)) + app.post('/hide-comment-on-lover', ...apiRoute(hidecommentonlover)) + app.post('/searchlocation', ...apiRoute(searchlocation)) + app.post('/searchnearcity', ...apiRoute(searchnearcity)) + app.post( + '/createlovecompatibilityquestion', + ...apiRoute(createlovecompatibilityquestion) + ) + app.post('/create-chart-annotation', ...apiRoute(createchartannotation)) + app.post('/delete-chart-annotation', ...apiRoute(deletechartannotation)) + // Catch 404 errors - this should be the last route + app.use(allowCorsUnrestricted, (req, res) => { + res + .status(404) + .set('Content-Type', 'application/json') + .json({ + message: `The requested route '${req.path}' does not exist. Please check your URL for any misspellings or refer to app.ts`, + }) + }) +}