Compare commits
No commits in common. "master" and "frontend" have entirely different histories.
16
README.md
16
README.md
@ -1,12 +1,6 @@
|
|||||||
# Singleboard Forum
|
# Forum App with FastAPI
|
||||||
A 4ch ripoff, coded as an exercise in learning full stack development with React
|
Model is after 4chan
|
||||||
and FastAPI.
|
|
||||||
|
|
||||||
## Demo
|
Board: has threads, unique counter for posts
|
||||||
Start the Docker containers:
|
Thread: Collection of related posts
|
||||||
```
|
Post: post_id, thread_id, title, content
|
||||||
docker compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
Interact with the backend API to add some posts by browsing to http://localhost:8000/docs,
|
|
||||||
then browse to the frontend at http://localhost:3000.
|
|
@ -5,7 +5,7 @@ services:
|
|||||||
context: ./backend
|
context: ./backend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '8000:8000'
|
- '8001:8000'
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
@ -13,7 +13,7 @@ services:
|
|||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- '3000:3000'
|
- '8000:8000'
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
@ -1,22 +1,4 @@
|
|||||||
# Forum Frontend
|
# Forum Frontend
|
||||||
The frontend for the forum is written in React.
|
Should be extremely simple to start with no styling.
|
||||||
|
|
||||||
**Note**: Before running, update the `apiUrl` in `app/src/App.js` to point your backend.
|
Node.js with a nice framework should be the ultimate goal, but could just do simple HTML and JS by hand for now.
|
||||||
|
|
||||||
## Development
|
|
||||||
To start the frontend in development mode and serve on http://localhost:3000:
|
|
||||||
```shell
|
|
||||||
npm run start
|
|
||||||
```
|
|
||||||
|
|
||||||
## Production
|
|
||||||
```shell
|
|
||||||
# Install serve
|
|
||||||
npm install -g serve
|
|
||||||
|
|
||||||
# Build for production
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
# Serve
|
|
||||||
serve -s --no-clipboard build
|
|
||||||
```
|
|
@ -3,13 +3,11 @@ import {useEffect, useState} from "react";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import PostList from "./components/Post/PostList";
|
import PostList from "./components/Post/PostList";
|
||||||
|
|
||||||
const apiUrl = "http://localhost:8000";
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [postList, setPostsList] = useState([]);
|
const [postList, setPostsList] = useState([]);
|
||||||
|
|
||||||
const fetchPosts = async () => {
|
const fetchPosts = async () => {
|
||||||
await axios.get(apiUrl + "/catalog")
|
await axios.get("http://localhost:8000/catalog")
|
||||||
.then((response) => { setPostsList(response.data)})
|
.then((response) => { setPostsList(response.data)})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,4 +38,4 @@ function App() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
22
frontend/conf/nginx.conf
Normal file
22
frontend/conf/nginx.conf
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server {
|
||||||
|
listen 8000 default_server;
|
||||||
|
listen [::]:8000 default_server;
|
||||||
|
|
||||||
|
root /app;
|
||||||
|
index index.html;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://backend:8000/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user