Skip to content

Instantly share code, notes, and snippets.

View santuman's full-sized avatar
🏠
Working from home

Santosh Subedi santuman

🏠
Working from home
View GitHub Profile
@santuman
santuman / jwt.md
Created May 8, 2021 04:08
JSON Web Tokens

JSON Web Tokens

What are JSON Web Tokens?

  • Open-source industry standart (RFC-7519).
  • Usable for Authorization or secure exchange of information bretween parties.
  • Verify that the sender is who it/he/she claims to be.
  • Signed by the issuer, using a secret or keypair (HMAC algorithm, RSA or ECDSA).

JWT Structure

@santuman
santuman / how-redux-works.md
Created April 17, 2021 04:14
How redux works?

Redux

Redux is based on FLUX application architecture (by Facebook)

Building Blocks of Redux are:-

  • Action Javascript objects that represents what just happend. We could also call them Events e.g. userAdded, userUpdated, userRemoved
@santuman
santuman / immutable-mutable.md
Created April 17, 2021 00:19
Immutability in JavaScript

Mutable and Immutable Data Types

Textbook Definition

A mutable object is an object whose state can be changed or modified over time. A immutable object is an object whose state cannot be modified after it is created.

In Javascript String and Numbers are immutable and Objects and arrays ars mutable.

let a = 7
a += 1
@santuman
santuman / search-items.md
Last active April 16, 2021 14:17
Creating search items endpoint | NestJs, Typeorm

Endpoint to search keyword in the database.

async function getSearchedData (search:string){
  try {
    const searchData = return await this.connection
                                     .getRepository(UserEntity)
                                     .createQueryBuilder("user")
                                     .leftJoinAndSelect("user.roles", "roles")
                                     .where(
 "user.full_name LIKE :search OR user.username LIKE :search OR user.email LIKE :search",
@santuman
santuman / query-data-with-relations.md
Created April 16, 2021 12:10
Typeorm(ORM) querying data with relations

Typeorm Querying data with realtions.

Using Repository

const data = this.userRepository.find({
                    relations: ['photos']
                  })

Using QueryBuilder