Skip to content

🐱 Pet adoptions back-end API REST. Built with Node.js, Fastify and Vitest.

Notifications You must be signed in to change notification settings

lui7henrique/find-a-friend-back-end

Repository files navigation

🐾 Find a Friend

The project consists of an API designed to facilitate the adoption of animals by connecting individuals interested in adopting pets with organizations that offer animals for adoption.

Application Rules

  • It must be possible to register a pet.
  • It must be possible to list all pets available for adoption in a city.
  • It must be possible to filter pets by their characteristics.
  • It must be possible to view details of a pet available for adoption.
  • It must be possible to register as an organization (ORG).
  • It must be possible to log in as an organization (ORG).

Business Rules

  • To list pets, it is mandatory to provide the city.
  • An ORG needs to have an address and a WhatsApp number.
  • A pet must be associated with an ORG.
  • Users who want to adopt a pet will contact the ORG via WhatsApp.
  • All filters, other than the city, are optional.
  • For an ORG to access the application as an admin, they must be logged in.

🚀 How to Run

To run the application, follow these steps:

  1. Start Docker Compose:

    docker-compose up
  2. Set Environment Variables:

    Create a .env file or configure environment variables with the following values:

    NODE_ENV=dev
    PORT=3333
    DATABASE_URL=postgresql://docker:docker@localhost:5432/find-a-friend-db?schema=public
    JWT_SECRET=henrique
    
  3. Install Dependencies:

    pnpm install
  4. Generate Prisma Client:

    npx prisma generate
  5. Run Prisma Migrations:

    npx prisma migrate dev
  6. Start the Server in Development Mode:

    pnpm run start:dev

The application should now be running and accessible at the specified port. You can interact with the API according to your requirements.

🛠️ How to Build

  1. Compile TypeScript to JavaScript:

    pnpm run build
  2. Start the Compiled Server:

    pnpm start

🧪 How to Test

To run tests, follow these steps:

  1. Execute Unit Tests:

    pnpm run test
  2. Execute Integration Tests:

    pnpm run test:e2e
  3. Generate Test Coverage Report:

    pnpm run test:coverage

The tests will ensure the functionality and reliability of the project.

📦 Dependencies

  • @fastify/cors, fastify: Framework for Node.js API development.
  • @prisma/client: Prisma client for interacting with the database.
  • bcryptjs: Library for password hashing.
  • dotenv: Environment variable loading.
  • supertest: Library for integration testing.
  • tsup: TypeScript compiler.
  • vitest: Testing framework.
  • zod: Data validation library. 🐶

If you're interested in deploying the application, you can learn how to do it here. It's quick and easy! 🚀

👨‍💻 Author

Luiz Henrique - Software Developer

Linkedin | E-mail

About

🐱 Pet adoptions back-end API REST. Built with Node.js, Fastify and Vitest.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published