Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
FROM python:3.11.5-slim-bookworm

RUN pip install poetry==1.8.2

ENV POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /lemonapi
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

COPY pyproject.toml poetry.lock ./
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR

EXPOSE 5001

COPY . .
CMD uvicorn lemonapi.main:app --host=0.0.0.0 --port=5001 --log-level=info
RUN poetry install --without dev

ENTRYPOINT ["poetry"]

CMD ["run", "python", "-m", "uvicorn", "lemonapi.main:app", "--host=0.0.0.0", "--port=5001", "--log-level=info"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ You may connect to your own postgresql host by modifying `./lemonapi/utils/confi

## Credentials
The default admin credentials are `admin` with password `weakadmin`, change those!
> [!IMPORTANT]
> Make sure to copy over the contents of `.env-template` to `.env` with the appropriate credentials.

### Docker usage
Project has `Dockerfile` and `docker-compose.yml` pre made.
Expand Down Expand Up @@ -76,3 +78,11 @@ That's it, you should be able to get started with the basics
If you find a bug or error, open an issue and give a required information such as function/line where it happens in at, what is wrong and possibly other information (optional)

Want to know more about the API? Open an issue with label **question** or DM me in discord or something idk.

## Tests

If you are a developer and want to test your changes run
```bash
$ poetry shell # get into the poetry env
$ python -m pytest tests/
```
1,153 changes: 1,153 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[tool.poetry]
name = "lemon-api"
version = "0.1.0"
description = "Lemon api is a fast api based api about lemons"
authors = ["Nipa-Dev <nipathedev@gmail.com>"]
license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
asyncpg = "0.29.0"
bcrypt = "4.0.1"
fastapi = "0.100.1"
httpx = "^0.27.0"
Jinja2 = "3.1.2"
loguru = "0.7.0"
passlib = "1.7.4"
pydantic-settings = "^2.2.1"
python-jose = "3.3.0"
python-multipart = "0.0.6"
python-ulid = "1.1.0"
uvicorn = "0.23.2"
validators = "0.20.0"
aioprometheus = {extras = ["starlette"], version = "^23.12.0"}

[tool.poetry.group.dev.dependencies]
black = "^24.4.2"
pre-commit = "^3.7.1"
pytest = "^8.2.0"
ruff = "^0.4.4"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 0 additions & 4 deletions requirements-dev.txt

This file was deleted.

14 changes: 0 additions & 14 deletions requirements.txt

This file was deleted.

18 changes: 18 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,21 @@
def test_server_status():
response = client.get("/status/")
assert response.status_code == 200
assert response.text == "Server is running."

def test_server_metrics():
response = client.get("/metrics/")
assert response.status_code == 200

def test_home_endpoint():
root = client.get("/")
docs = client.get("/docs/")

assert root.status_code == 200
assert root.content == docs.content

def test_uknown_endpoint():
response = client.get("/asldkfalksdjf/")
assert response.status_code == 404