The Autobot API is a RESTful API built using Node.js, Express, and Sequelize. It allows developers to manage Autobots, their posts, and associated comments. The API pulls data from a third-party service and stores it in a local database, providing various endpoints for querying this data.
Ensure you have the following installed on your machine:
- Node.js (version 14.x or higher)
- npm or yarn
- MySQL or any other SQL database supported by Sequelize
- Vuejs A Progressive JavaScript Framework
Clone the repository:
git clone https://github.com/johnayinde/tweetAI-app.git
cd tweetAI-appTo simplify the setup process, you can use the provided script to automatically install all necessary dependencies for both the frontend and backend projects. This script is designed to work across different operating systems, including Windows, Linux, and macOS.
-
Download the Script: Ensure you have the script
install_dependencies.shin the root directory of your project. -
Make the Script Executable (Linux/macOS):
chmod +x install_dependencies.sh
-
Run the Script
./install_dependencies.sh
-
Install dependencies:
npm install OR yarn install
-
Rename the .env.example file in the root directory and configure your environment variables:
PORT=9090 CLIENT_URL=http://localhost:8080
-
Running the Application:
npm start
-
Install dependencies:
npm install OR yarn install
-
Running the Application:
npm run serve
The Autobot API provides a set of RESTful endpoints to manage Autobots, their posts, and comments. Below are the available endpoints, including the methods, descriptions, and examples of how to use them.
-
Endpoint:
GET /api/autobots -
Description: Retrieves a paginated list of all Autobots.
-
Query Parameters:
page(optional): Page number (default: 1)limit(optional): Number of items per page (default: 10)
-
Response:
{ "success": true, "data": [ { "id": 1, "name": "John Doe", "username": "johndoe", "email": "john@example.com", "phone": "123-456-7890" } ], "pagination": { "page": 1, "limit": 10, "totalPages": 5, "totalItems": 50 } }Example Request:
curl -X GET "http://localhost:9090/api/autobots?page=1&limit=10"
-
Endpoint:
GET /api/autobots/:botId/posts -
Description: Retrieves a paginated list of posts created by a specific Autobot.
-
Path Parameters:
botId: The unique ID of the Autobot.
-
Query Parameters:
page(optional): Page number (default: 1).limit(optional): Number of items per page (default: 10).
-
Response:
{ "success": true, "data": [ { "id": 1, "title": "Post Title", "body": "Post body content...", "autobotId": 1 } ], "pagination": { "page": 1, "limit": 10, "totalPages": 2, "totalItems": 20 } }Example Request:
curl -X GET "http://localhost:9090/api/autobots/1/posts?page=1&limit=10"
-
Endpoint:
GET /api/posts/:postId/comments -
Description: Retrieves a paginated list of comments for a specific post.
-
Path Parameters:
postId: ID of the post
-
Query Parameters:
page(optional): Page number (default: 1)limit(optional): Number of items per page (default: 10)
-
Response:
{ "success": true, "data": [ { "id": 1, "name": "Commenter Name", "email": "commenter@example.com", "body": "Comment content...", "postId": 1 } ], "pagination": { "page": 1, "limit": 10, "totalPages": 3, "totalItems": 30 } }Example Request:
curl -X GET "http://localhost:9090/api/posts/1/comments?page=1&limit=10"