Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tr1sm0s1n/axum-mongo-api

Axum API for CRUD operations in MongoDB.
https://github.com/tr1sm0s1n/axum-mongo-api

api axum crud docker mongodb rest rust tokio

Last synced: about 1 month ago
JSON representation

Axum API for CRUD operations in MongoDB.

Awesome Lists containing this project

README

        

# Axum-Mongo-API

Axum API for CRUD operations in MongoDB.

## 🛠 Built With

[![Rust Badge](https://img.shields.io/badge/Rust-000?logo=rust&logoColor=fff&style=for-the-badge)](https://www.rust-lang.org/)
[![Axum Badge](https://img.shields.io/badge/Axum-000?logo=rust&logoColor=fff&style=for-the-badge)](https://docs.rs/axum/latest/axum/)
[![MongoDB Badge](https://img.shields.io/badge/MongoDB-47A248?logo=mongodb&logoColor=fff&style=for-the-badge)](https://www.mongodb.com/)
[![Docker Badge](https://img.shields.io/badge/Docker-2496ED?logo=docker&logoColor=fff&style=for-the-badge)](https://www.docker.com/)

## ⚙️ Run Locally

Clone the project

```bash
git clone https://github.com/tr1sm0s1n/axum-mongo-api.git
cd axum-mongo-api
```

Install Rust

```bash
make install
```

Start the database

```bash
make up
```

Run the application

```bash
make run
```

Create a certificate

```bash
curl -X POST http://127.0.0.1:8080/create -H "Content-Type: application/json" -d '{"_id": 1, "name": "Langley", "course": "9A"}'
```

Read all certificates

```bash
curl http://127.0.0.1:8080/read
```

Read a certificate

```bash
curl http://127.0.0.1:8080/read/1
```

Update a certificate

```bash
curl -X PUT http://127.0.0.1:8080/update/1 -H "Content-Type: application/json" -d '{"_id": 1, "name": "Nightingale", "course": "MBCC"}'
```

Delete a certificate

```bash
curl -X DELETE http://127.0.0.1:8080/delete/1
```

View the database (optional)

```bash
make enter
```

Stop the database

```bash
make down
```