I’ve been building apps using NestJS for quite a while now and I want to share the best way to structure your directory/code with other developers new to this framework.
Before we begin, keep in mind that this structure is quite generic and might not work with some techniques like GraphQL. You could however modify it as per your requirements.
Now, let’s get straight to the point!
These are just the directory names. I will give more insights into how the files look inside these directories in their own particular section.
src ├── authentication ├── common │ ├── constants │…
Taking Class-Transformer & TypeORM in NestJS & comparing them with Laravel Collections & Query Builder, I am today going to explain how to minimize writing too much code & getting similar outputs. I have been using TypeORM as part of NestJS for a long time now & really believe that it holds almost the same capabilities as its competitor in Laravel / PHP.
Let me first explain the main reasons why custom repositories will keep you at a greater advantage.
It is very well known how the social distancing has come into affect in almost all countries of the world. Evidently, this is leading to nature coming back to life.
Let’s first talk about why the social distancing is important. Simply putting it, we can say, it’s contagious! And with no vaccine available so far, recovery is self-relied. And obviously, it is a psychological that without orders or proper awareness, no human is capable of making good decisions. This is why the governments (the biggest known entity in a country) has to make decisions for you to stay at home.
A little while ago, I published an article on “Seeding Databases in NestJS.” Now, I have created this article basically as a small “icing on the cake” to add some magic to the plain old database seeder. It is mainly focused on passing options or arguments to the seeder from the command line.
Occasionally, you need to create a seeder based on inputs/arguments passed in the command itself. For eg:
—-users=10. To achieve this, you can use the Node package command-line-args.
Just use your package manager to update your
npm install command-line-args
npm install @types/command-line-args --save-dev// or…
Getting values from an environment file isn’t supposed to be as simple as creating a
.env file. In NodeJS, dotenv, is one of the most famous packages that adds values into the node’s
process.env and returns them as a
string. But sometimes, you need these values to as boolean (eg. for enabling/disabling a feature) or an array (eg. array of support emails)… and because now we have more than one types to play around with, validation of these incoming environment variables becomes a must.
NestJS is one of the few Node frameworks that makes creating config variables very easy. …
When people usually start getting ready early in the morning, all they usually have in their minds is “I need to reach on time”, “Need to make a list of all my pending tasks”, “Need to talk to the manager about blah blah”… and the never ending series of depressing thoughts continue until you finally reach work, and start stressing out… This is the boring 9 to 5 work story of many men and women throughout the world.
Being punctual and clear about your daily tasks & goals is always nice, and I feel this is something everyone needs to…
NestJS is a highly scalable NodeJS framework revolutionizing the building of server-side apps. Its ability to create Application Contexts allows developers to easily build micro-applications and take advantage of components and modules within that environment.
One can simply create a wrapper around Nest’s container that will hold all the instantiated classes. You can then grab an existing instance inside that wrapper and run functions inside it, such as clearing your app cache, rebuilding configuration files etc.
Any kind of static data that is commonly shared between entities or is mainly used for testing is what one must focus on when…
Some developers code for coffee ☕️, some for money 🤑 and some for zen ☮️. Problem solving is one of the skills that makes them a great developer.
Is that enough though? Definitely not!
For clients, business comes first. Most clients care more about speed of delivery, which might not produce the best results. Imagine ordering a pizza and having it delivered to you in 15 minutes. It’s possible, but do you really expect it to be as good as the one that takes 30 minutes? Cooking requires time. It’s an art.
The outcome of any rushed work generally turns…
Laravel 📦, NestJS 🦁, Docker 🐳 | Full Stack Web Developer @Crowdlinker