Coder Social home page Coder Social logo

kosy-backend's Introduction

  ___   _      ___   _      ___   _      ___   _      ___   _
 [(_)] |=|    [(_)] |=|    [(_)] |=|    [(_)] |=|    [(_)] |=|
  '-`  |_|     '-`  |_|     '-`  |_|     '-`  |_|     '-`  |_|
 /mmm/  /     /mmm/  /     /mmm/  /     /mmm/  /     /mmm/  /
       |____________|____________|____________|____________|
                             |            |            |
                         ___  \_      ___  \_      ___  \_
                        [(_)] |=|    [(_)] |=|    [(_)] |=|
                         '-`  |_|     '-`  |_|     '-`  |_|
                        /mmm/        /mmm/        /mmm/

┌──┤ WHOAMI ├─────────▰▰▰
│
├─▣ Backend Engineer
├─▣ Indentation Enjoyer
├─▣ Async Awaiter 
├─▣ Rust Cult Member
├─▣ Hackathons Speed-Runner
├─▣ Student
│
└───────────────────────────────▰▰▰

┌──┤ SOCIAL ├─────────▰▰▰
│
├─◈ Website
├─◈ Linkedin
├─◈ Facebook
├─◈ E-Mail
│
└───────────────────────────────▰▰▰

┌──┤ RECENT BLOGS ├───────▰▰▰
│
├─◈ GIL and Data Races | GIL | Python
├─◈ Asynchronous file handling | Async | Python
├─◈ Convert argument's type at runtime | Typehints | Python
├─◈ Save python objects in redis | Redis | Python 
│
└───────────────────────────────▰▰▰

┌──┤ RECENT SESSIONS ├───────▰▰▰
│
├─▣ Month long Python Bootcamp on DRCFS
│
└───────────────────────────────▰▰▰

kosy-backend's People

Contributors

caffeineduck avatar

Watchers

 avatar

kosy-backend's Issues

REFACTOR: Remove unnecessary fields from `User` Model

Problem

There are too many fields in the User model.

Solution

Move non-essential fields to Profile model.

Current status of User Model

model User {
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt

    id                 Int     @id @default(autoincrement())
    email              String  @unique
    emailVerified      Boolean @default(false)
    phoneVerified      Boolean @default(false)
    tokenVersion       Int     @default(0)
    username           String  @unique
    role               Role    @default(USER)
    phone              String? @unique
    password           String?
    resetPasswordToken Int?

    books                Book[]
    profile              Profile?
    profileId            Int?
    savedBooks           Book[]        @relation("SavedBooks")
    BookComments         BookComment[]
    likedBookComments    BookComment[] @relation("LikedBookComments")
    dislikedBookComments BookComment[] @relation("DislikedBookComments")
}

REFACTOR: Use Transactions instead of multiple queries

Problem

If someone wants to update a comment, their profile, or the book they added, we have to check if the object belongs to the Jwt Authenticated user. This is causing multiple queries to the database and a lot of boilerplate code as well.

Solution

The provided solution aims to solve the multiple queries problem by using transactions.

Scope of Implementation

  • Books
  • Comments
  • User Profile

Example

Instead of using

  @ApiBearerAuth()
  @Delete(':id')
  async delete(@Param('id') id: string, @User() userJwt: JwtUserPayload) {
    await this.commentService.verifyUserComment(+id, userJwt.userId);
    return this.commentService.delete(+id);
  }

while checking if the comment belongs to the user, we can use Prisma Interactive transactions to minimize the number of queries to the database.

FEAT: Endpoints for User Profile

Problem

There aren't any endpoints in the backend for creating/ modifying the user profile yet.

Solution

Add the endpoints in by creating a new module.

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.