Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/zerohertz/crud

🦀 CRUD operations based on various languages 🦀
https://github.com/zerohertz/crud

actix-web crud expressjs fastapi flask gin go java javascript nestjs nodejs python rust spring spring-boot

Last synced: 3 days ago
JSON representation

🦀 CRUD operations based on various languages 🦀

Awesome Lists containing this project

README

        

🦀 CRUD 🦀

```sh
$ kubectl create ns crud
namespace/crud created
$ kubectl -n crud apply -f k8s
configmap/postgres-config created
secret/postgres-secret created
deployment.apps/postgres created
service/postgres created
deployment.apps/backend created
$ kubectl -n crud exec -it deploy/backend -- zsh
```

API Specification



crud

| Function | Endpoint | Method | Description | Request Headers | Request Body | Response |
| --------------------- | ------------- | -------- | ------------------------------------------------ | -------------------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Create User | `/users` | `POST` | Creates a new user. | `Content-Type: application/json` | `json { "username": "john_doe", "email": "[email protected]", "password": "securepassword123" }` | Status: 201 Created
Body: `json { "id": "1", "username": "john_doe", "email": "[email protected]", "created_at": "2024-07-30T12:34:56Z" }` |
| Get All Users | `/users` | `GET` | Retrieves all users. | - | - | Status: 200 OK
Body: `json [ { "id": "1", "username": "john_doe", "email": "[email protected]", "created_at": "2024-07-30T12:34:56Z" }, { "id": "2", "username": "jane_doe", "email": "[email protected]", "created_at": "2024-07-30T12:40:00Z" } ]` |
| Get User by ID | `/users/{id}` | `GET` | Retrieves a specific user by ID. | - | - | Status: 200 OK
Body: `json { "id": "1", "username": "john_doe", "email": "[email protected]", "created_at": "2024-07-30T12:34:56Z" }` |
| Update User | `/users/{id}` | `PUT` | Updates a specific user's information. | `Content-Type: application/json` | `json { "username": "john_doe_updated", "email": "[email protected]" }` | Status: 200 OK
Body: `json { "id": "1", "username": "john_doe_updated", "email": "[email protected]", "updated_at": "2024-07-30T13:00:00Z" }` |
| Partially Update User | `/users/{id}` | `PATCH` | Partially updates a specific user's information. | `Content-Type: application/json` | `json { "email": "[email protected]" }` | Status: 200 OK
Body: `json { "id": "1", "username": "john_doe", "email": "[email protected]", "updated_at": "2024-07-30T13:30:00Z" }` |
| Delete User | `/users/{id}` | `DELETE` | Deletes a specific user. | - | - | Status: 204
No Content |

Database (PostgreSQL) Table Schema


| Field | Data Type | Description | Constraints |
| ---------- | ------------ | ------------------ | ----------------------------------- |
| id | INT | User's unique ID | PRIMARY KEY, AUTO_INCREMENT |
| username | VARCHAR(50) | User's username | NOT NULL, UNIQUE |
| email | VARCHAR(100) | User's email | NOT NULL, UNIQUE |
| password | VARCHAR(255) | User's password | NOT NULL |
| created_at | DATETIME | Creation timestamp | NOT NULL, DEFAULT CURRENT_TIMESTAMP |
| updated_at | DATETIME | Update timestamp | NULL, ON UPDATE CURRENT_TIMESTAMP |



DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}