Skip to content

TechAbraao/contacts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API REST for Contacts

Tecnologias

Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge

How to Start

Pre-requisites

  • Java (21)
  • Apache Maven (3.8.7+)
  • Docker
  • PostgreSQL
  • Makefile (optional)

Running with Docker (recommended)

1. Clone the repository

Clone and access the directory

git@github.com:TechAbraao/contacts.git
cd ./contacts

2. Configure the environment variables.

Change the .env.example file to .env. For example:

cp .env.example .env

Now configure the necessary variables for the Docker container (minimal example):

## POSTGRESQL ##
POSTGRES_CONTAINER_NAME=contacts_postgres
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=secret
POSTGRES_DB=contacts_db

## PGADMIN ##
PGADMIN_CONTAINER_NAME=contacts_pgadmin
PGADMIN_PORT=8081
PGADMIN_EMAIL=admin@example.com
PGADMIN_PASSWORD=secret

3. Configure the application.yml file.

The application is pre-configured to use environment variables. Below is the recommended configuration for your src/main/resources/application.yml (minimal example):

server:
  port: 8080

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/contacts_db
    username: postgres
    password: secret
    driver-class-name: org.postgresql.Driver

  security:
    user:
      email: admin@example.com
      name: admin
      password: secret

4. Initialize the containers

If you have the Makefile (Linux/Unix system):

make start

If not, do it manually:

docker compose \
  --env-file .env \
  -f docker/compose/docker-compose.yml \
  up -d

5. Run the application

mvn clean install
mvn spring-boot:run

6. Availability

The API will be available at:

http://localhost:8000/api/

API Swagger Swagger available in:

http://localhost:8000/swagger-ui/index.html

API RESTful Definitions

Endpoints

Check out all the endpoints available in this project.

Authorizations
Method URL Description Authentication
POST /api/auth/signup Register a new user public
POST /api/auth/signin Login and obtain JWT token public
POST /api/auth/signout Logout (invalidate token) basicAuth or bearerAuth
Users
Method URL Description Authentication
GET /api/users/me Get authenticated user data basicAuth
GET /api/users Get all Users basicAuth
POST /api/users Create a User basicAuth
GET /api/users/{userId} Get User by ID basicAuth
DELETE /api/users/{userId} Delete User by ID basicAuth or bearerAuth
Contacts
Method URL Description Authentication
GET /api/contacts List my contacts basicAuth or bearerAuth
POST /api/contacts Create a new contact basicAuth or bearerAuth
GET /api/contacts/{contactId} Get a specific contact basicAuth or bearerAuth
PUT /api/contacts/{contactId} Update a contact basicAuth or bearerAuth
DELETE /api/contacts/{contactId} Delete a contact basicAuth or bearerAuth

Releases

No releases published

Packages

 
 
 

Contributors