Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pycreater/auth
JWT authentication using NestJS with mongoDB
https://github.com/pycreater/auth
javascript jwt-authentication mongodb nestjs typescript
Last synced: 13 days ago
JSON representation
JWT authentication using NestJS with mongoDB
- Host: GitHub
- URL: https://github.com/pycreater/auth
- Owner: Pycreater
- Created: 2024-07-18T06:46:16.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-21T13:54:41.000Z (6 months ago)
- Last Synced: 2024-11-17T19:41:48.163Z (2 months ago)
- Topics: javascript, jwt-authentication, mongodb, nestjs, typescript
- Language: TypeScript
- Homepage: https://auth-frontend-topaz.vercel.app/
- Size: 309 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Auth
This repository contains an authentication system built using NestJS. It supports user registration, login, and token-based authentication with JWT.
## Features
- User Registration
- User Login
- JWT Authentication## Technologies Used
- TypeScript
- NestJS
- JWT
- MongoDB## Getting Started
### Prerequisites
- Node.js
- npm
- MongoDB### Installation
1. Clone the repository:
```sh
git clone https://github.com/Pycreater/Auth.git
```
2. Navigate to the project directory:
```sh
cd Auth
```
3. Install the dependencies:
```sh
npm install
```
4. Create a `.env` file in the root directory and add your MongoDB and JWT configurations:
```env
PORT=8000
MONGODB_URI=
CORS_ORIGIN=
ACCESS_TOKEN_SECRET=
ACCESS_TOKEN_EXPIRY=
REFRESH_TOKEN_SECRET=
REFRESH_TOKEN_EXPIRY=
```### Running the Application
Run the following command to start the application:
```sh
npm run start
```The application will be accessible at `http://localhost:8000`.
## API Endpoints
### Authentication
- **Register**: `POST /api/v1/user/register`
```json
{
"username": "your_username",
"password": "your_password",
"email": "your_email"
}
```- **Login**: `POST /api/v1/user/login`
```json
{
"email": "your_email",
"password": "your_password"
}
```### Secured Endpoints
These endpoints require a valid JWT token to access.
- **User Logout**: `POST /api/v1/user/logout`
- Headers: `Authorization: Bearer `- **Change-password**: `POST /api/v1/user/forgot-password`
- Headers: `Authorization: Bearer `## Contributing
Contributions are welcome! Please open an issue or submit a pull request for any changes.
## License
This project is licensed under the MIT License. See the [MIT](MIT) file for details.