GithubHelp home page GithubHelp logo

rubiin / ultimate-nest Goto Github PK

View Code? Open in Web Editor NEW
285.0 6.0 42.0 9.49 MB

Starter template with blog clone as project

License: MIT License

JavaScript 0.48% Dockerfile 0.42% TypeScript 97.65% Shell 0.28% Just 0.32% CSS 0.84%
vue nestjs nestjs-backend postgresql jwt mikroorm typescript hacktoberfest

ultimate-nest's Introduction

Nest Logo

Blog made using Nestjs + Mikro-orm codebase(backend) containing real world examples (CRUD, auth (password based and oauth), advanced patterns, etc) and batteries included and ever-evolving

GitHub package.json version Workflow test GitHub GitHub

Buy Me A Coffee


NOTE: Starting April 18,2022 , the repo has ditched most promises for observables. You can check the latest promised version code at commit

More on why observables are better than promises can be read here


Table of Contents

Prerequisites

NodeJS https://nodejs.org/en/

Typescript https://www.typescriptlang.org/

PostgresQL https://www.postgresql.org/

Redis https://redis.io/

RabbitMQ https://www.rabbitmq.com

Getting started

# 1. Clone the repository or click on "Use this template" button.
npx degit rubiin/ultimate-nest my-nest-app

# 2. Enter your newly-cloned folder.
cd ultimate-nest

# 3. Create Environment variables file.
cp env/.env.example env/.env.dev

# 4. Install dependencies (preferred: pnpm)

 npm install
 pnpm install
 yarn install

Database

Mikro Orm

The example codebase uses MikroORM with a Postgres database. Why Mikroorm? It is a modern ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. It is fully compatible with TypeScript and provides additional features like support for enums, custom types, MongoDB, transactions, caching, migrations, change tracking, advanced queries, lazy/eager relations and much more.

Copy sample env file and adjust the connection settings and other settings(jwt,redis,mail,etc) respectively on sample env file

Note: Env files are kept in env folder. The config validation allows 4 environment ['dev', 'prod', 'test','stage']. The env file name should be of format .env.[environment] Ex. (.env.dev). The env to use should be provided while running any script as NODE_ENV=dev npm run dev

Start local Postgres server and run npx cross-env NODE_ENV=dev just migrate to apply migrations

Now you can start the application witt npx cross-env NODE_ENV=dev npm run start.


Whats included

  • ๐ŸŒ I18n - Internationalization
  • ๐Ÿงต Stats - Swagger stats for common server metrics
  • ๐Ÿงต Poolifier - Threads for CPU extensive tasks
  • ๐Ÿ’ฌ Twilio - SMS support
  • ๐Ÿ“ฑ NestJS โ€” Latest version
  • ๐ŸŽ‰ TypeScript - Type checking
  • โš™๏ธ Dotenv - Supports environment variables
  • ๐Ÿ— Authentication, RSA256, [OAuth](https://oauth.net/ - JWT, RSA256, OAuth
  • ๐Ÿฌ Authorization - RBAC with casl
  • ๐Ÿช MikroORM - Database ORM
  • ๐Ÿช PostgreSQL - Open-Source Relational Database
  • ๐Ÿง  Configuration - Single config for all
  • ๐Ÿ“ƒ Swagger - API Documentation
  • ๐Ÿณ Docker Compose - Container Orchestration
  • ๐Ÿ” Helmet - Secure HTTP headers
  • ๐Ÿ“ ESLint โ€” Pluggable JavaScript linter
  • โœ… Commitlint โ€” Checks if your commit messages meet the conventional commit format.
  • ๐Ÿบ Husky โ€” Helps you create Git hooks easily.

Available Scripts

  • npm run start - Start application
  • npm run start:dev - Start application in watch mode
  • npm run start:prod - Start built application
  • npm run start:hmr - Start application with hot module replacement
  • npm run lint - Uses eslint to lint all the files inside src with config provided in eslint.config.js
  • npm run orm migration:create - Uses Mikroorm to create a migration file
  • npm run orm migration:up - This command is used to run availablexisting migration files.
  • npm run orm migration:down - This command is used to rollback migration.
  • npm run orm seeder:run - This command is used to run existing seeders in src/common/database.

All the scripts require NODE_ENV flag

Additionally, you can also see the scripts in justfile which is a cross platform task runner. You can use it by installing just and then running just <script>. Ex. just build


Setup

  • First if you don't want to use any libs from like redis, mailer etc. replace them from the app.module.tasks
    • You will also need to remove the config from validate.config.ts from line load: []
    • Also remove the unwanted config variables from the env file
  • Make sure you create a env file under env directory with name like .env.something.The portion after .env is the NODE_ENV value which will be required while running the app

Migration and seeding

Migrations are used to update the database schema. The migration files are stored in migrations directory.

npx cross-env NODE_ENV=dev npm run orm migration:up # applies migration for dev env

Seeding is used to insert data into the database. The seeding files are stored in common/database/seeders directory.

npx cross-env USER_PASSWORD=Test@1234 NODE_ENV=dev npm run orm seeder:run   # seeds data for dev env with all user password set as Test@1234

Start application

  • npx cross-env NODE_ENV=[env name] npm run start
  • View automatically generated swagger api docs by browsing to http://localhost:[port]/docs
  • View automatically generated swagger stats dashboard by browsing to http://localhost:[port]/stats. The username and password is the values set in the env file under SWAGGER_USERNAME and SWAGGER_PASS respectively

File structure

ultimate-nest
โ”œโ”€โ”€ env                                           * Contains all configuration files
โ”‚   โ””โ”€โ”€ .env.example                              * Sample configuration file.
โ”‚   โ””โ”€โ”€ .env.dev                                  * Configuration file for development environment.
โ”‚   โ””โ”€โ”€ .env.prod                                 * Configuration file for production environment.
โ”‚   โ””โ”€โ”€ .env.test                                 * Configuration file for test environment.
โ”œโ”€โ”€ coverage                                      * Coverage reports after running `npm run test:cov` command.
โ”œโ”€โ”€ dist                                          * Optimized code for production after `npm run build` is run.
โ”œโ”€โ”€ src
    โ””โ”€โ”€ modules                                   * Folder where specific modules all files are stored
          โ””โ”€โ”€ <module>
      โ”‚       โ””โ”€โ”€ dto                             * Data Transfer Objects.
      โ”‚       โ””โ”€โ”€ <module>.controller.ts          * Controller file.
      โ”‚       โ””โ”€โ”€ <module>.module.ts              * root module file for module.
      โ”‚       โ””โ”€โ”€ <module>.service.ts             * Service file for <module>.
      โ”‚       โ””โ”€โ”€ <module>.service.spec.ts        * Test file for service.
      โ”‚       โ””โ”€โ”€ <module>.repository.ts          * Repository file for <module>.
      โ”‚       โ””โ”€โ”€ <module>.repository.spec.ts     * Test file for repository.
โ”‚   โ””โ”€โ”€ common                                    * Common helpers function, dto, entity,guards, custom validators,types, exception, decorators etc.
โ”‚   โ””โ”€โ”€ __mocks__                                 * Fixtures for unit tests.
โ”‚   โ””โ”€โ”€ libs                                      * Resusable pre configured libraries
โ”‚   โ””โ”€โ”€ resources                                 * Contains all static resources like ssl, i18n,email templates etc.
โ”‚   โ””โ”€โ”€ app.module.ts                             * Root module of the application.
โ”‚   โ””โ”€โ”€ main.ts                                   * The entry file of the application which uses the core function NestFactory to create a Nest application instance.
โ”œโ”€โ”€ test                                          * End to end test files for the application.

Authentication

This applications uses JSON Web Token (JWT) to handle authentication. The token is passed with each request using the Authorization header with Token scheme. The JWT authentication middleware handles the validation and authentication of the token.

Deployment

You need to have docker and docker-compose installed. The image environment variable values can be found at the compose file

ENV=dev sh ./scripts/deploy.sh   # deploys dev environment (.env.dev used)
ENV=prod sh ./scripts/deploy.sh   # deploys prod environment (.env.prod used)

More docs found at docs folder

Do you use this template?
Don't be shy to give it a star! โ˜…

Support

Also if you are into NestJS ecosystem you may be interested in one of my other libs:

helper-fns

GitHub stars npm

A collection of helper functions for typescrip development. It includes functions for array,object,string,etc

nestjs-easyconfig

GitHub stars npm

Platform config manager for nestjs. It supports multiple config files and environment variables.


nestjs-minio

GitHub stars npm

This is a minio module for Nest.


nestjs-cloudinary

GitHub stars npm

This is a cloudinary module for Nest.


nestjs-pgpromise

GitHub stars npm

A Module for Utilizing Pg-promise with NestJS


Star History

Star History Chart

Made with โค๏ธ with opensource.

ultimate-nest's People

Contributors

bibhushankarki avatar bytegizmo avatar dependabot[bot] avatar github-actions[bot] avatar imgbotapp avatar joehillyard avatar kkz6 avatar mergify[bot] avatar renovate[bot] avatar rubiin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ultimate-nest's Issues

sharp pipe for handling image

Use sharp in a middleware or in pipe to reduce the uploaded image size without any extra code on services.
Also add sharp image resize on cloudinary service

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json5
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: node

Feature Request: Query criteria in PageOptionsDTO

Feature Request

Many a time I will need to submit query criteria to search for instances. The PageOptionsDTO instance should be enhanced to submit the complex query criteria that mikro-orm support such as $and, $or, $like, $ge etc. This would allow clients to execute complex queries leveraging the richness of mikro-orm.

Use configurable module builder

Currently using golevelup/modules to create dynamic modules but since v9 of nest it provides configurable modules that eliminates the use of the library

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • fix(deps): update all non-major dependencies (@aws-sdk/client-s3, @aws-sdk/client-ses, @swc/core, @types/node, pnpm, stripe, traefik, twilio)

Detected dependencies

asdf
.tool-versions
  • node 20.14.0
docker-compose
docker-compose.yml
  • redis 7.2.5-alpine
  • postgres 16.3-alpine
  • traefik v3.0.2
  • rabbitmq 3.13.3-management-alpine
dockerfile
docker/dev.Dockerfile
  • node 20.14.0-slim
docker/prod.Dockerfile
  • node 20.14.0-slim
github-actions
.github/workflows/codeql.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/github-ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • google-github-actions/release-please-action v4
  • actions/checkout v4
.github/workflows/lock.yml
  • dessant/lock-threads v5
npm
package.json
  • @aws-sdk/client-s3 ^3.598.0
  • @aws-sdk/client-ses ^3.598.0
  • @casl/ability ^6.7.1
  • @golevelup/nestjs-rabbitmq ^5.3.0
  • @golevelup/nestjs-stripe ^0.8.0
  • @golevelup/nestjs-webhooks ^0.2.18
  • @ladjs/consolidate ^1.0.3
  • @mikro-orm/core 6.2.9
  • @mikro-orm/migrations 6.2.9
  • @mikro-orm/nestjs ^6.0.2
  • @mikro-orm/postgresql 6.2.9
  • @mikro-orm/reflection 6.2.9
  • @mikro-orm/sql-highlighter ^1.0.1
  • @nestjs/axios ^3.0.2
  • @nestjs/cache-manager ^2.2.2
  • @nestjs/common 10.3.9
  • @nestjs/config ^3.2.2
  • @nestjs/core 10.3.9
  • @nestjs/jwt ^10.2.0
  • @nestjs/mapped-types *
  • @nestjs/passport ^10.0.3
  • @nestjs/platform-express ^10.3.9
  • @nestjs/platform-socket.io ^10.3.9
  • @nestjs/schedule ^4.0.2
  • @nestjs/serve-static ^4.0.2
  • @nestjs/swagger ^7.3.1
  • @nestjs/terminus ^10.2.3
  • @nestjs/throttler ^5.2.0
  • @nestjs/websockets ^10.3.9
  • @ngneat/falso ^7.2.0
  • @paralleldrive/cuid2 ^2.2.2
  • @sentry/hub ^7.114.0
  • @sentry/node ^8.9.2
  • @socket.io/redis-adapter ^8.3.0
  • @supercharge/request-ip ^1.2.0
  • @travelerdev/nestjs-sentry ^4.3.0
  • argon2 ^0.40.3
  • cache-manager 5.6.1
  • cache-manager-ioredis-yet ^2.1.1
  • class-transformer ^0.5.1
  • class-validator ^0.14.1
  • compression ^1.7.4
  • date-fns ^3.6.0
  • date-fns-tz ^3.1.3
  • eta ^3.4.0
  • firebase-admin ^12.1.1
  • helmet ^7.1.0
  • helper-fns ^2.7.0
  • ioredis ^5.4.1
  • isomorphic-dompurify ^2.12.0
  • joi ^17.13.1
  • mime-types ^2.1.35
  • nestjs-cloudinary ^2.0.7
  • nestjs-i18n ^10.4.5
  • nestjs-minio ^2.6.1
  • nestjs-pino ^4.1.0
  • nestjs-throttler-storage-redis ^0.4.4
  • nodemailer ^6.9.13
  • otplib ^12.0.1
  • passport 0.7.0
  • passport-facebook ^3.0.0
  • passport-google-oauth20 ^2.0.0
  • passport-jwt 4.0.1
  • passport-magic-login ^1.2.2
  • pino-http ^10.1.0
  • pino-pretty ^11.2.1
  • poolifier ^4.0.14
  • preview-email ^3.0.20
  • prom-client ^15.1.2
  • qrcode ^1.5.3
  • redis ^4.6.14
  • reflect-metadata 0.2.2
  • rxjs ^7.8.1
  • sharp ^0.33.4
  • socket.io ^4.7.5
  • stripe ^15.11.0
  • swagger-stats ^0.99.7
  • twilio 5.1.1
  • unprofane ^1.0.6
  • url-minify ^2.8.4
  • @antfu/eslint-config ^2.21.1
  • @firebase/app-compat ^0.2.35
  • @firebase/app-types ^0.9.2
  • @golevelup/ts-jest ^0.5.0
  • @mikro-orm/cli 6.2.9
  • @mikro-orm/seeder 6.2.9
  • @nestjs/cli 10.3.2
  • @nestjs/schematics 10.1.1
  • @nestjs/testing 10.3.9
  • @rubiin/tsconfig ^1.1.2
  • @sentry/types ^8.9.2
  • @side/jest-runtime ^1.1.0
  • @swc/core ^1.6.1
  • @swc/jest ^0.2.36
  • @total-typescript/ts-reset ^0.5.1
  • @types/cache-manager ^4.0.6
  • @types/cache-manager-redis-store ^2.0.4
  • @types/compression ^1.7.5
  • @types/consolidate ^0.14.4
  • @types/jest ^29.5.12
  • @types/mime-types ^2.1.4
  • @types/multer ^1.4.11
  • @types/node ^20.14.2
  • @types/nodemailer ^6.4.15
  • @types/passport ^1.0.16
  • @types/passport-facebook ^3.0.3
  • @types/passport-google-oauth20 ^2.0.16
  • @types/passport-jwt ^4.0.1
  • @types/preview-email ^3.0.4
  • @types/qrcode ^1.5.5
  • @types/qs 6.9.15
  • @types/supertest 6.0.2
  • @types/swagger-stats ^0.95.11
  • @types/swagger-ui-express ^4.1.6
  • cross-env ^7.0.3
  • cz-conventional-changelog 3.3.0
  • eslint ^9.5.0
  • husky ^9.0.11
  • jest 29.7.0
  • lint-staged ^15.2.7
  • run-script-webpack-plugin ^0.2.0
  • sample-env ^2.0.8
  • supertest 7.0.0
  • testcontainers ^10.9.0
  • ts-loader 9.5.1
  • ts-node 10.9.2
  • tsconfig-paths 4.2.0
  • typescript ^5.4.5
  • webpack ^5.92.0
  • webpack-node-externals ^3.0.0
  • node >=20.14.0
  • pnpm 9.3.0
nvm
.nvmrc
  • node 20.14.0

  • Check this box to trigger a request for Renovate to run again on this repository

docker-compose up not working

Describe the bug

On clean install, replace variable values in .env.dev and run docker-compose up results in:

time="2023-06-29T22:02:28+02:00" level=warning msg="The \"PASSWORD\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"ENV\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"ENV\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"ENV\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"POSTGRES_USER\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"POSTGRES_PASSWORD\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"POSTGRES_DB\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"API_URL\" variable is not set. Defaulting to a blank string."
time="2023-06-29T22:02:28+02:00" level=warning msg="The \"ENV\" variable is not set. Defaulting to a blank string."
validating C:\dev\ultimate-nest\docker-compose.yml: services.pgweb.environment.0 must be a string

I assume this has to do with not telling which environment you are using, so by using docker-compose --env-file .env.dev up you get following error:

validating C:\dev\ultimate-nest\docker-compose.yml: services.pgweb.environment.0 must be a string

Am I using the incorrect env instantiation?

Reproduction

.

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 16.68 GB / 31.93 GB
  Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.5.0 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Spartan (44.22621.1848.0), Chromium (114.0.1823.58)
    Internet Explorer: 11.0.22621.1

Used Package Manager

yarn

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Doesn't seem to read the correct .env.${NODE_ENV} file

This looks like an awesome template repo. A colleague and I spent quite a bit of time on this, but even though we created a .env.dev file in the env directory (hence ./env/.env.dev) it cannot read from this file. For example, we tried first running:

NODE_ENV=dev make migrate

But, the mikro-orm-cli would ask for the dbName or clientUrl values, meaning it couldn't read them from ./env/.env.dev,

image

We're sure of this because we then copied ./env/.env.dev to the project root and renamed to .env and once again ran NODE_ENV=dev make migrate which works and the db migration completes successfully.

Furthermore, after this we removed the .env we created from the root project folder and ran NODE_ENV=dev npm run start:dev and we got the below error stating the REDIS_TTL is required, which is indeed correctly set in our ./env/.env.dev but it seems this file is not being read correctly.

image

Any advice would be appreciated ๐Ÿ˜„

Below is our ./env/.env.dev file


### Environment File ##################################################################
# This file is a "template" of which env vars need to be defined for your application
########################################################################################
	
APP_PORT=8000
APP_PREFIX=v1
NODE_ENV=dev
API_URL=http://localhost:8000
SWAGGER_USER=cit-dev
SWAGGER_PASSWORD=xW4oH6*fd3u^vi
	
	# database 
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=root
DB_PASSWORD=root
DB_DATABASE=ultimateNest


	# for encryption,decryption stuffs all over the app

ENC_IV=A46B761159225E47
ENC_KEY=EC77F2C6EE0F3611A988921B65CA8776

  # jwt
  # access expiry can be number or 35d

JWT_ACCESS_EXPIRY=365d
JWT_REFRESH_EXPIRY=999999
JWT_SECRET=EC77F2C6EE0F36


	# mail
	# template dir should start from src, mail server values smtp,ses
MAIL_HOST=smtp.gmail.com
MAIL_PASSWORD=password
MAIL_PORT=465
MAIL_SERVER=SMTP
MAIL_PREVIEW_EMAIL=false
[email protected]
MAIL_TEMPLATE_DIR=resources/templates
MAIL_USERNAME=username

	#cloudinary
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-secret

  #redis
REDIS_URI=redis://default:test@1234@redis:6379
REDIS_TTl=10

  #rabbitmq
RABBITMQ_URI=
RABBITMQ_EXCHANGE=

  #sentry
SENTRY_DSN=https://redacted

  #google ouath
GOOGLE_CLIENT_ID=
GOOGLE_SECRET=
GOOGLE_CALLBACK_URL=http://localhost:8000/v1/auth/google/redirect


  #facebook ouath
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_CALLBACK_URL=http://localhost:8000/v1/auth/facebook/redirect

Use different pattern for translations

Clear and concise description of the problem

I have seen the codebase uses code these many times. This code is duplicated many places. The code performs nestjs-i118n translating part. Which is mostly boilerplate and is repeated many times.

I18nContext.current<I18nTranslations>()!.t("exception.itemDoesNotExist", { 
     args: { item: "Post" }
})

Suggested solution

I am suggesting a utility function that performs all the translating part using the same pattern. The function that translates the code looks like these and is given below. The code can be used in many places within a request body, but can't be used in dtos for now.

import { I18nContext, Path, TranslateOptions } from "nestjs-i18n";
import { I18nTranslations } from "src/i18n.generated";

export const translate = (
  key: Path<I18nTranslations>,
  options: TranslateOptions = {},
) => I18nContext.current<I18nTranslations>().t(key, options) as string;

This removes all most of the boiler plates and forces the code to use single source of truth pattern, Here is the updated code for getUserForProfile() would look like this

/**
	 * "Get a user by their username, and populate the specified fields."
	 *
	 * The first parameter is the username, which is a string. The second parameter is an array of fields
	 * to populate
	 * @param {string} username - string - The username of the user to get.
	 * @param {AutoPath<User, keyof User>[]} populate - AutoPath<User, keyof User>[] = []
	 * @returns Observable<User>
	 */
	getProfileByUsername(
		username: string,
		populate: AutoPath<User, keyof User>[] = [],
	): Observable<User> {
		return from(
			this.userRepository.findOne(
				{
					username,
				},
				{
					populate,
					populateWhere: {
						favorites: { isActive: true, isDeleted: false },
						followers: { isActive: true, isDeleted: false },
						followed: { isActive: true, isDeleted: false },
						posts: { isActive: true, isDeleted: false },
					},
				},
			),
		).pipe(
			mergeMap(user => {
				if (!user) {
					return throwError(
						() =>
							new NotFoundException(
								translate("exception.itemDoesNotExist",{
								          args: { item: "Profile" },
								})
							),
					);
				}

				return of(user);
			}),
		);
	}

Alternative

No response

Additional context

No response

Validations

Clear cache on data mutation

Now, whenever the data is created, updated or deleted, the redis cache is not updated and the user has to wait for time set in ttl for the data to be reflected back in redis.

Feat: Add script to generate npm lock file for docker deployment

Feature Request

Is your feature request related to a problem? Please describe.

On docker deployment, we mostly use yarn or npm. While npm is the defacto and has things like npm ci which doesn't generate lock file rather uses the existing lock file.If you are using other package managers like me in local development (pnpm) , this would create problem as the package-lock.json doesn't exist. Ofcourse you can always run , npm i --package-lock-only but the point is to automate this for docker deployment.

Describe the solution you'd like

Add a make file script, that gets run before deploy script/

Teachability, Documentation, Adoption, Migration Strategy

Add queuing

Feature Request

Is your feature request related to a problem? Please describe.

Queuing is very important for cpu intensive ,asynchronous and operations where delivery matters

Describe the solution you'd like

.The issue tracks progress of adding
rabbitmq as a queue

Teachability, Documentation, Adoption, Migration Strategy

What is the motivation / use case for changing the behavior?

More detailed getting started instructions?

Fantastic work. Looks great from code/design point of view. However had an issue trying to get it started. Feel that current instructions to getting started and deploying are in-adequate. Per docs couldn't find to the example mikro-orm config file or the file app.module.tasks. Would be great if you could provide more detailed instructions to get started --
-- with minimal components (excluding mail, rabbitmq, etc)
-- with all components (including some direction for installing depending components)

Many thanks.,

Add ssl

Should be able to pass a ssl flag and if set, use the ssl from the given location

Feat: Move hard coded strings and values to a file

The template still has hard coded strings and values for options like expiry time and some custom messages. Thinking of collecting all such stuffs in a file under src/common/constants/index.ts and using the exported value.
This ensures we are not duplicating code as well as a central control.
Note: Some can be added to env config files

Is any user allowed to update any article?

Describe the bug

I'm building blog api with Nest and MikroORM for learning purposes and I'm using this repo for reference, it already helped me a lot, thank you for maintaining it!

I'm stuck at updating article endpoint, I simply can't figure out how to filter article by author id before updating it.

Here is the update method in this repository, it seems it doesn't have such check, so it looks like any user can update any article.

I can see there is a policy decorator in the controller, so it sounds like it performs some checks before running the controller. But how does that work, where are the checks, is it checking if the article belongs to the user or not - I can't figure this out.

Reproduction

no repro

System Info

System

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.