This is a basic authentication API using Node.js, Express, and JSON Web Tokens (JWT). The API supports user registration, login, and access to protected routes.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You need to have Node.js and npm installed on your local machine.
-
Clone the repository:
git clone https://github.com/coderooz/auth-api.git cd auth-api
-
Install the dependencies:
npm install express bcryptjs jsonwebtoken body-parser
-
Start the server:
node index.js
-
Register a new user
POST /register
- Request body:
{ "username": "john_doe", "password": "your_password" }
-
Login a user
POST /login
- Request body:
{ "username": "john_doe", "password": "your_password" }
-
Access protected route
GET /me
- Headers:
{ "x-access-token": "your_jwt_token" }
Use a tool like Postman or cURL to interact with the API endpoints.
- Express - The web framework used
- bcryptjs - To hash passwords
- jsonwebtoken - For JWT authentication
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Ranit Saha - Initial work - Coderooz
This project is licensed under the MIT License - see the LICENSE.md file for details