Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mealet/todo_api.rs

Simple TODO API created with Rocket.rs and SurrealDB
https://github.com/mealet/todo_api.rs

Last synced: about 2 months ago
JSON representation

Simple TODO API created with Rocket.rs and SurrealDB

Awesome Lists containing this project

README

        

# 🛠️ | Todo API

### 👀 What is this?
This is a sample for REST API in Rust 🦀

It provides creating, editing and fetching tasks from database.

### ✈️ How to run this?
1. Install SurrealDB from [official site](https://surrealdb.com/) and run it
2. Download this code and edit `.env` file:
```
DB_URL=127.0.0.1:8000
DB_USERNAME=root
DB_PASSWORD=toor
DB_NS=somenamespace
DB_DATABASE=mydb
```

> **DB_URL** - url adress to you'r database (on local machine it would be 127.0.0.1:8000)

> **DB_USERNAME** - username for login (i've chosen 'root')

> **DB_PASSWORD** - password for login

> **DB_NS** - namespace (edit as you wish)

> **DB_DATABASE** - database name (it will keep all you'r content)

3. Run project by:
```
cargo run --release
```
4. Open it in browser: [127.0.0.1](http://127.0.0.1:8080)

### 🦛 Routes

| Request Type | Route Adress | Description |
| ------------ | ------------ | ----------- |
| | / | Index Page |
| | /tasks | All tasks |
| | /tasks/\ | Get task by id |
| | /tasks/new | Create new task (JSON) |
| | /tasks/\/edit | Edit task by id (JSON) |
| | /tasks/\/finish | Finish task by id (JSON) |
| | /tasks/\/definish | Unfinish task by id (JSON) |
| | /tasks/\ | Delete task by id |

> [!IMPORTANT]
> To create/edit tasks send JSON data like this:
> ```json
> {
> "title": "TASK TITLE"
> "description": "TASK DESCRIPTION"
> }
> ```

### 🦈 License
Project is licensed under the MIT License.

Check the [LICENSE](https://github.com/mealet/todo_api.rs/blob/master/LICENSE) file for more.