This application provides user registration, login, and protected routes using Express.js, PostgreSQL, and JWT authentication.
-
User Registration: Allows users to register with a valid email and password, which are securely stored after hashing.
-
User Login: Validates user credentials and issues a JWT token for authentication.
-
Protected Routes: Utilizes JWT tokens to protect routes and allow access only to authenticated users.
-
Clone the repository:
git clone https://github.com/LilVoidx/Auth-app.git cd Auth-app
-
Install dependencies:
npm install
-
Set up environment variables:
Copy
.env.example
to.env
and configure with your PostgreSQL credentials and JWT secret. -
Start the server:
npm start
The server will run on
http://localhost:5000
by default.
- POST
/register
: Register a new user. - POST
/login
: Log in with existing credentials and receive a JWT token. - GET
/protected
: Access a protected route requiring authentication.
- Express.js
- PostgreSQL
- JWT (JSON Web Tokens)
- bcrypt for password hashing