Skip to content

Commit 7145284

Browse files
committed
feat: updating deps, makefile consistency, formatting, using port 8080
1 parent 288ecd0 commit 7145284

File tree

7 files changed

+243
-634
lines changed

7 files changed

+243
-634
lines changed

.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
LOG_LEVEL=INFO
2-
PORT=8000
2+
PORT=8080
33
REDIS_URL="redis://localhost:6379"
44

Makefile

+33-14
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,49 @@
1-
install:
1+
MAKEFLAGS += --no-print-directory
2+
3+
## ---------------------------------------------------------------------------
4+
## | The purpose of this Makefile is to provide all the functionality needed |
5+
## | to install, develop, build, and run this app. |
6+
## ---------------------------------------------------------------------------
7+
8+
help: ## Show this help
9+
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
10+
11+
install: ## Install all dependencies
212
@uv sync --all-extras
313

4-
dev: install
5-
@fastapi dev src/app/main.py
14+
dev: ## Run a dev server and watch files to restart
15+
@$(MAKE) install
16+
@fastapi dev src/app/main.py --port 8080
617

7-
serve: install
8-
@fastapi run src/app/main.py
18+
serve: ## Run a production server
19+
@$(MAKE) install
20+
@fastapi run src/app/main.py --port 8080
921

10-
test:
22+
test: ## Run tests
1123
@pytest -rxP
1224

13-
docker:
14-
@docker compose up -d
25+
docker: ## Spin down docker containers and then rebuild and run them
26+
@docker compose down
27+
@docker compose up -d --build
1528

16-
format: install
29+
format: ## Format code
30+
@$(MAKE) install
1731
@ruff check src/app --fix
1832
@ruff format src/app
1933

20-
lint: install
34+
lint: ## Lint code
35+
@$(MAKE) install
36+
@$(MAKE) format
2137
@mypy src/app
22-
@ruff check src/app
23-
@ruff format src/app --check
2438

25-
lock: install
39+
lock: ## Update lock file
40+
@$(MAKE) install
2641
@uv lock
2742

28-
clean:
43+
update: ## Update dependencies
44+
@$(MAKE) install
45+
@uv sync --upgrade
46+
47+
clean: ## Remove build files
2948
@rm -rf .venv/ .mypy_cache/ .ruff_cache/ .pytest_cache/
3049
@find . -type d -name __pycache__ -exec rm -r {} \+

README.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Next, spin up docker containers:
3434
make docker
3535
```
3636

37-
You should have a server running on `http://localhost:<port>` where the port is set in your `.env` file (default is 8000). You can test the following routes:
37+
You should have a server running on `http://localhost:<port>` where the port is set in your `.env` file (default is 8080). You can test the following routes:
3838

3939
1. `GET /api/todos` - Gets all todos
4040
2. `GET /api/todos/:id` - Gets a todo by ID
@@ -69,23 +69,7 @@ make dev
6969

7070
## Other Scripts
7171

72-
Run a production server outside of docker:
73-
74-
```bash
75-
make serve
76-
```
77-
78-
Formatting code:
79-
80-
```bash
81-
make format
82-
```
83-
84-
Linting:
85-
86-
```bash
87-
make lint
88-
```
72+
Run `make` to see the list of available commands.
8973

9074
## Connecting to Redis Cloud
9175

__test__/Tests.http

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@Host = http://localhost:8080
2+
3+
### Get All Todos
4+
GET {{Host}}/api/todos HTTP/1.1
5+
6+
### Search Todos
7+
8+
GET {{Host}}/api/todos/search?status=in progress HTTP/1.1
9+
10+
### Get a single todo
11+
12+
GET {{Host}}/api/todos/1 HTTP/1.1
13+
14+
### Create a todo
15+
16+
POST {{Host}}/api/todos HTTP/1.1
17+
Content-Type: application/json
18+
19+
{
20+
"id": "2",
21+
"name": "Laundry"
22+
}
23+
24+
### Update a todo
25+
26+
PATCH {{Host}}/api/todos/2 HTTP/1.1
27+
Content-Type: application/json
28+
29+
{
30+
"status": "in progress"
31+
}
32+
33+
### Delete a todo
34+
35+
DELETE {{Host}}/api/todos/2 HTTP/1.1

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ maintainers = [
1010
]
1111
readme = "README.md"
1212
license = "MIT"
13-
requires-python = ">=3.8"
13+
requires-python = ">=3.9"
1414
keywords = ["python", "fastapi", "redis", "starter", "redis-py"]
1515
classifiers = [
1616
"Development Status :: 4 - Beta",
@@ -27,7 +27,7 @@ dependencies = [
2727
[dependency-groups]
2828
dev = [
2929
"pytest>=8.3.4",
30-
"pytest-asyncio>=0.24.0",
30+
"pytest-asyncio>=0.25.3",
3131
]
3232

3333
[project.urls]

src/app/components/todos/router.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
todos_store: TodoStore | None = None
1111

12+
1213
def get_todos() -> TodoStore:
1314
global todos_store
1415

0 commit comments

Comments
 (0)