Skip to content

Commit

Permalink
feat: remove get/set for msgSrvcName, remove aws ssm
Browse files Browse the repository at this point in the history
  • Loading branch information
KenLSM committed Nov 22, 2024
1 parent d9651f9 commit a9139cc
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 92 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ services:
depends_on:
- backend
environment:
- SERVICES=s3,sqs,secretsmanager
- SERVICES=s3,sqs
- DNS_ADDRESS=0
- EXTRA_CORS_ALLOWED_ORIGINS=http://localhost:5173
volumes:
Expand Down
34 changes: 0 additions & 34 deletions src/app/models/__tests__/form.server.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2971,39 +2971,5 @@ describe('Form Model', () => {
)
})
})

describe('updateMsgSrvcName', () => {
const MOCK_MSG_SRVC_NAME = 'mockTwilioName'
it('should update msgSrvcName of form to new msgSrvcName', async () => {
// Arrange
const form = await Form.create({
admin: populatedAdmin._id,
title: 'mock mobile form',
})

// Act
const updatedForm = await form.updateMsgSrvcName(MOCK_MSG_SRVC_NAME)
// Assert
expect(updatedForm?.msgSrvcName).toBe(MOCK_MSG_SRVC_NAME)
})
})

describe('deleteMsgSrvcName', () => {
const MOCK_MSG_SRVC_NAME = 'mockTwilioName'
it('should delete msgSrvcName of form', async () => {
// Arrange
const form = await Form.create({
admin: populatedAdmin._id,
title: 'mock mobile form',
msgSrvcName: MOCK_MSG_SRVC_NAME,
})

// Act
const updatedForm = await form.deleteMsgSrvcName()

// Assert
expect(updatedForm?.msgSrvcName).toBeUndefined()
})
})
})
})
19 changes: 3 additions & 16 deletions src/app/models/form.server.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ const compileFormModel = (db: Mongoose): IFormModel => {
},
},

/**
* @deprecated Twilio is no longer supported as we have moved the functionality to postman-sms
*/
msgSrvcName: {
// Name of credentials for messaging service, stored in secrets manager
type: String,
Expand Down Expand Up @@ -803,22 +806,6 @@ const compileFormModel = (db: Mongoose): IFormModel => {
return this.save()
}

FormSchema.methods.updateMsgSrvcName = async function (
msgSrvcName: string,
session?: ClientSession,
) {
this.msgSrvcName = msgSrvcName

return this.save({ session })
}

FormSchema.methods.deleteMsgSrvcName = async function (
session?: ClientSession,
) {
this.msgSrvcName = undefined
return this.save({ session })
}

const FormDocumentSchema = FormSchema as unknown as Schema<IFormDocument>

FormDocumentSchema.methods.getDashboardView = function (
Expand Down
8 changes: 1 addition & 7 deletions src/app/modules/form/admin-form/admin-form.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SecretsManager } from 'aws-sdk'
import { PresignedPost } from 'aws-sdk/clients/s3'
import { assignIn, last, omit, pick } from 'lodash'
import mongoose, { ClientSession } from 'mongoose'
Expand Down Expand Up @@ -60,7 +59,7 @@ import {
IPopulatedUser,
} from '../../../../types'
import { EditFormFieldParams, FormUpdateParams } from '../../../../types/api'
import config, { aws as AwsConfig } from '../../../config/config'
import { aws as AwsConfig } from '../../../config/config'
import { createLoggerWithLabel } from '../../../config/logger'
import getAgencyModel from '../../../models/agency.server.model'
import getFormModel from '../../../models/form.server.model'
Expand Down Expand Up @@ -120,11 +119,6 @@ const WorkspaceModel = getWorkspaceModel(mongoose)
const FormWhitelistedSubmitterIdsModel =
getFormWhitelistSubmitterIdsModel(mongoose)

export const secretsManager = new SecretsManager({
region: config.aws.region,
endpoint: process.env.AWS_ENDPOINT,
})

type PresignedPostUrlParams = {
fileId: string
fileMd5Hash: string
Expand Down
18 changes: 0 additions & 18 deletions src/app/modules/form/admin-form/admin-form.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ import {
DatabasePayloadSizeError,
DatabaseValidationError,
MalformedParametersError,
SecretsManagerConflictError,
SecretsManagerError,
SecretsManagerNotFoundError,
} from '../../core/core.errors'
import { ErrorResponseData } from '../../core/core.types'
import { InvalidPaymentAmountError } from '../../payments/payments.errors'
Expand Down Expand Up @@ -155,21 +152,6 @@ export const mapRouteError = (
statusCode: StatusCodes.INTERNAL_SERVER_ERROR,
errorMessage: coreErrorMessage ?? error.message,
}
case SecretsManagerNotFoundError:
return {
statusCode: StatusCodes.NOT_FOUND,
errorMessage: coreErrorMessage ?? error.message,
}
case SecretsManagerConflictError:
return {
statusCode: StatusCodes.CONFLICT,
errorMessage: coreErrorMessage ?? error.message,
}
case SecretsManagerError:
return {
statusCode: StatusCodes.INTERNAL_SERVER_ERROR,
errorMessage: coreErrorMessage ?? error.message,
}
case StripeAccountError:
return {
statusCode: StatusCodes.BAD_GATEWAY,
Expand Down
16 changes: 0 additions & 16 deletions src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,6 @@ export interface IFormSchema extends IForm, Document, PublicView<PublicForm> {
getDuplicateParams(
overrideProps: OverrideProps,
): PickDuplicateForm & OverrideProps

/**
* Updates the msgSrvcName of the form with the specified msgSrvcName
* @param msgSrvcName msgSrvcName to update the Form docuemnt with
* @param session transaction session in which update operation is a part of
*/
updateMsgSrvcName(
msgSrvcName: string,
session?: ClientSession,
): Promise<IFormSchema>

/**
* Deletes the msgSrvcName of the form
* @param session transaction session in which delete operation is a part of
*/
deleteMsgSrvcName(session?: ClientSession): Promise<IFormSchema>
}

/**
Expand Down

0 comments on commit a9139cc

Please sign in to comment.