NestJS
High Level
- What
- Why use NestJS
- Story of NestJS1
- Platform agnostics
- We can build
- REST API
- Micro services
- Web sockets
- GraphQL
- Bootstrap
- Dependency injections
- Decorators
- Decorator factor
- TS vs JS
- Call, apply, bind
- This context in different functions
NestCLI
npm i -g @nestjs/clinest newnest g co/nest generate controllernest g snest g module <name_of_module>
Theory
- Module
@Module()- controller
- exports
- imports
- providers
- Types
- Feature modules
- Global modules
- Third party modules
- Controllers
@<HTTP Methods>- params
- path params -
@Param() - query params -
@Query()
- path params -
@Body- Status codes
- defaults
@HttpCode(HttpStatus.<code>)
- Accessing underline library
@Res()
- injecting
- private readonly
- Error handling
new HttpExeption()- Helper classes eg:
new NotFoundException - Exception layer4
- Providers5
- Service
@Injectable()
- DTOs
- Pipes
- types of pipes
- Class validators
- pipes vs class validators
- Accessing code expires req
- Strategy
- Guards
- global
- local
TypeORM NestJS
- configuration
- autoLoadEntites
- synchronize
- enable in dev, disable in prod
- Entitles
- forRoot
- forFeatures
@Entity()@PrimaryGeneratedColumn@Column- nullable
@JoinTable()@ManyToMany(()=> <Relation>, (relation)=> relation.field)
- Repository
@InjectRepository(<name>)
- TypeORM
- create
- save
- preload
- remove
- Transactions 1.
Footnotes
-
Node.js makes not assumptions and includes nothing my default. Developer are in charge of setting up everything they want, this applies to everything from setting up routing, API calls, setting up web sockets and even code organization, file structure etc… NestJS let's you focus on the application problem at hand instead of the tiny implementation details ↩
-
For not creating test files ↩
-
Stimulate a command ↩
-
When throwing random error. NestJS automatically throes internal servererrorr ↩
-
Inject dependencies ↩
-
If set to true, if a field that is not on the DTO is passed it will throw an error ↩
-
If set to true, the body will be an instance of DTO class, and type casing as well ↩