Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bedirhanssaglam/user-api
Simple Java Spring Boot application designed to manage user data with operations such as creating, updating, and deleting user information.
https://github.com/bedirhanssaglam/user-api
java maven spring spring-boot
Last synced: 1 day ago
JSON representation
Simple Java Spring Boot application designed to manage user data with operations such as creating, updating, and deleting user information.
- Host: GitHub
- URL: https://github.com/bedirhanssaglam/user-api
- Owner: bedirhanssaglam
- Created: 2024-11-14T20:17:32.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-15T17:04:33.000Z (2 months ago)
- Last Synced: 2024-11-22T05:07:45.508Z (2 months ago)
- Topics: java, maven, spring, spring-boot
- Language: Java
- Homepage:
- Size: 31.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# User API
This is a simple Java Spring Boot application designed to manage user data with operations such as creating, updating, and deleting user information. The application uses `ResponseWrapper` to standardize API responses.
## Table of Contents
1. [Features](#features)
2. [Technologies Used](#technologies-used)
3. [Setup and Installation](#setup-and-installation)
4. [Endpoints](#endpoints)
5. [Error Handling](#error-handling)
6. [Postman Collection](#postman-collection)---
### Features
- CRUD operations for User entities:
- **Create a user**
- **Retrieve user(s)** by ID, email, or name
- **Update user information**
- **Delete a user**
- Input validation (e.g., email format validation)
- Standardized responses with `ResponseWrapper`### Technologies Used
- Java 17+: Supports modern Java versions.
- Spring Boot: Core framework for building web applications and services.
- Spring Data MongoDB: Simplifies data management with MongoDB.
- Velocity: Template engine for generating dynamic content.
- Maven: Dependency management and build automation tool.---
### Setup and Installation
#### Prerequisites
- Java 17 or higher
- Maven
- Git### Endpoints
| HTTP Method | Endpoint | Description |
|-------------|----------------------|-----------------------------|
| GET | `/users` | Retrieve all users |
| GET | `/users/{id}` | Retrieve a user by ID |
| GET | `/users/email/{email}` | Retrieve a user by email |
| GET | `/users/name/{name}` | Retrieve users by name |
| POST | `/users` | Create a new user |
| PUT | `/users/{id}` | Update a user by ID |
| DELETE | `/users/{id}` | Delete a user by ID |#### Sample API Requests
1. **Retrieve a user by email:**
```http
GET /users/email/{email}
```Example Response:
```json
{
"code": 200,
"data": {
"id": "673600a3deaeb9142bc0ed94",
"name": "Bedirhan Saglam",
"email": "[email protected]"
},
"message": null
}
```2. **Create a new user:**
```http
POST /users
```Example Request Body:
```json
{
"name": "Bedirhan Saglam",
"email": "[email protected]"
}
```Example Response:
```json
{
"code": 201,
"data": {
"id": "1",
"name": "Bedirhan Saglam",
"email": "[email protected]"
},
"message": "User created successfully."
}
```### Error Handling
This application uses a custom `ResponseWrapper` class to standardize API responses and error messages.#### Common Error Messages
- Invalid Email Format: Returned when the provided email is invalid.
- User Not Found: Returned when no user is found for the specified criteria.
- Email Already Used: Returned when attempting to create or update a user with an email that already exists.### Postman Collection
You can download Postman collection from `postman` folder. Its appearance is as follows: