Skip to content

Commit

Permalink
Fix old routes
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Oct 24, 2024
1 parent fbbea6d commit 53650cf
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 94 deletions.
2 changes: 2 additions & 0 deletions backend/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({})

Expand Down Expand Up @@ -124,3 +125,4 @@ Object.entries(handlers).forEach(([path, handler]) => {
assertUnreachable(api, 'Unsupported API method')
}
})
addOldRoutes(app)
198 changes: 104 additions & 94 deletions backend/api/src/old-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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`,
})
})
}

0 comments on commit 53650cf

Please sign in to comment.