Skip to content

Instantly share code, notes, and snippets.

View muslemomar's full-sized avatar

Muslem Omar muslemomar

View GitHub Profile

Improving REST API Throughput

1. Database Indexing:

  • I analyzed our MongoDB query patterns and added appropriate indexes to speed up frequent read and write operations. This reduced query response times significantly, particularly for the most commonly accessed endpoints.

2. Horizontal Scaling:

  • I set up a load balancer to distribute incoming requests across multiple instances of our Node.js application. This ensured that our API could handle increased traffic without becoming a bottleneck.

3. Caching Layer:

  • I introduced a Redis-based caching layer to store frequently accessed data, such as configuration settings and user session data. This reduced the load on our primary database and improved response times for cached requests.
  1. List four types of tests commonly used in software development.
  2. Explain the difference between unit tests, integration tests, and end-to-end tests.
  3. Explain the concept of TDD and discuss its advantages and disadvantages.
  4. Why is testing considered crucial in software development.
  5. What's the difference between manual testing and automated testing.
  6. Why is integrating testing into CI/CD beneficial for software development?
  7. What are some common types of non-functional tests? How do these tests contribute to the overall quality and reliability of a software system?
  1. What is a CSRF attack? How does it use HTTP requests? And why do we call it the one-click attack?
  2. What is an XSS attack? And what is the connection between it and cookies/sessions? And what are the two main categories of XSS?
  3. What is SQL injection? and what is the attacker’s intention from it?
  4. Consider the below SQL command, where is the vulnerability? think about some ways an attacker can misuse it:
const { username, password } = req.body
let strQry = `SELECT Count(*) FROM Users WHERE username=${username} AND password=${password}`;
  1. What does End-to-End encryption means? Share an example of an well-known app using E2EE, how is that app using it?
  1. What are the differences and connections between Mongoose schemas and models? How do they work together in an Express.js application?
  2. How does Mongoose handle data validation? Discuss the benefits of using Mongoose for data validation as opposed to doing it manually in your Express.js routes.
  3. What are virtuals in Mongoose? Discuss how and why you might use them in a project. Give examples of scenarios where virtuals can be particularly useful.
  4. What is population in Mongoose? How does it differ from simply storing object IDs in your documents? Discuss scenarios where population is beneficial and when it might be better to avoid it.
  5. How does Mongoose handle asynchronous operations? Discuss the role of promises and async/await in managing database interactions in an Express.js application.

SQL discussions

  1. What is the difference between SQL and MySQL?
  2. What do you mean by DBMS? What are its different types?
  3. What are the types of joins in SQL? Give an example for each one.
  4. What is a Primary key?
  5. What are the different operators available in SQL?
  6. What is the need for group functions in SQL?
  7. What is a Relationship and what are they?
@muslemomar
muslemomar / react-query-exercise.md
Last active June 10, 2023 12:32
React Query Exercise

React Query Exercise

Overview

This exercise focuses on creating a Next.js application that uses React Query to fetch data.

Instructions

  1. Create a NextJS application (the configurations are up to you, but make sure "App Router" is enabled, since you will need it in this app).
  2. Create a page for fetching all posts using this url: https://jsonplaceholder.typicode.com/posts
  • Examine package.json file, and answer the following questions:
    • What is the scripts section?
    • What could the dependencies be?
  • How many ways we can style an element in react?
  • Why do we use className instead of class in JSX?
  • In page.tsx we've used useState in line 6. What does it mean?

React Introduction Discussion

After seeing the code along and doing your first lab, discuss these ideas with your friends:

  1. From your understanding, what is React?
  2. What concept stood out to you about React?
  3. How different is coding React apps from coding with pure JS?
  4. What benefits do you anticipate from using React?
  5. How would React help you towards having a more structured project management experience?

After discussing this, one member of the team should write down what the group reached in the comment sections.

OOP

  • What is Object-Oriented Programming (OOP)?
  • What are the concepts of OOP in JavaScript?
  • Why are classes important in OOP? How do they help developers write better code?
  • What is the difference between an object and a class in JavaScript?
  • What is inheritance in JavaScript?
  • What is a constructor function in JavaScript?
  • What are getter and setter methods in JavaScript classes
@muslemomar
muslemomar / signin.js
Created May 11, 2023 18:49
A react hook to handle http requests
import { useState } from 'react';
import Router from 'next/router';
import useRequest from '../../hooks/use-request';
export default () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const { doRequest, errors } = useRequest({
url: '/api/users/signin',
method: 'post',