Skip to content
Snippets Groups Projects
Commit 634c8db9 authored by Tayeeb Islam's avatar Tayeeb Islam
Browse files

Fixed and hidden API Keys

parent 9a9da91e
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/node_modules /node_modules
/.pnp /.pnp
.pnp.js .pnp.js
.env
# testing # testing
/coverage /coverage
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
/build /build
# misc # misc
.DS_Store .DS_Store
.env.local .env.local
.env.development.local .env.development.local
......
To run this, you must have: node To run this, you must have:
node version: v16.0.0, node version: v16.0.0,
npm version: 8.4.1, npm version: 8.4.1,
Then you must run: 'npm install', Then you must run: 'npm install',
Then run: 'node server.js', Then run: 'node server.js',
Finally run: 'npm start' Finally run: 'npm start'
Also create a .env and include a PORT number for the server and your API Keys for Brevo and OpenAI
Also visit https://cors-anywhere.herokuapp.com/corsdemo and request access to the demo version and you will get access immediately and it everything should work. Also visit https://cors-anywhere.herokuapp.com/corsdemo and request access to the demo version and you will get access immediately and it everything should work.
...@@ -18,7 +19,7 @@ In the project directory, you can run: ...@@ -18,7 +19,7 @@ In the project directory, you can run:
### `npm start` ### `npm start`
Runs the app in the development mode.\ Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser. Open [http://localhost:3000] to view it in your browser.
The page will reload when you make changes.\ The page will reload when you make changes.\
You may also see any lint errors in the console. You may also see any lint errors in the console.
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"babel-plugin-macros": "^3.1.0", "babel-plugin-macros": "^3.1.0",
"chart.js": "^4.2.1", "chart.js": "^4.2.1",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"newsapi": "^2.4.1", "newsapi": "^2.4.1",
"openai": "^3.2.1", "openai": "^3.2.1",
...@@ -7005,11 +7006,14 @@ ...@@ -7005,11 +7006,14 @@
} }
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "10.0.0", "version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
"engines": { "engines": {
"node": ">=10" "node": ">=12"
},
"funding": {
"url": "https://github.com/motdotla/dotenv?sponsor=1"
} }
}, },
"node_modules/dotenv-expand": { "node_modules/dotenv-expand": {
...@@ -15243,6 +15247,14 @@ ...@@ -15243,6 +15247,14 @@
} }
} }
}, },
"node_modules/react-scripts/node_modules/dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
"engines": {
"node": ">=10"
}
},
"node_modules/react-transition-group": { "node_modules/react-transition-group": {
"version": "4.4.5", "version": "4.4.5",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
...@@ -23270,9 +23282,9 @@ ...@@ -23270,9 +23282,9 @@
} }
}, },
"dotenv": { "dotenv": {
"version": "10.0.0", "version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ=="
}, },
"dotenv-expand": { "dotenv-expand": {
"version": "5.1.0", "version": "5.1.0",
...@@ -29130,6 +29142,13 @@ ...@@ -29130,6 +29142,13 @@
"webpack-dev-server": "^4.6.0", "webpack-dev-server": "^4.6.0",
"webpack-manifest-plugin": "^4.0.2", "webpack-manifest-plugin": "^4.0.2",
"workbox-webpack-plugin": "^6.4.1" "workbox-webpack-plugin": "^6.4.1"
},
"dependencies": {
"dotenv": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
}
} }
}, },
"react-transition-group": { "react-transition-group": {
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"babel-plugin-macros": "^3.1.0", "babel-plugin-macros": "^3.1.0",
"chart.js": "^4.2.1", "chart.js": "^4.2.1",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"newsapi": "^2.4.1", "newsapi": "^2.4.1",
"openai": "^3.2.1", "openai": "^3.2.1",
......
...@@ -3,10 +3,11 @@ const cors = require("cors"); ...@@ -3,10 +3,11 @@ const cors = require("cors");
const bodyParser = require("body-parser"); const bodyParser = require("body-parser");
const { Configuration, OpenAIApi } = require("openai"); const { Configuration, OpenAIApi } = require("openai");
const SibApiV3Sdk = require('sib-api-v3-sdk'); const SibApiV3Sdk = require('sib-api-v3-sdk');
require('dotenv').config()
// Set up OpenAI API configuration // Set up OpenAI API configuration
const config = new Configuration({ const config = new Configuration({
apiKey: "sk-2yby0adrLKDtKVxYMtEST3BlbkFJeVVXwpWS9rnBajx1adlZ", apiKey: process.env.API_KEY_OA,
}); });
// Create an instance of OpenAI API // Create an instance of OpenAI API
...@@ -42,7 +43,7 @@ res.send(completion.data.choices[0].text); ...@@ -42,7 +43,7 @@ res.send(completion.data.choices[0].text);
// Set API key for Sendinblue // Set API key for Sendinblue
const defaultClient = SibApiV3Sdk.ApiClient.instance; const defaultClient = SibApiV3Sdk.ApiClient.instance;
const apiKey = defaultClient.authentications['api-key']; const apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = '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'; apiKey.apiKey = process.env.API_KEY_SB;
// Set up endpoint to send email using Sendinblue API // Set up endpoint to send email using Sendinblue API
app.post('/send-email', async (req, res) => { app.post('/send-email', async (req, res) => {
...@@ -65,7 +66,7 @@ res.status(500).send('Error sending email'); ...@@ -65,7 +66,7 @@ res.status(500).send('Error sending email');
}); });
// Set up port to listen to incoming requests // Set up port to listen to incoming requests
const PORT = 8080; const PORT = process.env.PORT;
app.listen(PORT, () => { app.listen(PORT, () => {
console.log('Server is running on port: ${PORT}'); console.log(`Server is running on port: ${PORT}`);
}); });
\ No newline at end of file
...@@ -7,7 +7,7 @@ export const ChatgptAPI =()=> { ...@@ -7,7 +7,7 @@ export const ChatgptAPI =()=> {
const [response, setResponse] = useState(""); const [response, setResponse] = useState("");
// Define the API endpoint for the Chatbot API // Define the API endpoint for the Chatbot API
const HTTP = "http://localhost:8080/chat"; const HTTP = "http://localhost:3000/chat";
// Handle form submission // Handle form submission
const handleSubmit = (e) => { const handleSubmit = (e) => {
......
...@@ -23,7 +23,7 @@ const Contact = () => { ...@@ -23,7 +23,7 @@ const Contact = () => {
try { try {
// Send a POST request to the server with the form data // Send a POST request to the server with the form data
const response = await axios.post( const response = await axios.post(
"http://localhost:8080/send-email", "http://localhost:3000/send-email",
data data
); );
// Display a success message and reset the form // Display a success message and reset the form
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment