From 40f2072a2fede3aba8c89c152279a052b1922c10 Mon Sep 17 00:00:00 2001 From: Hans Tirtaputra Date: Thu, 16 Jun 2022 00:52:28 +0800 Subject: [PATCH] refactor: move submissions.feedback route to feedback route --- .../v3/forms/public-forms.feedback.routes.ts | 21 ++++++++++++---- .../api/v3/forms/public-forms.routes.ts | 3 --- ...ublic-forms.submissions.feedback.routes.ts | 25 ------------------- 3 files changed, 16 insertions(+), 33 deletions(-) delete mode 100644 src/app/routes/api/v3/forms/public-forms.submissions.feedback.routes.ts diff --git a/src/app/routes/api/v3/forms/public-forms.feedback.routes.ts b/src/app/routes/api/v3/forms/public-forms.feedback.routes.ts index ee79212066..61004ccfd2 100644 --- a/src/app/routes/api/v3/forms/public-forms.feedback.routes.ts +++ b/src/app/routes/api/v3/forms/public-forms.feedback.routes.ts @@ -1,23 +1,34 @@ import { Router } from 'express' +import * as FeedbackController from '../../../../modules/feedback/feedback.controller' import * as PublicFormController from '../../../../modules/form/public-form/public-form.controller' export const PublicFormsFeedbackRouter = Router() +/** + * @deprecated + * TODO #3964: Remove this route once we fully migrate to /:formId/submissions/:submissionId/feedback endpoint + */ +PublicFormsFeedbackRouter.route('/:formId([a-fA-F0-9]{24})/feedback').post( + PublicFormController.handleSubmitFeedback, +) + /** * Send feedback for a public form - * @route POST /:formId/feedback + * @route POST /:formId/submissions/:submissionId/feedback * @group forms - endpoints to serve forms * @param {string} formId.path.required - the form id + * @param {string} submissionId.path.required - the form submission id * @param {Feedback.model} feedback.body.required - the user's feedback * @consumes application/json * @produces application/json * @returns 200 if feedback was successfully saved * @returns 400 if form feedback was malformed and hence cannot be saved - * @returns 404 if form with formId does not exist or is private + * @returns 404 if form with formId or submissionId does not exist, or form is private * @returns 410 if form has been archived + * @returns 422 if form feedback for the submissionId has already been submitted * @returns 500 if database error occurs */ -PublicFormsFeedbackRouter.route('/:formId([a-fA-F0-9]{24})/feedback').post( - PublicFormController.handleSubmitFeedback, -) +PublicFormsFeedbackRouter.route( + '/:formId([a-fA-F0-9]{24})/submissions/:submissionId([a-fA-F0-9]{24})/feedback', +).post(FeedbackController.handleSubmitFormFeedback) diff --git a/src/app/routes/api/v3/forms/public-forms.routes.ts b/src/app/routes/api/v3/forms/public-forms.routes.ts index 98459a3bb7..a5db22e138 100644 --- a/src/app/routes/api/v3/forms/public-forms.routes.ts +++ b/src/app/routes/api/v3/forms/public-forms.routes.ts @@ -3,7 +3,6 @@ import { Router } from 'express' import { PublicFormsAuthRouter } from './public-forms.auth.routes' import { PublicFormsFeedbackRouter } from './public-forms.feedback.routes' import { PublicFormsFormRouter } from './public-forms.form.routes' -import { PublicFormSubmissionsFeedbackRouter } from './public-forms.submissions.feedback.routes' import { PublicFormsSubmissionsRouter } from './public-forms.submissions.routes' import { PublicFormsVerificationRouter } from './public-forms.verification.routes' @@ -14,5 +13,3 @@ PublicFormsRouter.use(PublicFormsFeedbackRouter) PublicFormsRouter.use(PublicFormsFormRouter) PublicFormsRouter.use(PublicFormsAuthRouter) PublicFormsRouter.use(PublicFormsVerificationRouter) -// TODO #3964: Cleanup PublicFormsFeedbackRouter once it's fully migrated to PublicFormSubmissionsFeedbackRouter -PublicFormsRouter.use(PublicFormSubmissionsFeedbackRouter) diff --git a/src/app/routes/api/v3/forms/public-forms.submissions.feedback.routes.ts b/src/app/routes/api/v3/forms/public-forms.submissions.feedback.routes.ts deleted file mode 100644 index d5dda309d3..0000000000 --- a/src/app/routes/api/v3/forms/public-forms.submissions.feedback.routes.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Router } from 'express' - -import * as FeedbackController from '../../../../modules/feedback/feedback.controller' - -export const PublicFormSubmissionsFeedbackRouter = Router() - -/** - * Send feedback for a public form - * @route POST /:formId/submissions/:submissionId/feedback - * @group forms - endpoints to serve forms - * @param {string} formId.path.required - the form id - * @param {string} submissionId.path.required - the form submission id - * @param {Feedback.model} feedback.body.required - the user's feedback - * @consumes application/json - * @produces application/json - * @returns 200 if feedback was successfully saved - * @returns 400 if form feedback was malformed and hence cannot be saved - * @returns 404 if form with formId or submissionId does not exist, or form is private - * @returns 410 if form has been archived - * @returns 422 if form feedback for the submissionId has already been submitted - * @returns 500 if database error occurs - */ -PublicFormSubmissionsFeedbackRouter.route( - '/:formId([a-fA-F0-9]{24})/submissions/:submissionId([a-fA-F0-9]{24})/feedback', -).post(FeedbackController.handleSubmitFormFeedback)