项目作者: enricmartos

项目描述 :
This REST API application provides a user management tool.
高级语言: Java
项目地址: git://github.com/enricmartos/user-rest-api.git
创建时间: 2019-04-08T19:14:11Z
项目社区:https://github.com/enricmartos/user-rest-api

开源协议:

下载


user-rest-api

Description

This REST API application is a user management tool which allows you to see, edit and delete all user entries. You can add new users as well.

Personal goals

  • To implement a REST API using Spring MVC
  • To build the data layer using Spring Data JPA
  • To understand configuration, deployment and execution of Spring applications

Core technologies

Back-end

  • Spring Boot
  • Hibernate (as a JPA framework)

Database

  • MySQL

Dependency management tool

  • Gradle

IDE

  • IntellIJ Idea

Containerization

  • Docker-compose

Build setup

With Docker

$ docker-compose up

  1. This command creates the three docker containers detailed below:
  2. - _user-rest-api_app_1_: Main container of the Spring Boot application
  3. - _user-rest-api_mysql_1_: DB container
  4. - _user-rest-api-adminer_1_: DB management tool to interact with the MySQL DB
  5. Adminer's credentials are the ones defined in .env file.
  6. ### Without Docker
  7. - Clone this repo to your local machine. If you use IntelliJ as IDE, open this project there.
  8. - MySQL (and MySQL Workbench, optionally) must be already installed in your machine. Otherwise, you will have to install them. Please notice that the default parameters (port, username and password) to enable the MySQL connection are defined on application.properties file. So, feel free to edit them in order to match one of your MySQL connections.

Create the db

CREATE SCHEMA user_db ;
```

  • Run the project as Spring Boot App

Usage

  • Postman or any other API tester must be already installed in your machine. Otherwise, you will have to install them. You can perform the requests below in order to test the application. They belong to User management API collection, which can be easily imported to Postman with this shareable link.
Action HTTP request method Endpoint Body example
Create new user POST /api/user {“fname”: “Steven”, “lname”: “Adams”}
Read all users GET /api/users
Read user GET /api/user/{id}
Update user PUT /api/user {“id”: “1”, “fname”: “Anthony”, “lname”: “Davis”}
Delete user DELETE /api/user/{id}

References

I have accomplished the aforementioned goals thanks to the following courses: