Skip to content

Daespinosag/kata-rick-and-morty

Repository files navigation

Rick and Morty API

Kata - Demonstrative project only

Kata Rick and Morty

Índice

Description

This project is a backend application developed in Node.js, using Express and GraphQL Yoga to create an API that consumes the public Rick and Morty API. The application also implements caching with Redis to improve performance and uses a SQL database (Postgres) to manage data. It is designed to demonstrate skills in creating modern and efficient APIs with Node.js, integrating various technologies and design patterns.

Installation

Prerequisites

Before installing and running this application, make sure you have the following tools in their specified versions or higher:

  • Node.js (versión 18.0.0 o superior): Node.js is a runtime environment for JavaScript built with Chrome's V8 JavaScript engine.

    To check the version, use: node -v

  • npm (versión 10.0.0 o superior)

    To check the version, use: npm -v

  • Postgres (versión 12.18 o superior)

    To check the version, use: psql --version.

  • Redis (versión 5.0.7 o superior)

    To check the version, use: redis-server --version.

Used technology

This project makes use of several prominent technologies and libraries in web and API development, including:

  • Express.js: Web Application Framework for Node.js.
  • GraphQL Yoga: Complete server implementation for GraphQL.
  • Redis: Storage of data structure in memory, used as a database, cache and message broker.
  • PostgreSQL: Powerful, open source relational database management system.
  • Sequelize: ORM for Node.js for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.
  • TypeScript: TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.

Installation and commissioning steps

  1. Clone the repository:

    git clone <url-del-repositorio>
    
    cd kata-rick-and-morty
  2. Install dependencies:

    npm install
  3. Configure environment variables: Copy the .env.example file to .env and adjust the environment variables according to your configuration.

  4. **Run database migrations and seeders: **(make sure you have a database created)

    npm run database:migrate
    
    npm run database:seed
  5. Start the application:

  • Para desarrollo:
    npm run dev
    

Examples of Use

In this section, you will find examples of how to query the GraphQL API to obtain data from Rick and Morty characters, using various filters.

Basic Query

To get a list of characters filtering by name, you can use the following GraphQL query:

query { 
  characters(page: 1, filter: {name: "Rick Sanchez"}) {
    info {
      count,
      pages,
      prev,
      next,
    }
    results {
      id,
      name,
      status,
      species,
      type,
      gender,
      image,
    }
  },
  status{
    code,
    name,
    timesmap,
  }
}

This query returns information about characters whose name contains the "Rick Sanchez", including pagination and query metadata.

Available Filters

You can filter the characters using the following criteria:

  • name: Filters characters by name. Case insensitive search. species: Filter characters by species. Case insensitive search.
  • gender: Filter characters by gender. It must be an exact match.
  • status: Filters characters by status (alive, dead, unknown). It must be an exact match.
  • origin: Filter characters by their origin. Case insensitive search.

Pagination

The API supports pagination for character queries. By default, 20 items are displayed per page, and the first page is displayed if the page parameter is not provided.

To navigate through pages, you can modify the value of the page parameter in your query.

A look at the result

Preview

E/R Model

E/R

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published