Skip to content

The Spring Boot endpoint for a task scheduling project, which follows all 4 levels of Richardson maturity to be RESTful, uses ISO 8601 date formats, supports HTTP PATCH, and includes pagination with HATEOAS. The project also integrates Swagger and Spring Security (Bearer Authentication), with PostgreSQL as the database.

Notifications You must be signed in to change notification settings

ryan-ribeiro/schedule-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Scheduling API

This project is an API built using Java, Spring Boot, Hibernate, Spring Data JPA, Spring Security, Swagger, HATEOAS, PostgreSQL, and implements Bearer Authentication and ISO 8601 date formats. The project supports HTTP PATCH, includes pagination, and follows all four levels of Richardson Maturity Model required to be RESTful.

Table of Contents

Installation

  1. Clone the repository:
git clone https://github.com/ryan-ribeiro/schedule-api.git
  1. Install dependencies with Maven:
mvn install
  1. Install PostgreSQL and create a database.

  2. Configure the database connection in application.properties:

spring.application.name=schedule-api
spring.datasource.url=jdbc:postgresql://localhost:5432/schedule-api
spring.datasource.username=yourusername
spring.datasource.password=yourpassword

Usage

  1. Start the application with Maven:
mvn spring-boot:run
  1. The API will be accessible at localhost:8080 Swagger is available at localhost:8080/swagger-ui/index.html#/

API Endpoints

The API provides the following endpoints:

Authentication:

POST /auth/register - Register a new user (no authentication required)

POST /auth/login - Authenticate an existing user, and returns a token (no authentication required)

GET /auth/test - Returns status 200 ok if the user is authenticated (authentication required)

GET /auth/test/customer - Returns status 200 ok if the user has the role "ROLE_CUSTOMER" (ROLE_CUSTOMER authentication required)

GET /auth/test/administrator - Returns status 200 ok if the user has the role "ROLE_ADMINISTRATOR" (ROLE_ADMINISTRATOR authentication required)

Tasks:

GET /task - Retrieve a list of all tasks in the database (pagination available, ROLE_ADMINISTRATOR authentication required)

GET /task/user/{username} - Retrieve a list of all tasks made by the user "username", but only if you're the "username" user authenticated. (ROLE_CUSTOMER authentication required)

GET /task/{id} - Retrieve a task whose id is "{id}" made by the user "username", but only if you're the "username" user authenticated (pagination available, ROLE_CUSTOMER authentication required).

POST /task - Create a new task in the name of the user "username", but only if you're the "username" user authenticated (ROLE_CUSTOMER authentication required)

PUT /task/{id} - Update all of an existing task's property in the name of the user "username", but only if you're the "username" user authenticated (ROLE_CUSTOMER authentication required)

PATCH /task/{id} - Update an existing task's property in the name of the user "username", but only if you're the "username" user authenticated (ROLE_CUSTOMER authentication required)

DELETE /task/{id} - Delete an existing task in the name of the user "username", but only if you're the "username" user authenticated (ROLE_CUSTOMER authentication required)

User:

GET /user - Retrieve a list of all users in the database (pagination available, ROLE_ADMINISTRATOR authentication required)

GET /user/{id} - Retrieve a list of all tasks made by the user "username" and his info, but only if you're the "username" user authenticated. (pagination available, ROLE_CUSTOMER authentication required)

PUT /user/{id} - Update all of an existing user's property in the name of the user "username", but only if you're the "username" user authenticated (ROLE_CUSTOMER authentication required)

PATCH /user/{id} - Update an existing user's property in the name of the user "username", but only if you're the "username" user authenticated (ROLE_CUSTOMER authentication required)

DELETE /user/{id} - Delete an existing user in the name of the user "username", but only if you're the "username" user authenticated (ROLE_CUSTOMER authentication required)

Authentication

The API uses Spring Security for authentication, with Bearer Token authentication. The following roles are available:

CUSTOMER -> Standard role for authenticated users.
ADMINISTRATOR -> Admin role for accessing all the content persisted, but not to delete or update anything.

To access protected endpoints, include the Bearer token in the Authorization header:

Authorization: Bearer <your-token>

If you are using Swagger, you also need to authenticate.

Database

The project utilizes PostgreSQL as the database.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request to the repository.

When contributing to this project, please follow the existing code style, commit conventions, and submit your changes in a separate branch.

About

The Spring Boot endpoint for a task scheduling project, which follows all 4 levels of Richardson maturity to be RESTful, uses ISO 8601 date formats, supports HTTP PATCH, and includes pagination with HATEOAS. The project also integrates Swagger and Spring Security (Bearer Authentication), with PostgreSQL as the database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages