Skip to content

Commit 8ef42ed

Browse files
committed
refactor: unnecessary removed
1 parent fa649b5 commit 8ef42ed

File tree

11 files changed

+52
-79
lines changed

11 files changed

+52
-79
lines changed

api/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#Não é necessario fazer build esse dockerfile para rodar aplicação
2+
#No arquivo pod.yaml já está definido para pegar do dockerhub
3+
14
FROM python:3.9
25

36
WORKDIR /code

api/api/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
allow_headers=["Content-Type"],
1515
)
1616

17-
@app.get("/api/get/")
17+
@app.get("/feature/")
1818
async def featureGet():
1919
features = get_features()
2020
return jsonable_encoder(features)
@@ -24,12 +24,12 @@ class ResponseFeature(BaseModel):
2424
description: str
2525
coordinates: list
2626

27-
@app.post("/api/post/")
27+
@app.post("/feature/")
2828
async def featurePost(responseFeature: ResponseFeature):
2929
save_feature(responseFeature.name, responseFeature.description, responseFeature.coordinates)
3030
return {'message': 'Feature posted successfully'}
3131

32-
@app.delete("/api/delete/{idfeature}")
32+
@app.delete("/feature/{idfeature}")
3333
async def featureDelete(idfeature: int):
3434
delete_feature(idfeature)
3535
return {'message': 'Feature deleted successfully'}

frontEnd/build/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Map Feature</title>
7-
<script type="module" crossorigin src="/static/index-xbKLFoPe.js"></script>
7+
<script type="module" crossorigin src="/static/index-Bo7gbw0J.js"></script>
88
<link rel="stylesheet" crossorigin href="/static/index-D9LS3ofo.css">
99
</head>
1010
<body>
Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontEnd/nginx/default.conf

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@ server {
66
location / {
77
root /usr/share/nginx/html;
88
index index.html index.htm;
9-
10-
add_header 'Access-Control-Allow-Origin' 'api1:81, api2:82';
11-
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, OPTIONS';
12-
add_header 'Access-Control-Allow-Headers' 'Content-Type';
13-
}
14-
15-
location /api/get/ {
16-
proxy_pass http://api-balance/api/get/;
17-
}
18-
19-
location /api/post/ {
20-
proxy_pass http://api-balance/api/post/;
219
}
2210

23-
location /api/delete/ {
24-
proxy_pass http://api-balance/api/delete/;
11+
location /api/ {
12+
proxy_pass http://api-balance/feature/;
2513
}
2614

2715
error_page 500 502 503 504 /50x.html;

frontEnd/src/components/CreateFeature/index.jsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
import React, { useEffect } from 'react';
2+
import requestPostFeature from '../../requests/requestPostFeature';
23
import { useDispatch } from 'react-redux';
34
import { notAddingFeature } from '../../actions/AddingFeatureSlice';
45
import './style.css';
56

6-
export default function CreateFeature({coordinates}) {
7+
export default function CreateFeature({ coordinates }) {
78
const dispatch = useDispatch();
8-
9+
910
useEffect(() => {
1011
document.querySelector('#submitForm').addEventListener('click', (event) => {
11-
fetch('http://localhost:8000/api/post/', {
12-
method: 'POST',
13-
headers: {
14-
'Content-Type': 'application/json',
15-
},
16-
body: JSON.stringify({
17-
name: document.querySelector('#name').value,
18-
description: document.querySelector('#description').value,
19-
coordinates: coordinates,
20-
}),
21-
}).then(() => {dispatch(notAddingFeature())});
12+
requestPostFeature(document.querySelector('#name').value, document.querySelector('#description').value, coordinates).then(() => { dispatch(notAddingFeature()) });
2213
});
2314
}, []);
2415
return (
@@ -27,7 +18,7 @@ export default function CreateFeature({coordinates}) {
2718
<div className="create-feature__form">
2819
<input id="name" type="text" placeholder="Name" />
2920
<input id="description" type="text" placeholder="description" />
30-
<input id="submitForm"type="button" value="Submit" />
21+
<input id="submitForm" type="button" value="Submit" />
3122
</div>
3223
</section>
3324
)

frontEnd/src/openLayers/createLayerFeature.js

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const requestDeleteFeature = (FeatureId) => {
2-
return fetch(`http://localhost:8000/api/delete/${FeatureId}`, {
3-
method: 'DELETE',
4-
headers: {
5-
'Content-Type': 'application/json',
6-
}
7-
})
8-
.catch((error) => console.error('Error:', error));
2+
return fetch(`http://localhost:8000/api/${FeatureId}`, {
3+
method: 'DELETE',
4+
headers: {
5+
'Content-Type': 'application/json',
6+
}
7+
})
8+
.catch((error) => console.error('Error:', error));
99
}
1010
export default requestDeleteFeature;

frontEnd/src/requests/requestFeatures.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const requestFeatures = () => {
2-
return fetch('http://localhost:8000/api/get/', {
2+
return fetch('http://localhost:8000/api/', {
33
method: 'GET',
44
headers: {
55
'Content-Type': 'application/json',
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const requestPostFeature = (name, description, coordinates) => {
2+
return fetch('http://localhost:8000/api/', {
3+
method: 'POST',
4+
headers: {
5+
'Content-Type': 'application/json',
6+
},
7+
body: JSON.stringify({
8+
name: name,
9+
description: description,
10+
coordinates: coordinates,
11+
}),
12+
}).catch((error) => console.error('Error:', error));
13+
}
14+
export default requestPostFeature;

0 commit comments

Comments
 (0)