Welcome to the TD API project! This open-source project provides a flexible and easy-to-use interface for accessing and managing data related to TD. With this API, you can access a variety of information, including events, news, resources, and more. We believe in the power of open-source software and welcome contributions from developers of all skill levels. Join us in building a better future for TD!
This is the repository for the backend of our website. So if you want to contribute to our frontend, please look at this repository instead.
We have chosen a tech stack that should make it easy for new students to quickly learn the ropes and start contributing.
API: Docker, Python, Fast API, MongoDB
We prefer a containerized development. Therefore, the only dependeciy needed to work on this project is docker/ docker-compose. To make this easier for new developers we have created a script that can be used to run the api in a container locally, this script is placed in the project root and is called
dev_utils.sh
.
- Clone the project
git clone git@github.com:td-org-uit-no/tdctl-api.git
- Go to the project directory
cd tdctl-api
- Add executable rights to the container util script
chmod +x ./dev_utils.sh
- Build docker container
This is only needed if it is the first time you running the server or if there has been any changes to the runtime environment of the server.
./dev_utils.sh compose build
- Launch the container
- Run container in background
Shutdown the container by running
./dev_utils.sh compose down
./dev_utils.sh compose up -d
- You can now start a interactive shell within the container by running the command
To get an interactive shell in the database container add
db
to the end of this command./dev_utils.sh exec
- You can now start a interactive shell within the container by running the command
- Run the container and view container output
Shutdown the container by pressing
ctrl-C
./dev_utils.sh compose up
- Run container in background
- Optional: Seed the database with test users:
This will provide you with a dummy admin user which has the credentials E-Mail :
dev_admin@admin.com
Password :Admin!234
to be able to login as admin../dev_utils.sh seed
When the container is up and running you should be to view the api at localhost:5001
To run tests make sure the container is running, then run the following command
./dev_utils.sh test
You should now se an output similar to this:
Starting mongodb_test
============================= test session starts ==============================
platform linux -- Python 3.9.16, pytest-7.3.0, pluggy-1.0.0
rootdir: /app
plugins: anyio-3.6.2
collected 46 items
tests/test_decorator.py ... [ 6%]
tests/test_endpoints/test_admin.py ..... [ 17%]
tests/test_endpoints/test_auth.py ... [ 23%]
tests/test_endpoints/test_event.py ..................... [ 69%]
tests/test_endpoints/test_jobs.py .... [ 78%]
tests/test_endpoints/test_mail.py . [ 80%]
tests/test_endpoints/test_members.py ....... [ 95%]
tests/test_validation/test_file_validation.py . [ 97%]
tests/test_validation/test_password_validation.py . [100%]
============================= 46 passed in 25.71s ==============================
Feel free to add issues to our issue tracker, or create your own pull request.
Contributions are always welcome!
See contributing.md
for ways to get started.
For support, email nettside-ansvarlig@td-uit.no