This is the server repo of PromptDB. It is a full-stack app for managing AI prompts. It features user authentication and provides users with CRUD functionality. This server is deployed on Heroku and is connected via this github repository.
Before you begin, ensure you have the following installed:
- Node.js
- npm (Node Package Manager)
- MongoDB
Follow these steps to get your development environment running:
-
Clone the Repository:
git clone git@github.com:jpatel98/promptDB-server.git
-
Navigate to the Project Directory:
cd promptDB-server
-
Install Dependencies:
npm install
-
Environment Setup: Create a
.env
file in the root of your project and update it with your environment-specific details based on .env.example file. -
Start the Server:
npm start
-
User Registration
- Method: POST
- Endpoint:
/api/users/register
- Description: Registers a new user.
- Body:
{ username, email, password }
-
User Login
- Method: POST
- Endpoint:
/api/users/login
- Description: Authenticates a user and returns a token.
- Body:
{ email, password }
-
Add a New Prompt
- Method: POST
- Endpoint:
/api/prompts/add
- Description: Adds a new prompt. Requires authentication.
- Body:
{ title, description, tags }
-
Get All Prompts
- Method: GET
- Endpoint:
/api/prompts/all
- Description: Retrieves all prompts.
-
Get Prompt by ID
- Method: GET
- Endpoint:
/api/prompts/getById/:promptId
- Description: Retrieves a specific prompt by its ID. Requires authentication and user must be the creator of the prompt.
- URL Parameters:
promptId
-
Edit a Prompt
- Method: PUT
- Endpoint:
/api/prompts/edit/:promptId
- Description: Edits an existing prompt. Requires authentication and user must be the creator of the prompt.
- URL Parameters:
promptId
- Body:
{ title, description, tags }
-
Delete a Prompt
- Method: DELETE
- Endpoint:
/api/prompts/delete/:promptId
- Description: Deletes a prompt. Requires authentication and user must be the creator of the prompt.
- URL Parameters:
promptId
-
Like a Prompt
- Method: PUT
- Endpoint:
/api/prompts/like/:promptId
- Description: Adds a like to a prompt.
- URL Parameters:
promptId
-
Unlike a Prompt
- Method: PUT
- Endpoint:
/api/prompts/removeLike/:promptId
- Description: Removes a like from a prompt.
- URL Parameters:
promptId