Skip to content

Third challenge of the updated Node.js track of the Ignite course

Notifications You must be signed in to change notification settings

Artur-Poffo/03-FindAFriend-API-Ignite

Repository files navigation

API for pet adoption

Status: Finished

AboutFeaturesAPI RoutesHow it worksTech StackAuthor

About

Find A Friend API - Ignite's third challenge on the Node.js trail, enables the registration of organizations and pets for adoption


Features

  • Register organization
  • Sign In with organization
    • JWT Authentication
  • Register a pet in an organization
  • List all pets for adoption in a city
  • Filter one unique pet with ID
  • Filter pets by traits
  • Persist data in Postgres database with docker

API Routes

  • Organizations
    • POST /orgs - Register a new organization
    • POST /sessions - Sign in with organization and generate JWT
    • PATCH /token/refresh - Refresh token
  • Pets
    • GET /pets - List all pets for adoption in a city or filter by params
    • GET /pets/:id - See a specific pet details with ID
    • POST /pets - Register a new pet in an organization Require a valid Bearer Token in the req's header

How it works

Pre-requisites

Before you begin, you will need to have the following tools installed on your machine: Git, Node.js. In addition, it is good to have an editor to work with the code like VSCode and a REST client like Insomnia

You will also need to have Docker installed to run the postgres database with Docker Compose

it is very important that before running the project you configure the environment variables as indicated in the file: .env.example

Run the app

# Clone this repository
$ git clone https://github.com/Artur-Poffo/03-FindAFriend-API-Ignite.git

# Access the project folder cmd/terminal
$ cd 03-FindAFriend-API-Ignite

# install the dependencies
$ npm install

# Inicialize the database
# In the root directory after installing docker run:
$ docker compose up
# This command should create and start a container with Postgres database

# Then when you want to stop running docker run:
$ docker compose stop
# Or just press Ctrl+c

# With your database running and connected in .env file:
$ npx prisma migrate dev

# Run the application in development mode
$ npm run dev

# The server will start at port: 3333 - You can now test in Insomnia or another REST client: http://localhost:3333

Run tests

# Run unit tests
$ npm run test

# Run E2E tests
$ npm run test:e2e

# Run test coverage
$ npm run test:coverage

Tech Stack

The following tools were used in the construction of the project:

  • Node.js
  • TypeScript
  • tsx
  • tsup
  • Fastify
  • @Fastify/jwt
  • @Fastify/cookie
  • bcrypt
  • zod
  • prisma
  • vitest
  • supertest

See the file package.json


Author

  • Artur Poffo - Developer

Linkedin Badge Gmail Badge