Skip to content

My assistant, a nodejs API powered by chatGPT, nodejs and mongoDB

Notifications You must be signed in to change notification settings

raybags-dev/my-wizard-chat-gpt

Repository files navigation

MY-WIZARD API

This is a simple API powered by chat-gpt that allows you to ask GPT-5 questions and get a response locally in your dev-environment. It use custom functions that define routes for an Express.js server. The Authenticate function is defining a route for a POST request to the /api/auth endpoint, which is used to generate a JSON web token (JWT) using the generateJWTToken function and the authorization header of the request. The AskGPT function is defining a route for a POST request to the /raybags/ask-me endpoint, which is used to validate a JWT using the validateJWTToken function, then call the GPT_5 function with the question from the request body, and finally save the result to the GPT_RESPONSE model and return the response. The GetPaginatedResults function is defining a route for a GET request to the /historical-data endpoint, which is used to retrieve paginated results from the GPT_RESPONSE model. The GetAll function is defining a route for a GET request to the /historical-data-all endpoint, which is used to retrieve all the results from the GPT_RESPONSE model. The other functions are providing similar functionality for other endpoints

Endpoints

POST:

/api/auth

Generates a JSON web token (JWT) using the authorization header of the request.

POST:

/raybags/v1/wizard/ask-me

Validates a JWT using the authorization header, then calls the GPT_5 function with the question from the request body, and finally save the result to the GPT_RESPONSE model in mongodb and return the response.

GET:

/raybags/v1/wizard/data

Get paginated results:

?page=page-number ie. ?page=1

For all results.

-all

Get one item based on its id

/raybags/v1/wizard/item/:id

DELETE:

/raybags/v1/wizard/delete-item/:id

GET :

Handles unsupported routes.

'*'

Getting Started

  1. Clone the repository:
git clone  https://github.com/raybags-web-dev/my-wizard-chat-gpt.git
  1. Install the dependencies:
npm install
  1. Start the server:
npm start
  1. Test the endpoints using a tool like Postman or curl.

Built With

  • Express.js - The web framework used
  • Node.js - The JavaScript runtime
  • Jest - The testing framework
  • Mongoose - The MongoDB object modeling tool and Database

DOCKER

  1. Build docker image
docker build -t my-wizard-chat-gpt .
  1. Run Docker container
docker run -p 8080:4200 my-wizard-chat-gpt
  1. You can pull the image from docker hub with
docker pull revraymondbaguma/wizard-chat:1.0.0

This will start the server inside the Docker container and map it to port 8080 on your local machine

Author

This project is powered by chatGPT

About

My assistant, a nodejs API powered by chatGPT, nodejs and mongoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published