Giter Club home page Giter Club logo

ultimate-nest's Introduction

Hi, I'm Rubin

Rubin Bhandari | Twitter Rubin's LinkedIN Rubin's Telegram Rubin's Instagram Rubin's Reddit Rubin's Dev.to

Hi, I'm Rubin Bhandari, a Full Stack Developer ๐Ÿš€ from Nepal, currently, I'm working with Takeo.ai .I am a self taught developer, FOSS lover, linux enthusiast. I create blog posts and open source packages mainly on JS and Go that I find will help me and others with similar problems. I have a passion for learning and sharing my knowledge with others in a way that's as public as possible. You can see a full list of what I am up to on rubiin.ml. If you found value in something I have created or contributed to, please feel free to send a tip, give me a shout out @RubinCodes, give some hearts on DEV.to/rubiin

GIF

A little more about me...

  • ๐Ÿ‘จ๐Ÿฝโ€๐Ÿ’ป Iโ€™m currently working on gitignorer.
  • ๐ŸŒฑ Iโ€™m currently learning Golang and kubernetes;
  • ๐Ÿ‘ฏ Iโ€™m looking to collaborate on NestJS-Easyconfig ๐Ÿค;
  • ๐Ÿค” Iโ€™m looking for help with Data Structures and Algorithms ๐Ÿ˜ญ;
  • ๐Ÿ’ฌ Ask me about anything, I am happy to help;
  • โšก๏ธ Fun-Fact: Go to my personal site and type in rubin .Theres more, happy treasure hunting!
  • ๐Ÿ“ซ How to reach me: [email protected];


๐Ÿ› ๏ธ Stuffs I use (Languages,Tools and Others):

JavaScript Nodejs Typescript Lua Golang Python Vue HTML5 CSS3 SASS Tailwind Nestjs Linux Bash Jenkins Docker Traefik Postman Jest Trello Git ElasticSearch GraphQl Jira MongoDB Postgres

๐Ÿ“ˆ My GitHub Stats:

rubiin

๐Ÿ“• ย Latest Blog Posts

Go           2 hrs 37 mins   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   25.77 %
TypeScript   1 hr 55 mins    โ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   18.88 %
Bash         1 hr 53 mins    โ–ˆโ–ˆโ–ˆโ–ˆโ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   18.65 %
zsh          40 mins         โ–ˆโ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   06.69 %
sh           32 mins         โ–ˆโ–’โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   05.27 %

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

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?

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.

Add ssl

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

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

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

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

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.

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

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.

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

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.,

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

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

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.

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.