Authentication in NestJS with PassportJS and Prisma

WBOY
Release: 2024-09-04 20:30:32
Original
970 people have browsed it

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=""
Copy after login
  1. Start the development server: npm run dev

Built With

  • NestJs
  • PassportJs
  • Prisma

Endpoints

Login

/auth/login
Copy after login

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

{ "email": "string", "password": "string" }
Copy after login

Register

/auth/register
Copy after login

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

{ "name": "string", "email": "string", "password": "string" }
Copy after login

Get currect user

/auth/profile
Copy after login

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

Authorization: Bearer 
Copy after login

Contribution

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

The above is the detailed content of Authentication in NestJS with PassportJS and Prisma. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!