leosuncin/nest-auth-example
关于
使用 Passport 实现 Nest.js 身份验证的 Realworld 示例
安全与隐私可以做什么
- Authentication using Passport
- Local and JWT strategies are implemented
- TypeORM to connect with PostgreSQL
- Unit tests, integration tests and E2E tests
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文🛂 Nest.js Authentication Example
Nest.js authentication with Passport. RealWorld example
Features
- Authentication using Passport
- Local and JWT strategies are implemented
- TypeORM to connect with PostgreSQL
- Unit tests, integration tests and E2E tests
- ts-auto-mock with ttypescript to generate mocks with jest
- Check code quality with MegaLinter
- Check continuous integration with github actions
- Run the necessary services with docker compose
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
Tech Stack
Server: Typescript, PostgreSQL, Nest.js, TypeORM, Passport
Test: Jest, SuperTest, TS auto mock
DevOps: Docker Compose
Author
👤 Jaime Leonardo Suncin Cruz
- Twitter: @jl_suncin
- Github: @leosuncin
- LinkedIn: @jaimesuncin
Show your support
Give a ⭐️ if this project helped you!
:star2: Stargazers
:fork_and_knife: Forkers
Related
Here are some more example projects with Nest.js
License
Release under the terms of MIT
探索相关项目
加载中…