Skip to content

rogeriofonseca/forum-alura

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎯 forum-alura

This project is an example of implementing a Rest API using Spring Boot following instructions from the alura course.

Summary

Requirements:

  • Maven ⚙️
  • Java 8+

How to use?

Run the command to compile:

mvn clean install

To start the project. Run:

mvn spring-boot:run

spring_run
Image containing command result mvn spring-boot:run

After running the above command, the application will be available at: http://localhost:8080

Endpoints

List Topics:

Link: 🔗 http://localhost:8080/topicos?page=0&size=2&sort=id,asc Method GET

Postman Screenshot *[Click Here!]* 👈   🖼️
Screenshot_03_12_21_23_00
Postman Screenshot with Request Result

Link: 🔗 http://localhost:8080/topicos/{ID} Method POST

If you want to add a new record to try the endpoint, you can run the following CURL command in the terminal. And that will create a new record.

  curl -X POST \
  http://localhost:8080/topicos \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
    "titulo": "Question About Spring Validation",
    "mensagem": "Currently, should I add a new dependency for this to work?",
    "nomeCurso": "Spring Boot"
}'

Or it's also possible through postman:

postman_topicos_post_cadastrar
Screenshot with the request made through postman.

Adding H2 Database dependency and Console Browser

Connection Settings: 🎲

Driver Class: org.h2.Driver
JDBC URL: jdbc:h2:mem:alura-forum
User Name: sa
Password: (leave this field empty)

🔗Commit #3f7ac98e5c

H2_Console
H2 database interface showing tables in a column on the left of the screen.

Initial Data Load

The data located in the following path will be loaded at startup.

Initial data structure: src/main/resources/data.sql 📄

Filter using Spring Data

To search topics using the filter, you must enter the parameter in the URL: http://localhost:8080/topicos?param=Spring+Boot

Swagger

The URL to access the Swagger is: http://localhost:8080/swagger-ui/index.html

First, you must authenticate with a user, through endpoint /auth using for example:

{
  "email": "[email protected]",
  "senha": "123456"
}

There are two credentials available:

  login: aluno@email.com
  password: 123456
login: moderador@email.com
password: 123456
swagger
Swagger's screenshot.

Commits History

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages