Skip to content

Instantly share code, notes, and snippets.

View programmerShinobi's full-sized avatar
🇮🇩
Work from anywhere

FaQih programmerShinobi

🇮🇩
Work from anywhere
View GitHub Profile

RBAC with JWT Authentication in Express

This project demonstrates how to implement Role-Based Access Control (RBAC) using JWT authentication in an Express.js application. The app will handle authentication and authorization based on user roles: Admin, Editor, and Viewer. Each role has different levels of access to various routes.


Project Setup

1. Initialize the Project

@programmerShinobi
programmerShinobi / steps-to-clone-a-git-repository-and-push-for-the-first-time-on-a-new-pc.md
Last active November 4, 2024 01:55
Steps to Clone a Git Repository and Push for the First Time on a New PC

Steps to Clone a Git Repository and Push for the First Time on a New PC

1. Ensure Git is Installed

If you haven't installed Git on your PC, download and install it from the official Git website.

2. Configure Git

Set your global username and email:

$ git config --list --show-origin
$ git config --global user.name "Your Name"
@programmerShinobi
programmerShinobi / redis-commander.md
Last active October 25, 2024 12:15
Redis Commander

Redis Commander

Here’s how you can use the KEYS command in Redis Commander:

Keys: KEYS

  • Command: KEYS pattern
  • Function: The KEYS command is used to find all keys matching a specific pattern. This can be especially helpful when you want to locate keys with a common prefix, suffix, or specific pattern in their names. In Redis Commander, you can use this command to search for keys that match the pattern you specify.
  • Example:
    • Pattern: example:*
  • Command: KEYS example:*
@programmerShinobi
programmerShinobi / steps-to-update-version-push-and-manage-git-tags.md
Last active October 16, 2024 21:10
Steps to Update NPM Version, Push, and Manage Git Tags

Steps to Update NPM Version and Manage Git Tags

1. Update the NPM Version

Run the command below to increment the version:

$ npm version <major | minor | patch> -m "<message>"
  • Replace <major | minor | patch> with:
    • major for significant changes.
  • minor for backward-compatible enhancements.
@programmerShinobi
programmerShinobi / deployment-manual-instructions-for-updating-an-application-or-service-using-docker.md
Last active October 24, 2024 15:05
Deployment Manual Instructions for Updating an Application or Service (ahi-backend) from Version 1.2.32 to Version 1.2.33 Using Docker

Instructions for deploying the ahi-backend version 1.2.33 using Docker

Steps

  1. Navigate to the project directory:

    cd workspace/ahi-backend/
  2. Check the active Git branch:

@programmerShinobi
programmerShinobi / how-to-install-php-and-composer-on-linux-ubuntu.md
Last active October 24, 2024 14:59
How to install PHP & Composer with extension (sqlsrv & pdo_sqlsrv) on Linux (Ubuntu 22.04)

Install PHP and Composer

1. Install PHP

Update and upgrade the system:

$ sudo apt update
$ sudo apt upgrade
@programmerShinobi
programmerShinobi / how-to-create-or-update-file.md
Last active October 24, 2024 15:01
How To Create Or Update a File

Create or Update test.txt

To create or update the test.txt file using the following command:

$ cat << EOF > test.txt
  This is the first line.
  This is the second line.
 EOF
@programmerShinobi
programmerShinobi / validation-and-controller-setup-in-nestjs.md
Last active October 24, 2024 15:20
Validation and controller setup in NestJS (Series 04)

Validate and Set Up Controllers in NestJS

  1. Create a Serializer Interceptor
    Create serializer.interceptor.ts to handle response serialization.
    // src/utils/serializer.interceptor.ts
    import {
      CallHandler,
      ExecutionContext,
      Injectable,
@programmerShinobi
programmerShinobi / typeorm-integration-with-migrations-in-nestjs-using-docker.md
Last active November 4, 2024 01:03
TypeORM integration with migration in NestJS using Docker (NestJS Series 03)

How to Integrate TypeORM with migrations in NestJS using Docker | Ubuntu 22.04 (Jammy)

  1. Get the latest version of the PostgreSQL image.
    $ sudo docker pull postgres
  2. Run a PostgreSQL container with the name my-postgres, and run the container in the background.
    $ sudo docker run --name my-postgres \
      -e POSTGRES_USER=postgres \
      -e POSTGRES_PASSWORD=postgres \
@programmerShinobi
programmerShinobi / load-env-using-config-module-in-nestjs.md
Last active September 24, 2024 05:01
Load .env using Config Module in NestJS (NestJS Series 02)

How to Load .env using Config Module in NestJS

  1. Add @nestjs/config library to your dependencies in package.json
    $ yarn add @nestjs/config
  2. Add src/modules/config/app.config.ts
     // src/modules/config/app.config.ts
    
    import { registerAs } from '@nestjs/config';