Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vinodnextcoder/nestjs-mongoose-boilerplate
About JwtService utilities module based on the nestjs/jwt package Authentication using NestJS & JWT Token, JwtService and cookies as access token & refresh token.
https://github.com/vinodnextcoder/nestjs-mongoose-boilerplate
dailyrotatefile docker jwt loggermiddleware nest-mongoose nestjs-backend nestjs-boilerplate nestjs-config nestjs-env nestjs-jwt-cookie-auth nestjs-mongoose-jwt nestjs-swagger nestmiddleware swagger swagger-documentation typescript winston winston-daily-rotate-file
Last synced: 6 days ago
JSON representation
About JwtService utilities module based on the nestjs/jwt package Authentication using NestJS & JWT Token, JwtService and cookies as access token & refresh token.
- Host: GitHub
- URL: https://github.com/vinodnextcoder/nestjs-mongoose-boilerplate
- Owner: vinodnextcoder
- Created: 2023-11-01T06:09:53.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-14T06:19:45.000Z (9 months ago)
- Last Synced: 2024-02-14T07:28:49.630Z (9 months ago)
- Topics: dailyrotatefile, docker, jwt, loggermiddleware, nest-mongoose, nestjs-backend, nestjs-boilerplate, nestjs-config, nestjs-env, nestjs-jwt-cookie-auth, nestjs-mongoose-jwt, nestjs-swagger, nestmiddleware, swagger, swagger-documentation, typescript, winston, winston-daily-rotate-file
- Language: TypeScript
- Homepage: https://github.com/vinodnextcoder/nestjs-mongoose-jwt/wiki
- Size: 1.12 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NestJS JWT Service with Cookie and Authorization
This repository contains a NestJS application showcasing JWT (JSON Web Token) authentication using cookies and authorization implementation.
## Features
- **JWT Authentication**: Implementation of JWT-based authentication using NestJS.
- **Cookie-based Tokens**: Store JWT tokens in HTTP-only cookies for secure communication.
- **Authorization Middleware**: Middleware for protecting routes and verifying user authorization.
- **Winston Logger** Winston is designed to be a simple and universal logging library with support for multiple transports.## Prerequisites
Ensure you have the following installed before running the application:
- Node.js (>= 12.x)
- npm
- MongoDB (or any preferred database)## Installation
1. **Clone the repository:**
```bash
https://github.com/vinodnextcoder/nestjs-mongoose-boilerplate.git
```2. **Install dependencies:**
```bash
cd nestjs-mongoose-boilerplat
npm i -g cross-env
npm install
```3. **Set up environment variables:**
Create a `.env` file in the root directory and provide necessary environment variables (check `.env.example` for reference).
## Configuration
- Update the `JWT_KEY` and other necessary environment variables in the `.env` file.
## Mongodb url update as per your config in env file
- MONGODB_URI=mongodb://localhost:27017/test
# or
- MONGODB_URI=mongodb://0.0.0.0:27017/test## Usage
1. **Start the application:**
```bash
# development
$ npm run start# watch mode
$ npm run start:dev# production mode
$ npm run start:prod
```### Swagger documentation for nestjs-mongoose-jwt
### Running
### You can get token from cookie response
```bash
Once the application is running you can visit [http://localhost:3000/api](http://localhost:3000/api) to see the Swagger interface.
```2. **Access the API:**
Use Postman, curl, or any REST client to interact with the API endpoints:
- Register a user: `POST /v1/users`
- Login: `POST /auth/login`
- Access protected routes: Use JWT token in the `Authorization` header or verify the cookie.## Endpoints
- `POST /v1/users`: Register a new user.
- `POST /auth/login`: Log in and receive a JWT token.
- `GET /v1/users`: Access a protected route (requires authentication).## Author
👤 **Vinod**
- Github: [@vinodnextcoder](https://github.com/vinodnextcoder)
## Contributing
Contributions are welcome! If you find any issues or want to enhance the application, feel free to submit a pull request.
husky added you skip in commint using below command
**git commit -m "commit msg" --no-verify**
## License
This project is licensed under the [MIT License](LICENSE).