Skip to content

Commit aba6fd7

Browse files
committed
Implement note fetching and CORS configuration; remove unused frontend files
1 parent e8a9c6e commit aba6fd7

7 files changed

Lines changed: 33 additions & 248 deletions

File tree

future-try.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1. future make sure build a simple functionality which will use things like async, await and to understand . if see how it will work without this then how this keywords will help.
2+
2. Even for the cors do this kind of thing.

react-playground/src/App.jsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
function Header() {
2-
return (
3-
<header>
4-
<h1>Personal Vault</h1>
5-
</header>
6-
);
7-
}
1+
import { useState, useEffect } from 'react';
2+
3+
function App() {
4+
const [notes, setNotes] = useState([]);
5+
6+
useEffect(() => {
7+
fetch('http://localhost:8000/notes?user_id=1')
8+
.then(res => res.json())
9+
.then(data => setNotes(data));
10+
}, []);
11+
12+
return (
13+
<div style={{ padding: "1rem" }}>
14+
<h1>My Notes</h1>
15+
{notes.map(note => (
16+
<p key={note.id}>{note.title}</p>
17+
))}
18+
</div>
19+
);
20+
}
821

9-
function App() {
10-
return (
11-
<div>
12-
<Header />
13-
<p>Hello from React</p>
14-
</div>
15-
);
16-
}
1722
export default App;

vault/app/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
DATABASE_URL = os.getenv("DATABASE_URL", "")
88
SECRET_KEY = os.getenv("SECRET_KEY", "")
99
VAULT_ENCRYPTION_KEY = os.getenv("VAULT_ENCRYPTION_KEY", "")
10+
CORS_ORIGINS = os.getenv("CORS_ORIGINS", "http://localhost:5173").split(",")

vault/app/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from fastapi import FastAPI
22
from fastapi.staticfiles import StaticFiles
33
from fastapi.responses import FileResponse
4-
from app.config import APP_ENV
4+
from fastapi.middleware.cors import CORSMiddleware
5+
from app.config import APP_ENV, CORS_ORIGINS
56
from app.routers import health
67
from app.routers import users
78
from app.routers import notes
@@ -14,6 +15,14 @@
1415
version="0.1.0",
1516
)
1617

18+
app.add_middleware(
19+
CORSMiddleware,
20+
allow_origins=CORS_ORIGINS,
21+
allow_credentials=True,
22+
allow_methods=["*"],
23+
allow_headers=["*"],
24+
)
25+
1726
app.include_router(health.router)
1827
app.include_router(users.router)
1928
app.include_router(notes.router)

vault/frontend/app.js

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

vault/frontend/index.html

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

vault/frontend/styles.css

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

0 commit comments

Comments
 (0)