Commit 362c60e6 by jaymehta

.

1 parent 4ca0fce1
...@@ -74,9 +74,6 @@ module.exports = createCoreController("api::vendor.vendor", () => ({ ...@@ -74,9 +74,6 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
); );
const date = new Date(); const date = new Date();
// TODO: Code to send OTP on email // TODO: Code to send OTP on email
const subject = `New content created: OTP testing`;
const message = `Content: ${oneTimePassword}`;
await strapi.services["api::vendor.vendor"].sns.sendEmail(subject, message);
// TODO: Code to send OTP on SMS // TODO: Code to send OTP on SMS
console.log("ctx.request.body.data", ctx.request.body.data); console.log("ctx.request.body.data", ctx.request.body.data);
......
// path: api/your-content-type/services/sns.js
const AWS = require('aws-sdk');
// Load environment variables
const { AWS_ACCESS_KEY_ID, AWS_ACCESS_SECRET, AWS_REGION, SNS_TOPIC_ARN } = process.env;
// Configure AWS SDK
AWS.config.update({
accessKeyId: AWS_ACCESS_KEY_ID,
secretAccessKey: AWS_ACCESS_SECRET,
region: AWS_REGION
});
const sns = new AWS.SNS();
module.exports = {
sendEmail: async (subject, message) => {
const params = {
Message: message,
Subject: subject,
TopicArn: SNS_TOPIC_ARN,
};
try {
const data = await sns.publish(params).promise();
console.log(`Message sent to SNS: ${data.MessageId}`);
return data;
} catch (err) {
console.error(`Error publishing to SNS: ${err.message}`);
throw err;
}
},
};
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!