- Node.js (version 18.16.0)
- Clone the repository:
git clone <repository-url>
- Install dependencies:
cd varthak npm install
- Set environment variables:
- Create a
.env
file in the project root directory - Add the following environment variables and set their values:
MONGO_URL=<your-mongodb-connection-string
SECKEY=<your-secret-key>
- Create a
- Start the server:
npm start
- The server will be running locally at
- Method: POST
- URL: /signup
- Description: Create a new user account
- Request Body:
- email (string): User's email address
- password (string): User's password
- roles (array): User roles (e.g., ["CREATOR", "VIEWER"])
- Method: POST
- URL: /login
- Description: Authenticate user and generate JWT token
- Request Body:
- email (string): User's email address
- password (string): User's password
- Response:
- msg (string): Success message
- token (string): JWT token
-
Method: GET
-
URL: /books
-
Description: Get a list of books based on user role
-
Query Parameters:
- https://varthak.onrender.com/books?new=1
- old (number, optional): Set to 1 to retrieve books created 10 minutes ago and older
- new (number, optional): Set to 1 to retrieve books created less than 10 minutes ago
-
Headers: - authorization (string): Bearer (JWT token)
- Method: POST
- URL: /books
- Description: Create a new book
- Request Body:
- title (string): Book title
- author (string): Book author
- Headers:
- authorization (string): Bearer (JWT token)
- Content-Type: application/json
- You can use tools like Postman or ThunderClient to test the APIs. Set the appropriate HTTP method, URL, request body, and headers as mentioned in the API documentation above.