DEV Community

Said MOUNAIM
Said MOUNAIM

Posted on

3 1 1 1 1

Authentication in NestJS with PassportJS and Prisma

NestJs Auth

NestJS Authentication with JWT, PassportJs, and Prisma

Getting Started

  1. Clone the repository: git clone https://github.com/saidMounaim/nest-auth.git
  2. Install dependencies: npm install
  3. Create a .env file in the root and add the following
DATABASE_URL=""

JWT_SECRET=""
Enter fullscreen mode Exit fullscreen mode
  1. Start the development server: npm run dev

Built With

Endpoints

Login

/auth/login
Enter fullscreen mode Exit fullscreen mode

Method: POST\
Description: Authenticates a user and returns a JWT token.\
Body:

{
  "email": "string",
  "password": "string"
}
Enter fullscreen mode Exit fullscreen mode

Register

/auth/register
Enter fullscreen mode Exit fullscreen mode

Method: POST\
Description: Registers a new user and returns a user info.\
Body:

{
  "name": "string",
  "email": "string",
  "password": "string"
}
Enter fullscreen mode Exit fullscreen mode

Get currect user

/auth/profile
Enter fullscreen mode Exit fullscreen mode

Method: GET\
Description: Retrieves user profile information. Requires a Bearer token for authentication.\
Body:

Authorization: Bearer <token>
Enter fullscreen mode Exit fullscreen mode

Contribution

All kind of contributions are welcome, please feel free to submit pull requests.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay