Skip to content

pnilan/qa-service-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Questions & Answers Service Backend

This repository contains the backend Express server for the Questions & Answers service of a clothing e-commerce website. The service is responsible for handling user inquiries, allowing them to ask and answer questions about products available on the website.

Table of Contents

Getting Started

Follow the instructions below to set up the backend server on your local machine.

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v14 or later)
  • npm (Node Package Manager)
  • PostgreSQL 15

Installation

  1. Clone this repository to your local machine using:
git clone https://github.com/your-username/questions-answers-backend.git
  1. Navigate to the project directory:
cd questions-answers-backend
  1. Install the required dependencies:
npm install
  1. Create a .env file in the root directory and provide the necessary environment variables. Here is an example:
PGUSER=postgres_user
PGHOST=postgres_host
PGPASSWORD=postgres_password
PGDATABASE=postgres_db
PGPORT=postgres_port
PORT=3001
  1. Start the server:
npm start

The server will run on the specified port (default: 3001).

Usage

The Questions & Answers service provides APIs for managing product-related questions and answers. You can integrate these APIs with your clothing e-commerce website frontend to allow users to ask and answer questions about products.

API Endpoints

  • GET /api/questions: Get a list questions for a given product id passed as a query param.
  • GET /api/questions/:question_id/answers: Get a list of answers for a given question id.
  • POST /api/questions: Add a question for a product id passed as a query param.
  • POST /api/questions/:question_id/answers: Adds an answer for a given question_id.
  • PUT /api/questions/:question_id/helpful: Marks a question as helpful by incrementing helpfulness count.
  • PUT /api/questions/:question_id/report: Updates question's "reported" field to true, marking the question as reported.
  • PUT /api/answers/:answer_id/helpful: Marks an answer as helpful by incrementing helpfulness count.
  • PUT /api/answers/:answer_id/report: Updates answer's "reported" field to true, marking the answer as reported.

Database

This project uses PostgreSQL 15 as the database to store questions and answers. Ensure you have PostgreSQL set up and running before starting the server.

Technologies Used

Node.js Express PostgreSQL nginx AWS EC2 Jest

Contributing

We welcome contributions to improve this backend server. To contribute, follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature/bugfix.
  3. Make your changes and test thoroughly.
  4. Create a pull request with a detailed description of your changes.

License

This project is licensed under the MIT License.

About

Backend for Q&A service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%