Skip to content

About

An API for managing customer support tickets and messages.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Customer Support API

This project provides a Customer Support API for managing tickets and messages.

Getting Started

To get the project up and running, follow these steps:

  1. Clone the repository:

    git clone <repository_url>
    cd customer-support-api
  2. Start Docker Compose:

    This will build the Docker images and start the PostgreSQL database and the Node.js application.

    docker-compose up --build
  3. Run Database Migrations: (Optional)

    After the services are up, run the database migrations to create the necessary tables.

    docker-compose exec customer-support-api yarn migrate:up

Available API Endpoints

Here's a list of the available API endpoints and their usage:

Tickets

  • POST /ticket

    • Description: Creates a new support ticket.
    • Request Body:
      {
          "customer_name": "string",
          "customer_email": "string",
          "description": "string"
      }
  • GET /ticket

    • Description: Retrieves a list of all support tickets.
  • GET /ticket/:id

    • Description: Retrieves a single support ticket by its ID.
  • PATCH /ticket/:id/resolve

    • Description: Resolves a support ticket by its ID.

Ticket Messages

  • POST /ticket-message/:id

    • Description: Creates a new message for a specific ticket.
    • Request Body:
      {
          "message": "string",
          "sender": "string" (e.g., "customer", "agent")
      }
  • PATCH /ticket-message/:id

    • Description: Updates an existing message for a specific ticket.
    • Request Body:
      {
          "message": "string"
      }
  • PATCH /ticket-message/:id/publish

    • Description: Publishes a ticket message (e.g., marks it as visible to the customer).

Health Check

  • GET /health
    • Description: Returns the health status of the API.

Creating a Migration Script for a New Table

To create a new migration script (for example, to add a new table), run the following command inside the Docker container:

docker-compose exec customer-support-api yarn migrate:create <migration_name>

Replace <migration_name> with a descriptive name for your migration, such as create-users-table.

This will generate a new migration file in the migrations directory.

Running Migrations from Docker

To run database migrations from inside the Docker container, use the following command:

docker-compose exec customer-support-api yarn migrate:up

This will execute the migration script within the running customer-support-api service container, ensuring it can connect to the database service.

About

An API for managing customer support tickets and messages.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages