Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(routes): prevent server crash
Browse files Browse the repository at this point in the history
kishore03109 committed Feb 26, 2024
1 parent 6a1ac28 commit 373203d
Showing 28 changed files with 96 additions and 5 deletions.
1 change: 0 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ services:
- .env
volumes:
- ./:/opt/isomercms-backend
- /opt/isomercms-backend/node_modules
- ${EFS_VOL_PATH}:${EFS_VOL_PATH}
- "~/.gitconfig:/etc/gitconfig"

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"start": "node --unhandled-rejections=warn -r ts-node/register/transpile-only -r tsconfig-paths/register -r dotenv/config build/server.js dotenv_config_path=/efs/isomer/.isomer.env",
"start:ecs:prod": "node --unhandled-rejections=warn -r ts-node/register/transpile-only -r tsconfig-paths/register src/server.js",
"start:ecs:staging": "node --unhandled-rejections=warn -r ts-node/register/transpile-only -r tsconfig-paths/register src/server.js",
"start::ecs:dev": "ts-node-dev --respawn src/server.js",
"start:ecs:dev": "ts-node-dev --respawn src/server.js",
"dev": "source .env && docker compose -f docker-compose.dev.yml up",
"test:docker": "docker run -d -p 54321:5432 --name postgres -e POSTGRES_USER=isomer -e POSTGRES_PASSWORD=password -e POSTGRES_DB=isomercms_test postgres:latest",
"test": "source .env.test && jest --runInBand",
4 changes: 4 additions & 0 deletions src/routes/formsg/formsgGGsRepair.ts
Original file line number Diff line number Diff line change
@@ -257,6 +257,10 @@ ${syncedRepos.map((repo) => `<li>${repo}</li>`)}
this.getGGsRepairFormSubmission
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/formsg/formsgSiteCreation.ts
Original file line number Diff line number Diff line change
@@ -183,6 +183,10 @@ export class FormsgSiteCreateRouter {
this.formsgCreateSite
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/formsg/formsgSiteLaunch.ts
Original file line number Diff line number Diff line change
@@ -349,6 +349,10 @@ export class FormsgSiteLaunchRouter {
this.handleSiteLaunchFormRequest
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/auth.js
Original file line number Diff line number Diff line change
@@ -144,6 +144,10 @@ class AuthRouter {
attachReadRouteHandlerWrapper(this.whoami)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticated/collaborators.ts
Original file line number Diff line number Diff line change
@@ -175,6 +175,10 @@ export class CollaboratorsRouter {
attachReadRouteHandlerWrapper(this.getCollaboratorsStatistics)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/authenticated/index.js
Original file line number Diff line number Diff line change
@@ -76,6 +76,9 @@ const getAuthenticatedSubrouter = ({
authenticatedSubrouter.use("/user", usersRouter.getRouter())
authenticatedSubrouter.use("/netlify-toml", netlifyTomlV2Router.getRouter())

authenticatedSubrouter.use((_req, res, next) => {
next()
})
return authenticatedSubrouter
}

4 changes: 4 additions & 0 deletions src/routes/v2/authenticated/metrics.ts
Original file line number Diff line number Diff line change
@@ -43,6 +43,10 @@ export class MetricsRouter {
const router = express.Router({ mergeParams: true })

router.post("/feedback", this.collateUserFeedback)

router.use((_req, res, next) => {
next()
})
return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticated/netlifyToml.js
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ class NetlifyTomlRouter {

router.get("/", attachReadRouteHandlerWrapper(this.readNetlifyToml))

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticated/notifications.ts
Original file line number Diff line number Diff line change
@@ -100,6 +100,10 @@ export class NotificationsRouter {
attachWriteRouteHandlerWrapper(this.markNotificationsAsRead)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticated/review.ts
Original file line number Diff line number Diff line change
@@ -1408,6 +1408,10 @@ export class ReviewsRouter {
attachReadRouteHandlerWrapper(this.closeReviewRequest)
)
router.get("/:requestId/blob", attachReadRouteHandlerWrapper(this.getBlob))

router.use((_req, res, next) => {
next()
})
return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticated/sites.ts
Original file line number Diff line number Diff line change
@@ -254,6 +254,10 @@ export class SitesRouter {
// and endpoint can be changed to GET.
router.post("/preview", attachReadRouteHandlerWrapper(this.getPreviewInfo))

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticated/users.ts
Original file line number Diff line number Diff line change
@@ -132,6 +132,10 @@ export class UsersRouter {
attachReadRouteHandlerWrapper(this.verifyMobileNumberOtp)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/authenticatedSites/collectionPages.js
Original file line number Diff line number Diff line change
@@ -224,6 +224,9 @@ class CollectionPagesRouter {
attachRollbackRouteHandlerWrapper(this.deleteCollectionPage)
)

router.use((_req, res, next) => {
next()
})
return router
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/authenticatedSites/collections.js
Original file line number Diff line number Diff line change
@@ -271,6 +271,9 @@ class CollectionsRouter {
attachRollbackRouteHandlerWrapper(this.moveCollectionDirectoryPages)
)

router.use((_req, res, next) => {
next()
})
return router
}
}
4 changes: 3 additions & 1 deletion src/routes/v2/authenticatedSites/contactUs.js
Original file line number Diff line number Diff line change
@@ -54,7 +54,9 @@ class ContactUsRouter {

router.get("/", attachReadRouteHandlerWrapper(this.readContactUs))
router.post("/", attachRollbackRouteHandlerWrapper(this.updateContactUs))

router.use((_req, res, next) => {
next()
})
return router
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/authenticatedSites/homepage.js
Original file line number Diff line number Diff line change
@@ -59,6 +59,9 @@ class HomepageRouter {
router.get("/", attachReadRouteHandlerWrapper(this.readHomepage))
router.post("/", attachRollbackRouteHandlerWrapper(this.updateHomepage))

router.use((_req, res, next) => {
next()
})
return router
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/authenticatedSites/index.js
Original file line number Diff line number Diff line change
@@ -240,6 +240,9 @@ const getAuthenticatedSitesSubrouter = ({
authenticatedSitesSubrouter.use("/settings", settingsV2Router.getRouter())
authenticatedSitesSubrouter.use("/admin", repoManagementV2Router.getRouter())
authenticatedSitesSubrouter.use(notificationOnEditHandler.createNotification)
authenticatedSitesSubrouter.use((_req, res, next) => {
next()
})

return authenticatedSitesSubrouter
}
5 changes: 5 additions & 0 deletions src/routes/v2/authenticatedSites/media.ts
Original file line number Diff line number Diff line change
@@ -83,6 +83,7 @@ export class MediaRouter {
{ page: number; limit: number; search: string },
{ userWithSiteSessionData: UserWithSiteSessionData }
> = async (req, res) => {
console.log("in listMediaDirectoryFiles")
const { userWithSiteSessionData } = res.locals

const { directoryName } = req.params
@@ -445,6 +446,10 @@ export class MediaRouter {
attachRollbackRouteHandlerWrapper(this.deleteMediaFile)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 3 additions & 1 deletion src/routes/v2/authenticatedSites/navigation.js
Original file line number Diff line number Diff line change
@@ -53,7 +53,9 @@ class NavigationRouter {

router.get("/", attachReadRouteHandlerWrapper(this.readNavigation))
router.post("/", attachRollbackRouteHandlerWrapper(this.updateNavigation))

router.use((_req, res, next) => {
next()
})
return router
}
}
4 changes: 3 additions & 1 deletion src/routes/v2/authenticatedSites/repoManagement.ts
Original file line number Diff line number Diff line change
@@ -65,7 +65,9 @@ export class RepoManagementRouter {
router.use(this.authorizationMiddleware.verifySiteMember)

router.post("/resetRepo", attachWriteRouteHandlerWrapper(this.resetRepo))

router.use((_req, res, next) => {
next()
})
return router
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/authenticatedSites/resourceCategories.js
Original file line number Diff line number Diff line change
@@ -142,6 +142,9 @@ class ResourceCategoriesRouter {
attachRollbackRouteHandlerWrapper(this.moveResourceDirectoryPages)
)

router.use((_req, res, next) => {
next()
})
return router
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/authenticatedSites/resourcePages.js
Original file line number Diff line number Diff line change
@@ -144,6 +144,9 @@ class ResourcePagesRouter {
"/:pageName",
attachRollbackRouteHandlerWrapper(this.deleteResourcePage)
)
router.use((_req, res, next) => {
next()
})

return router
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticatedSites/resourceRoom.js
Original file line number Diff line number Diff line change
@@ -125,6 +125,10 @@ class ResourceRoomRouter {
attachRollbackRouteHandlerWrapper(this.deleteResourceRoomDirectory)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticatedSites/settings.js
Original file line number Diff line number Diff line change
@@ -139,6 +139,10 @@ class SettingsRouter {
attachWriteRouteHandlerWrapper(this.updateRepoPassword)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/authenticatedSites/unlinkedPages.js
Original file line number Diff line number Diff line change
@@ -175,6 +175,10 @@ class UnlinkedPagesRouter {
attachRollbackRouteHandlerWrapper(this.moveUnlinkedPages)
)

router.use((_req, res, next) => {
next()
})

return router
}
}
4 changes: 4 additions & 0 deletions src/routes/v2/sgidAuth.ts
Original file line number Diff line number Diff line change
@@ -251,6 +251,10 @@ export class SgidAuthRouter {
attachReadRouteHandlerWrapper(this.handleSgidMultiuserLogin)
)

router.use((_req, res, next) => {
next()
})

return router
}
}

0 comments on commit 373203d

Please sign in to comment.