Skip to content

Commit

Permalink
add -update new dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroPaino committed Jun 27, 2024
1 parent 0e34fb5 commit 41874da
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 22 deletions.
68 changes: 68 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
Expand Down
34 changes: 20 additions & 14 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import logo from './logo.svg';
import './App.css';
import React, { useEffect, useState } from 'react';
import axios from 'axios';

function App() {
const [data, setData] = useState(null);

useEffect(() => {
fetchData();
}, []);

const fetchData = () => {
axios.get('http://localhost:3000/') // Substitua pela URL correta da sua API
.then(response => {
setData(response.data);
})
.catch(error => {
console.error('Erro ao buscar dados:', error);
});
};

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
<h1>Dados Carregados</h1>
{data ? <pre>{JSON.stringify(data, null, 2)}</pre> : <p>Carregando dados...</p>}
</header>
</div>
);
Expand Down
21 changes: 13 additions & 8 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import express from 'express';
import cors from 'cors';
import { createConnection } from 'typeorm';
import incomeRoutes from './routes/incomeRoutes';
import expenseRoutes from './routes/expenseRoutes';
import userRoutes from './routes/userRoutes'; // Garanta que você tenha esse arquivo e importe corretamente.

const express = require('express');
const { createConnection } = require('typeorm');
const app = express();

app.use(express.json()); // Middleware para parsear JSON
// Configuração do CORS para aceitar requisições do frontend
app.use(cors({
origin: 'http://localhost:3000' // Substitua pela URL/porta do seu frontend se necessário
}));

// Middleware para parsear JSON
app.use(express.json());

// Configurações de rotas
app.use('/users', userRoutes);
app.use('/incomes', incomeRoutes);
app.use('/expenses', expenseRoutes);
app.use('/api/incomes', incomeRoutes);

// Estabelecer conexão com o banco de dados
createConnection().then(connection => {
// Seu banco de dados está conectado e configurado
console.log('Database connected!');

// Configurações adicionais e rotas virão aqui

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
Expand All @@ -27,4 +32,4 @@ createConnection().then(connection => {
console.error('Database connection failed:', error);
});

module.exports = app;
export default app; // Usando exportação ES6 se você estiver usando módulos ES6 consistentemente

0 comments on commit 41874da

Please sign in to comment.