Auth API

Setup Instructions

1. Clone the Repository

git clone <your-repo-url>
cd <your-repo-folder>

2. Install Frontend Dependencies

cd client
yarn

3. Install Backend Dependencies

cd ../server
npm install

4. Start the Frontend

cd ../client
yarn start

5. Start the Backend

cd ../server
npm run start

Authentication API

User Model:

A user consists of the following properties:

  • id (UUID)
  • username (string, required)
  • password (hashed, required)

Endpoints:

1️⃣ Register a New User

POST /auth/register

{
  "username": "exampleUser",
  "password": "securePassword"
}

Response:

{
  "id": "generated-uuid",
  "username": "exampleUser"
}

2️⃣ Login

POST /auth/login

{
  "username": "exampleUser",
  "password": "securePassword"
}

Response:

{
  "token": "jwt-token"
}

3️⃣ Fetch User Details (Protected Route)

GET /auth/me

  • Requires Authorization: Bearer header.

Response:

{
  "id": "user-uuid",
  "username": "exampleUser"
}

Now you're ready to build and test your authentication API! 🚀