This repository contains the backend API for a animal adoption platform. The API provides features for users to login, create new users, update their data, create animals for adoption, update their animal's data, update animal status, search for animals based on multiple parameters and import animals from third-party APIs.
Ensure that your machine is equipped with the necessary software by installing the following:
- Clone the repository:
git clone https://github.com/iuridantas/Backend-Adocao-Animais.git
- Navigate to the project directory:
cd Backend-Adocao-Animais
- Install dependencies:
yarn
- Fulfill the .env variables
To run the application using Docker Compose, make sure you have Docker and Docker Compose installed. If you don't, you can install them by following the instructions at Docker
- Build the images and start the containers:
docker-compose up --build
This command will build Docker images and start containers based on the docker-compose.yml file.
To perform Prisma-related database operations, follow these steps:
- Run Prisma migrations:
npx prisma migrate dev
This command applies any pending migrations.
- Push changes to the database:
npx prisma db push
Use this command to apply the changes to the database.
- Generate Prisma Client:
npx prisma generate
Run this command to generate the Prisma Client, which is used to interact with your database.
Run the following command to start the application:
yarn start:dev
The API will be accessible at http://localhost:3000.
- Endpoint:
/auth/login
- Method:
POST
- Description: User login
- Request Body:
{ "email": "string", "password": "string" }
- Responses:
200
: Successful login400
: Bad request500
: Internal server error
-
Endpoint:
/user/create
-
Method:
POST
-
Description: Create user
-
Request Body:
{ "name": "string", "email": "string", "cpf": "string", "password": "string" }
-
Responses:
200
: Successful creation400
: Bad request500
: Internal server error
- Endpoint:
/animal/create
- Method:
POST
- Description: Create animal
- Request Body:
{
"name": "string",
"description": "string",
"image": "string",
"userId": "string",
"category": "string",
"status": "available"
}
- Responses:
200
: Successful creation400
: Bad request500
: Internal server error
- Endpoint:
/animal/allIncludingExternalData
- Method:
GET
- Description: All animals into the database
- Security: Bearer Token
- Responses:
200
: Successful request401
: Unauthorized500
: Internal server error
- Endpoint:
/animal/updateStatus/{id}
- Method:
PATCH
- Description: Update animal status
- Security: Bearer Token
- Parameters:
animalId
(string)
- Responses:
200
: Successful update400
: Bad request401
: Unauthorized500
: Internal server error
-
Endpoint:
/animal/byTerm
-
Method:
GET
-
Description: Get pets by term(name or description)
-
Parameters:
term
(string)
-
Responses:
200
: Successful request400
: Bad request500
: Internal server error
- Endpoint:
/animal/byCategory
- Method:
GET
- Description: Get pets by category(cat or dog)
- Parameters:
category
(string)
- Responses:
200
: Successful request400
: Bad request500
: Internal server error
- Endpoint:
/animal/byStatus
- Method:
GET
- Description: Get pets by status(available or adopted)
- Parameters:
status
(string)
- Responses:
200
: Successful request400
: Bad request500
: Internal server error
- Endpoint:
/animal/byCreationDate
- Method:
GET
- Description: Get pets by creation date(yyyy/MM/dd or dd/MM/yyyy)
- Parameters:
creation date
(string)
- Responses:
200
: Successful request400
: Bad request500
: Internal server error
- axios - Promise based HTTP client for the browser and node.js
- bcrypt - Library to help you hash passwords
- class-transformer - Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors
- class-validator - Validation library for class-based application structures
- date-fns - Modern JavaScript date utility library
- passport - Simple, unobtrusive authentication for Node.js
- passport-jwt - Passport authentication strategy using JSON Web Tokens
- reflect-metadata - Polyfill for the
Reflect
API - rxjs - Reactive Extensions for JavaScript
- @nestjs/common - Nest framework (common module)
- @nestjs/config - Configuration module for Nest framework
- @nestjs/core - Nest framework (core module)
- @nestjs/jwt - JWT utilities module for Nest framework
- @nestjs/passport - Passport module for Nest framework
- @nestjs/platform-express - Nest framework (Express adapter)
- @nestjs/swagger - Swagger module for Nest framework
- @prisma/client - Prisma client for querying databases
This project is licensed under the MIT License - see the LICENSE.md file for details.