Skip to content
/ nest-auth-example Public template

Nest.js authentication with Passport. Realworld example

License

Notifications You must be signed in to change notification settings

leosuncin/nest-auth-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛂 Nest.js Authentication Example

MegaLinter Unit test E2E test Prettier GPL v3 License HitCount

Nest.js authentication with Passport. RealWorld example

Nest Logo

Features

Run Locally

Clone the project

  git clone https://github.com/leosuncin/nest-auth-example.git

Go to the project directory

  cd nest-auth-example

Install dependencies

  npm install

Create a .env from the example one and customize it with your environment variables

  cp .env.example .env

Start the services using Docker Compose

  docker-compose up -d

Run migrations to create the DB schema

  npm run typeorm migration:run

Start the server

  npm run start:dev

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

POSTGRES_DB the name of the database to connect in the PostgreSQL instance (required)

POSTGRES_USER The name of the user to connect to the PostgreSQL instance (required)

POSTGRES_PASSWORD The password of the user to connect to the PostgreSQL instance (required)

DATABASE_URL a connection string to the PostgreSQL instance, example postgres://postgres|@localhost/example-db (required)

PORT the port that Nest.js will listen at (required)

APP_SECRET the secret used to encrypt the session (required)

ALLOWED_ORIGINS a comma separated list of origins from which accept request (required)

You can copy the example .env and edit the values

  cp .env.example .env

Running Tests

To run unit tests, run the following command:

  npm test

To run e2e tests (the PostgreSQL instance must be available), run the following command:

  npm run test:e2e

To see the code coverage

  npm run test:cov

Try it online

Gitpod Try-it

Tech Stack

Server: Typescript, PostgreSQL, Nest.js, TypeORM, Passport

Test: Jest, SuperTest, TS auto mock

DevOps: Docker Compose

Author

👤 Jaime Leonardo Suncin Cruz

Show your support

Give a ⭐️ if this project helped you!

🌟 Stargazers

Stargazers repo roster for @leosuncin/nest-auth-example

🍴 Forkers

Forkers repo roster for @leosuncin/nest-auth-example

Related

Here are some more example projects with Nest.js

GraphQL example

API example

TypeORM custom repository

License

Release under the terms of MIT

About

Nest.js authentication with Passport. Realworld example

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published