Skip to content

Krzysztof-Bednarczyk/phonebook-capstone

Repository files navigation

Phonebook capstone app.

PhoneBook application is an example project created as a Spring MVC (REST) application. The REST endpoints look as follows:

GET - receive all phoneBook records.
GET/{name} - all phones for the given name.
PUT/{name}; phoneNumber - add a phone to an existing name.
POST/; {“name”:”YourName”, “phoneNumber”: “+79998887711”} - create a new record in the phoneBook.
DELETE/{name} - removes record by name completely (including associated phone numbers).

Rest resources must be located under api/v1/contacts.

Uses JSON as a request/response body.
All records are kept in memory. It uses a mysql:5.7 docker database instance.

DELETE/{name} - throws an exception if there is no such phone in the PhoneBook. Exception is handled and the reason is printed out as a JSON object.

Java configuration is used in the App.

How to use the app.

Prerequisites

  1. Java version 17 ☕ -> openjdk 17.0.4 2022-07-19 LTS.
  2. Docker 🐳 -> get Docker Desktop.
  3. Postman. 🏣
  4. Maven.
  5. Intellij IDEA(optional).

Usage

  1. Execute command dokcer compose up -d. A docker mysql instance should spin up. A separate volume for persistent data will be created on Your local machine. Be sure that Your port #3306 is not occupied. If so You need to edit the docker-compose.yml file 📁 in the ports section.
  2. Execute command mvn spring-boot:run. The app will run and connect 🔌 to the mysql instance.
  3. Open http://localhost:7070/api/v1/contacts - The browser will ask You for username and password since the endpoint is secured. 🔐
    Below is the table with user credentials.
Username Password Role
john fun123 EMPLOYEE
mary fun123 MANAGER
susan fun123 ADMIN

After login in. You should receive an empty array in response at the first run.
4. Use the provided Postman collection to add some users.

Have fun and enjoy the App. 😄

About

spring-boot project with rest mvc spring security and jpa

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages