Arshnoor Singh (@arshnoor1411)

arshnoor1411's cover image
Powered by FIFO
arshnoor1411's image

Arshnoor Singh

Software Developer @FIFO. Software Engineer @Glue.

Followers34
Following33
Spaces10
Arshnoor Singh reposted

Why single threaded NodeJS?

A single threaded language means it can do only one thing at a time. Then why we use a single threaded language like NodeJS to create high traffic web applications with lots of concurrent connection.

Doesn’t it look counterintuitive?

Don’t you think a multi-thread language like Java and C++ will be more appropriate for this use case?

media
Arshnoor Singh reposted

SQL Commands-

SQL commands are instructions. It is used to communicate with the database. It is also used to perform specific tasks,

functions, and queries of data.

SQL can perform various tasks like create a table, add data to tables, drop the table, modify the table, set permission for users.

Arshnoor Singh reposted

What is Sentry ?

Sentry is a software platform that helps developers to identify and fix errors in their applications in real time. It is designed to work with a wide range of programming languages and technologies, and it integrates with various development and deployment tools.

Serverless in Nest JS

Serverless computing is a cloud computing execution model in which the cloud provider allocates machine resources on-demand, taking care of the servers on behalf of their customers.

When an app is not in use, there are no computing resources allocated to the app.

Pricing is based on the actual amount of resources consumed by application

Custom Providers in Nest Js

Custom providers in nest JS consist of dependency injection.

Dependency injection is an inversion of control (IoC) technique wherein you delegate instantiation of dependencies to the IoC container, instead of doing it in your own code imperatively.

Custom route decorators

Nest is built around a language feature called decorators. Decorators are a well-known concept in a lot of commonly used programming languages but in the JavaScript world they're still relatively new.

Interceptors in Nest JS

Interceptor in nest is an interceptor is a class annotated with the @Injectable() decorator and implements the NestInterceptor interface.

Interceptors have a set of useful capabilities

  • bind extra logic before / after method execution
  • transform the result returned from a function

Guards in NestJS

As yesterday was sharing views over the guards in nest JS. Today let's find out the execution context of auth guard.

Execution Context

The canActivate() function takes a single argument, the ExecutionContext instance. The ExecutionContext inherits from ArgumentsHost.

Guards in Nest JS

A guard is a class annotated with the @Injectable() decorator which implements the CanActivate interface.

Guards have a single responsibility that determine whether a given request will be handled by the route handler or not, depending on certain conditions like permissions, roles, ACLs etc. present at run-time which refers to authorization.

media

Multiple relation in Sequelize typescript

Multiple relations of same models

sequelize-typescript resolves the foreign keys by identifying the corresponding class references.

So if we define a model with multiple relations like

class Book extends Model { @ForeignKey(() => Person) @Column authorId: number; @BelongsTo(() => Person) author: Person; @ForeignKey(() => Person) @Column proofreaderId: number; @BelongsTo(() => Person) proofreader: Person;}@Tableclass Person extends Model { @HasMany(() => Book) writtenBooks: Book[]; @HasMany(() => Book) proofedBooks: Book[];}