Skip to content

Instantly share code, notes, and snippets.

View nurmdrafi's full-sized avatar
:octocat:
Focusing

Nur Mohamod Rafi nurmdrafi

:octocat:
Focusing
View GitHub Profile
@nurmdrafi
nurmdrafi / secure-localstorage.md
Last active April 7, 2025 04:29
Building a Secure LocalStorage Utility with crypto-js

Building a Secure LocalStorage Utility with crypto-js

Browser's LocalStorage is convenient but stores data in plaintext, creating security risks. Let's build a TypeScript utility that adds encryption using crypto-js to better protect client-side data.

The Problem with Default LocalStorage

LocalStorage has three key security issues:

  • Stores everything as plaintext
  • Vulnerable to XSS attacks
  • No built-in expiration mechanism
@nurmdrafi
nurmdrafi / prompts.md
Last active March 26, 2025 20:19
Unit Test Prompts

Vitest setup

MOCK SETUP CONFIGURATION WORKFLOW

PHASE 1: PROJECT STRUCTURE ANALYSIS
1. Redux: Located in redux/, with feature-specific logic in redux/features/
2. API Responses: Used in pages/ and hooks/
3. LocalStorage/SecureLocalStorage: Used in utils/ or directly in components
4. Tests: Stored in __tests__/ with mocks designed for testing
@nurmdrafi
nurmdrafi / test-coverage.md
Created March 5, 2025 07:42
Test Coverage Integration with SonarQube and GitHub Actions

Test Coverage Integration with SonarQube and GitHub Actions

This document outlines the steps taken to integrate test coverage reporting into SonarQube using GitHub Actions for the Laboni Express project.

Overview

The goal was to ensure that test coverage data (generated by Vitest) is correctly reported to SonarQube during the CI/CD pipeline. This involved:

  1. Generating test coverage files in GitHub Actions.
  2. Configuring Vitest to generate coverage files.
@nurmdrafi
nurmdrafi / template.md
Created March 3, 2025 15:45
Folder Structure
src/
├── app/                          # Next.js app router
│   ├── (marketing)/              # Public pages (e.g., home, about)
│   ├── (shop)/                   # Shop-related pages
│   ├── (product)/                # Product-related pages
│   ├── (admin)/                  # Admin-related pages
│   ├── layout.tsx                # Root layout
│   └── page.tsx                  # Home page
├── components/                   # Reusable components
@nurmdrafi
nurmdrafi / template.md
Last active January 26, 2025 15:14
Frontend Documentation Template

[Project Title]

1. Project Overview

Description

Insert a brief and concise description of the project. For example: "A web application for [briefly state the main purpose, e.g., tracking expenses, managing tasks, creating a portfolio]."

Purpose

@nurmdrafi
nurmdrafi / cmd.md
Last active March 3, 2025 08:55
Terminal Config

Bash

# Enable the subsequent settings only in interactive sessions
case $- in
  *i*) ;;
    *) return;;
esac

# Path to your oh-my-bash installation.
export OSH='/home/nurmdrafi/.oh-my-bash'

tsconfig.json

{
  "compilerOptions": {
    "typeRoots": ["node_modules/@types"],
    "baseUrl": ".",
    "paths": {
      "@components/*": ["components/*"],
      "@hooks/*": ["hooks/*"],
 "@features/*": ["redux/features/*"],
@nurmdrafi
nurmdrafi / shadcn.config.md
Last active November 14, 2024 11:17
typescript eslint config for shadcn UI

tsconfig.json

{
{
	"compilerOptions": {
		"target": "es2022",
		"lib": ["dom", "dom.iterable", "esnext"],
		"allowJs": true,
		"skipLibCheck": true,