Commit 4ca0fce1 by jaymehta

contact us

1 parent 44bd4eea
......@@ -15,6 +15,7 @@
"@strapi/provider-upload-aws-s3": "^4.3.9",
"@strapi/strapi": "4.3.6",
"@strapi/utils": "^4.24.3",
"aws-sdk": "^2.1644.0",
"csv-parse": "^5.5.5",
"mysql": "^2.18.1",
"pg": "^8.8.0",
......@@ -3570,6 +3571,51 @@
"npm": ">=6.0.0"
}
},
"node_modules/@strapi/provider-upload-aws-s3/node_modules/aws-sdk": {
"version": "2.1215.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1215.0.tgz",
"integrity": "sha512-btOexIY0O2F+HhjytToaYuub2HEdLqccZSM8rbT3nrbXo7U4k4Gqi6SbMGi2a+vEpj8lY8dAuMR2lvvVs4Ib9Q==",
"dependencies": {
"buffer": "4.9.2",
"events": "1.1.1",
"ieee754": "1.1.13",
"jmespath": "0.16.0",
"querystring": "0.2.0",
"sax": "1.2.1",
"url": "0.10.3",
"util": "^0.12.4",
"uuid": "8.0.0",
"xml2js": "0.4.19"
},
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/@strapi/provider-upload-aws-s3/node_modules/uuid": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.0.0.tgz",
"integrity": "sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/@strapi/provider-upload-aws-s3/node_modules/xml2js": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
"dependencies": {
"sax": ">=0.6.0",
"xmlbuilder": "~9.0.1"
}
},
"node_modules/@strapi/provider-upload-aws-s3/node_modules/xmlbuilder": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==",
"engines": {
"node": ">=4.0"
}
},
"node_modules/@strapi/provider-upload-local": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/@strapi/provider-upload-local/-/provider-upload-local-4.3.6.tgz",
......@@ -4703,9 +4749,10 @@
}
},
"node_modules/aws-sdk": {
"version": "2.1215.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1215.0.tgz",
"integrity": "sha512-btOexIY0O2F+HhjytToaYuub2HEdLqccZSM8rbT3nrbXo7U4k4Gqi6SbMGi2a+vEpj8lY8dAuMR2lvvVs4Ib9Q==",
"version": "2.1644.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1644.0.tgz",
"integrity": "sha512-9DkVmQWrL766uxeag6wLbXNahwodrIvxZlh1JZ6bzMoNXLCx38GhQfdtLhCoqK7+k0c5QIzHhjPqyqwPM4ohJw==",
"hasInstallScript": true,
"dependencies": {
"buffer": "4.9.2",
"events": "1.1.1",
......@@ -4716,7 +4763,7 @@
"url": "0.10.3",
"util": "^0.12.4",
"uuid": "8.0.0",
"xml2js": "0.4.19"
"xml2js": "0.6.2"
},
"engines": {
"node": ">= 10.0.0"
......@@ -17061,18 +17108,21 @@
}
},
"node_modules/xml2js": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz",
"integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==",
"dependencies": {
"sax": ">=0.6.0",
"xmlbuilder": "~9.0.1"
"xmlbuilder": "~11.0.0"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/xmlbuilder": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==",
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
"engines": {
"node": ">=4.0"
}
......@@ -19735,6 +19785,44 @@
"requires": {
"aws-sdk": "2.1215.0",
"lodash": "4.17.21"
},
"dependencies": {
"aws-sdk": {
"version": "2.1215.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1215.0.tgz",
"integrity": "sha512-btOexIY0O2F+HhjytToaYuub2HEdLqccZSM8rbT3nrbXo7U4k4Gqi6SbMGi2a+vEpj8lY8dAuMR2lvvVs4Ib9Q==",
"requires": {
"buffer": "4.9.2",
"events": "1.1.1",
"ieee754": "1.1.13",
"jmespath": "0.16.0",
"querystring": "0.2.0",
"sax": "1.2.1",
"url": "0.10.3",
"util": "^0.12.4",
"uuid": "8.0.0",
"xml2js": "0.4.19"
}
},
"uuid": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.0.0.tgz",
"integrity": "sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw=="
},
"xml2js": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
"requires": {
"sax": ">=0.6.0",
"xmlbuilder": "~9.0.1"
}
},
"xmlbuilder": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ=="
}
}
},
"@strapi/provider-upload-local": {
......@@ -20708,9 +20796,9 @@
"integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw=="
},
"aws-sdk": {
"version": "2.1215.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1215.0.tgz",
"integrity": "sha512-btOexIY0O2F+HhjytToaYuub2HEdLqccZSM8rbT3nrbXo7U4k4Gqi6SbMGi2a+vEpj8lY8dAuMR2lvvVs4Ib9Q==",
"version": "2.1644.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1644.0.tgz",
"integrity": "sha512-9DkVmQWrL766uxeag6wLbXNahwodrIvxZlh1JZ6bzMoNXLCx38GhQfdtLhCoqK7+k0c5QIzHhjPqyqwPM4ohJw==",
"requires": {
"buffer": "4.9.2",
"events": "1.1.1",
......@@ -20721,7 +20809,7 @@
"url": "0.10.3",
"util": "^0.12.4",
"uuid": "8.0.0",
"xml2js": "0.4.19"
"xml2js": "0.6.2"
},
"dependencies": {
"uuid": {
......@@ -29932,18 +30020,18 @@
"integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q=="
},
"xml2js": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz",
"integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==",
"requires": {
"sax": ">=0.6.0",
"xmlbuilder": "~9.0.1"
"xmlbuilder": "~11.0.0"
}
},
"xmlbuilder": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ=="
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
},
"xtend": {
"version": "4.0.2",
......@@ -18,6 +18,7 @@
"@strapi/provider-upload-aws-s3": "^4.3.9",
"@strapi/strapi": "4.3.6",
"@strapi/utils": "^4.24.3",
"aws-sdk": "^2.1644.0",
"csv-parse": "^5.5.5",
"mysql": "^2.18.1",
"pg": "^8.8.0",
......
{
"kind": "collectionType",
"collectionName": "contact_uses",
"info": {
"singularName": "contact-us",
"pluralName": "contact-uses",
"displayName": "Contact us"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"number": {
"type": "string"
},
"zip": {
"type": "string"
},
"message": {
"type": "text"
}
}
}
'use strict';
/**
* contact-us controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::contact-us.contact-us');
'use strict';
/**
* contact-us router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::contact-us.contact-us');
'use strict';
/**
* contact-us service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::contact-us.contact-us');
......@@ -74,6 +74,9 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
);
const date = new Date();
// 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
console.log("ctx.request.body.data", ctx.request.body.data);
......@@ -178,7 +181,11 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
message: "Front-end directory deleted successfully",
});
} else {
ctx.send({ ok: false, dir, message: "Authentication failed, Invalid credentials!" });
ctx.send({
ok: false,
dir,
message: "Authentication failed, Invalid credentials!",
});
}
},
}));
// 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;
}
},
};
......@@ -2667,6 +2667,22 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==
aws-sdk@^2.1644.0:
version "2.1644.0"
resolved "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1644.0.tgz"
integrity sha512-9DkVmQWrL766uxeag6wLbXNahwodrIvxZlh1JZ6bzMoNXLCx38GhQfdtLhCoqK7+k0c5QIzHhjPqyqwPM4ohJw==
dependencies:
buffer "4.9.2"
events "1.1.1"
ieee754 "1.1.13"
jmespath "0.16.0"
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
util "^0.12.4"
uuid "8.0.0"
xml2js "0.6.2"
aws-sdk@2.1215.0:
version "2.1215.0"
resolved "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1215.0.tgz"
......@@ -10338,6 +10354,19 @@ xml2js@0.4.19:
sax ">=0.6.0"
xmlbuilder "~9.0.1"
xml2js@0.6.2:
version "0.6.2"
resolved "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz"
integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==
dependencies:
sax ">=0.6.0"
xmlbuilder "~11.0.0"
xmlbuilder@~11.0.0:
version "11.0.1"
resolved "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz"
integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==
xmlbuilder@~9.0.1:
version "9.0.7"
resolved "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz"
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!