Skip to content

Commit 5d843e8

Browse files
committed
removed files, and logs
1 parent c9e2a53 commit 5d843e8

22 files changed

+108
-194
lines changed

backend/auth.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

backend/controllers/authMiddleware.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const client = jwksClient({
1111
jwksUri: `${COGNITO_ISSUER}/.well-known/jwks.json`,
1212
});
1313

14-
//function to get signing key
14+
//function to get signing key
1515
const getKey = async (header) => {
1616
try {
1717
const key = await client.getSigningKey(header.kid);
@@ -23,10 +23,10 @@ const getKey = async (header) => {
2323

2424
const authenticateToken = async (req, res, next) => {
2525
try {
26-
//grabs the first token (access token) sent in the header otherwise just returns null or undefined
26+
//grabs the first token (access token) sent in the header otherwise just returns null or undefined
2727
const token = req.headers.authorization?.split(' ')[1];
2828

29-
//if token is nonexisten, return error
29+
//if token is nonexisten, return error
3030
if (!token) {
3131
return res
3232
.status(401)

backend/controllers/loginController.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

backend/controllers/signupController.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

backend/data.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,11 @@ export const awsData = async () => {
157157
// Sends the request and waits for the response
158158
response = await client.send(command);
159159

160-
// console.log('response results', response.MetricDataResults);
161-
162160
return response; // logs the metric data and entire response if successful
163161
} catch (caught) {
164162
if (caught instanceof CloudWatchServiceException) {
165163
// if theres a CloudWatch error, it logs the error name and message
166-
// console.error(`Error from CloudWatch. ${caught.name}: ${caught.message}`);
164+
console.error(`Error from CloudWatch. ${caught.name}: ${caught.message}`);
167165
} else {
168166
throw caught; // if its a different error, it throws it so it can be handled elsewhere
169167
}
@@ -172,7 +170,7 @@ export const awsData = async () => {
172170
console.log('Inserting metrics into database...');
173171
for (const metric of response.MetricDataResults) {
174172
for (let i = 0; i < metric.Timestamps.length; i++) {
175-
console.log('Metric:', metric.Id, 'Value:', metric.Values[i]); // Debugging output
173+
// console.log('Metric:', metric.Id, 'Value:', metric.Values[i]); // Debugging output
176174

177175
const query = `
178176
INSERT INTO aws_metrics
@@ -191,7 +189,7 @@ export const awsData = async () => {
191189
await Pool.query(query, values);
192190
}
193191
}
194-
console.log('Metrics inserted successfully!');
192+
// console.log('Metrics inserted successfully!');
195193
};
196194

197195
// ✅ Correctly formatted IIFE to execute `awsData()`

backend/externalIDGenerator.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
const externalIdGenerator = () => {
22
const letters = '1234567890qwertyuiopasdfghjklzxcvbnm';
33
let result = '';
4-
5-
for (let i = 0; i < 10; i++){
4+
for (let i = 0; i < 10; i++) {
65
result += letters[Math.floor(Math.random() * 35)];
76
}
8-
9-
return result
7+
return result;
108
};
119

1210
export default externalIdGenerator;
13-
// uuid npm

backend/metrics.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const Workflow = async () => {
8888
if (!awsAccountId) {
8989
throw new Error("No AWS account found for the provided email.");
9090
}
91+
//testing Account ID
9192
console.log("AWS Account ID:", awsAccountId);
9293

9394
// Fetch the data from AWS CloudWatch

backend/modal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const client = new pg.Client({
1313
client
1414
.connect()
1515
.then(() => console.log('Connected to PostgreSQL!'))
16-
.catch((err) => console.log('uncomment below in modal'));
16+
.catch((err) => console.log('uncomment below in modal:', err));
1717
//console.error("Error connecting to PostgreSQL:", err)
1818

1919
export default client; // Export the client instance for use in other modules

backend/routes/loginRouter.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

backend/routes/signupRouter.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

backend/server.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import express from 'express';
22
import { fileURLToPath } from 'node:url';
33
import path from 'node:path';
44
import { awsData, awsHourData } from './data.js';
5-
import router from './auth.js';
6-
import loginRouter from './routes/loginRouter.js';
7-
import signupRouter from './routes/signupRouter.js';
85
import authenticateToken from './controllers/authMiddleware.js';
96
import Awsrouter from './routes/ApiRoutes.js';
107
import externalIdGenerator from './externalIDGenerator.js';
@@ -20,19 +17,13 @@ app.use(express.urlencoded({ extended: true }));
2017
app.use(express.static(path.join(__dirname, 'dist')));
2118

2219
//CAN BE DELETED, WAS ONCE A TEST ROUTER
23-
app.use('/auth', router);
2420
app.use('/aws_services', Awsrouter);
2521

2622
//TEST ROUTE, can be deleted
2723
app.get('/protected', authenticateToken, (req, res) => {
2824
res.json({ message: 'You have accessed a protected route!', user: req.user });
2925
});
3026

31-
//CAN BE DELETED
32-
// ROUTES ORIGINALLY SET UP TO SEND USER TO login or signup page
33-
// app.use('/signup', signupRouter);
34-
// app.use('/login', loginRouter);
35-
3627
//VITE CONFIG file allows for this to be just /data instead of /Home/data
3728
app.get('/data', async (req, res) => {
3829
let data = await awsHourData();
@@ -64,10 +55,6 @@ app.use((err, req, res, next) => {
6455
return res.status(errorObj.status).json(errorObj.message);
6556
});
6657

67-
68-
// app.use(express.static(path.resolve(__dirname, '../src')));
69-
70-
7158
app.listen(port, () => {
7259
console.log(`Server started at http://localhost:${port}`);
7360
});

src/Layout.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/pages/Error.jsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
function Error() {
2-
2+
return (
3+
<>
4+
<h1>This is not the page you are looking for, sorry about that.</h1>
5+
</>
6+
);
7+
}
38

4-
return (
5-
<>
6-
<h1>This is the Error page</h1>
7-
</>
8-
)
9-
}
10-
11-
export default Error
12-
9+
export default Error;

src/pages/Home.css

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/pages/Home.jsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import './Home.css';
21
import { useNavigate } from 'react-router';
32
import BarChart from './components/Barchart.jsx';
43
import LineChart from './components/Linechart.jsx';
54
import { useSelector } from 'react-redux';
6-
import DropDownMenu from './menu.jsx';
5+
import DropDownMenu from './components/menu.jsx';
76
import { useAuth } from './context/AuthContext.jsx';
87
import { useEffect } from 'react';
98

@@ -19,24 +18,24 @@ const Home = () => {
1918
signOut();
2019
};
2120

21+
//ASK JASON ABOUT THIS
2222
//SIMPLY TESTING MIDDLEWARE, To be implemented properly needs an api call to fetch current user's access token
2323
//then use that token and send it as part of the header with each request
24-
const testingMiddleware = () => {
25-
fetch('/protected', {
26-
method: 'GET',
27-
headers: {
28-
Authorization:
29-
'Bearer eyJraWQiOiI0Ym9xcFBHU2ZPVTFvS0RWRVlPS2RFYzBPcFhYXC82eEVnN0MxR0tLZitqcz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhNDc4YTQ2OC00MGMxLTcwNDAtZGZjOS01MTVkMzNiZWM5YTUiLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0xLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMV9wOUVIWHhPOTQiLCJjbGllbnRfaWQiOiIxYjUxNTV2MXQxNzZrM2FmY2o2bXM5NjRsOCIsIm9yaWdpbl9qdGkiOiJkNGI2YjJmMS0yNjlhLTQ4YjctODAwZC1hNTUyOTEyZDZkNzYiLCJldmVudF9pZCI6IjkwYmRiNjU1LTNhOWYtNGU1ZS05YWNmLWY2MzA1YjAyMGM1YiIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiYXdzLmNvZ25pdG8uc2lnbmluLnVzZXIuYWRtaW4iLCJhdXRoX3RpbWUiOjE3Mzg3OTI2OTMsImV4cCI6MTczODg3NDgwOCwiaWF0IjoxNzM4ODcxMjA4LCJqdGkiOiI5OGZkZGE2Zi0zYWMxLTQwZmItYmE2Yi1iYTg0MWQxZjIxZDUiLCJ1c2VybmFtZSI6ImE0NzhhNDY4LTQwYzEtNzA0MC1kZmM5LTUxNWQzM2JlYzlhNSJ9.VN4dRDdhh_ISefP734u4yBV5TknNb48_deExZ9HXHBwQS3lZ1J0xvsn8T2CD13Xn1H3PHoSQEIaqAP2lwyfzRfYFFOJGd5bScOWQd2Hk043MWfMGt1K3mzMTmGqz6FXHnHw9QG-jjE3jPGTn6BUvQ49u0gPB_57PrZ6fWOFAiwPlUAvC5MLLzFun6FbguwetdGfEySFuM5mRGoHPGJsDs4aKrj9GCzO5fnUket23fTzwwB4djkCsqGL6v2Vcbw-bI-9YOlYV-TOHM-fLnJ2VyYJfHBokX3BI0MIP8vzt1op8CDFzYMIrvnrs_yqVH2tOZKW-nqQSBtYIWV2CsPyd0g',
30-
'Content-Type': 'application/json',
31-
},
32-
})
33-
.then((response) => response.json())
34-
.then((data) => console.log('Response:', data))
35-
.catch((error) => console.error('Error:', error));
36-
};
24+
// const testingMiddleware = () => {
25+
// fetch('/protected', {
26+
// method: 'GET',
27+
// headers: {
28+
// Authorization:
29+
// 'Bearer ',
30+
// 'Content-Type': 'application/json',
31+
// },
32+
// })
33+
// .then((response) => response.json())
34+
// .then((data) => console.log('Response:', data))
35+
// .catch((error) => console.error('Error:', error));
36+
// };
3737

3838
const graphs = useSelector((state) => state.graphs);
39-
console.log(graphs);
4039
const newgraph = [];
4140

4241
for (let i = 0; i < graphs.graph.length; i++) {
@@ -81,12 +80,7 @@ const Home = () => {
8180
>
8281
Account
8382
</button>
84-
<a href='#' className='hover:underline'>
85-
Settings
86-
</a>
87-
<a href='#' className='hover:underline'>
88-
Recommended
89-
</a>
83+
9084
<button onClick={logOut} className='hover:underline'>
9185
Logout
9286
</button>

src/pages/menu.jsx renamed to src/pages/components/menu.jsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react';
22
import { useDispatch } from 'react-redux';
3-
import { addGraph } from '../state/graph-reducer.js';
3+
import { addGraph } from '../../state/graph-reducer.js';
44

55
export default function DropDownMenu() {
66
const dispatch = useDispatch();
77

8-
98
return (
109
<Menu as='div' className='relative inline-block text-left'>
1110
<div>
@@ -19,11 +18,18 @@ export default function DropDownMenu() {
1918
className=' absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white ring-1 shadow-lg ring-black/5 transition focus:outline-hidden data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in'
2019
>
2120
<div className='py-1 bg-purple-600'>
22-
<input id='metricBar' className='text-blue-600'></input>
21+
<input id='metricBar' className='text-blue-600'></input>
2322
<MenuItem>
2423
<button
2524
className=' text-pink-50 block px-4 py-2 text-sm text-gray-700 data-focus:bg-gray-100 data-focus:text-gray-900 data-focus:outline-hidden'
26-
onClick={() => dispatch(addGraph({ type: 'bar', metric: document.getElementById('metricBar').value }))}
25+
onClick={() =>
26+
dispatch(
27+
addGraph({
28+
type: 'bar',
29+
metric: document.getElementById('metricBar').value,
30+
})
31+
)
32+
}
2733
>
2834
Bar Graph
2935
</button>
@@ -32,7 +38,14 @@ export default function DropDownMenu() {
3238
<MenuItem>
3339
<button
3440
className='text-pink-50 block px-4 py-2 text-sm text-gray-700 data-focus:bg-gray-100 data-focus:text-gray-900 data-focus:outline-hidden'
35-
onClick={() => dispatch(addGraph({ type: 'areaLine', metric: document.getElementById('metricLine').value }))}
41+
onClick={() =>
42+
dispatch(
43+
addGraph({
44+
type: 'areaLine',
45+
metric: document.getElementById('metricLine').value,
46+
})
47+
)
48+
}
3649
>
3750
Line Graph
3851
</button>

src/pages/context/AuthContext.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export const AuthProvider = ({ children }) => {
2626
//grab userSession info
2727
currentUser.getSession((err, session) => {
2828
if (err || !session.isValid()) {
29-
console.log('not logged in testing');
3029
//if user session is not valid, set session to null
3130
setUserSession(null);
3231
} else {

0 commit comments

Comments
 (0)