This project provides a comprehensive template for implementing authentication in your application. It includes setup and configuration for user registration, login, and session management.
- User registration
- User login
- Session management
- middleware
- Password hashing
- Token-based authentication
- Node.js
- npm or yarn
-
Clone the repository:
git clone https://github.com/syipmong/authentication-template.git
-
Navigate to the project directory:
cd authentication-template -
Install dependencies:
npm install
or
pnpm install
-
Create a
.envfile in the root directory and add the following environment variables:DATABASE_URL=your_database_url
-
Start the development server:
npm start
or
yarn start
-
Open your browser and navigate to
http://localhost:3000.
- Register a new user by sending a POST request to
/auth/registerwith the user's details. - Login a user by sending a POST request to
/auth/loginwith the user's credentials. - Access protected routes by including the JWT token in the Authorization header.
Contributions are welcome! Please open an issue or submit a pull request.
Special thanks to all the contributors and open-source projects that made this template possible.