Skip to content

Instantly share code, notes, and snippets.

View montasim's full-sized avatar
💭
𝗟𝗢𝗢𝗞𝗜𝗡𝗚 𝗙𝗢𝗥 𝗡𝗘𝗪 𝗢𝗣𝗣𝗢𝗥𝗧𝗨𝗡𝗜𝗧𝗜𝗘𝗦.

M♢NTΛSIM montasim

💭
𝗟𝗢𝗢𝗞𝗜𝗡𝗚 𝗙𝗢𝗥 𝗡𝗘𝗪 𝗢𝗣𝗣𝗢𝗥𝗧𝗨𝗡𝗜𝗧𝗜𝗘𝗦.
View GitHub Profile
@montasim
montasim / .env.example
Created January 27, 2025 10:35
This file serves as a template for configuring environment variables essential for the development environment.
####################################################
# .env.production Configuration File
####################################################
# This file serves as a template for configuring environment variables essential for the development environment.
# Adjust these settings to align with your specific development needs and infrastructure requirements.
####################################################
# APPLICATION ENVIRONMENT
@montasim
montasim / eslint.config.mjs
Created December 26, 2024 12:20
This configuration includes rules and settings for general JavaScript and React projects. It aims to enforce best practices, coding conventions, and ensure code consistency.
import globals from 'globals';
import pluginJs from '@eslint/js';
import pluginReact from 'eslint-plugin-react';
/**
* ESLint configuration for a JavaScript/TypeScript project.
*
* This configuration includes rules and settings for general JavaScript and React projects.
* It aims to enforce best practices, coding conventions, and ensure code consistency.
*
####################################################
# .nvmrc Configuration File
####################################################
# Purpose:
# The .nvmrc file is used with Node Version Manager (NVM) to specify
# the required version of Node.js for this project. By defining the
# Node.js version, all developers and environments will use the same
# version, ensuring consistency and preventing issues caused by version
# mismatches during development or deployment.
@montasim
montasim / addUseStrict.js
Last active December 26, 2024 12:15
Adds the 'use strict'; directive to the top of a JavaScript file if it's not already there.
'use strict';
import fs from 'fs';
import path from 'path';
/**
* Represents the file system path to the 'shared' directory.
* The path is constructed by resolving the current working directory and appending 'shared' to it.
* It can be used to reference or access files and sub-directories located within the 'shared' directory.
*

CONTRIBUTOR LICENSE AGREEMENT (CLA)

Thank you for your interest in contributing to our project! To ensure that our project remains sustainable and that contributions can be integrated smoothly, we require all contributors to agree to the following Contributor License Agreement ("Agreement"). This Agreement helps us maintain the quality and integrity of the project while respecting your rights as a contributor.


Table of Contents

@montasim
montasim / generate-project-structure.js
Created August 13, 2024 16:19
Recursively generates a tree structure of the directory.
import fs from 'fs';
import path from 'path';
/**
* Recursively generates a tree structure of the directory.
*
* @param {string} dir - The directory to scan.
* @param {string} [prefix=''] - The prefix used for formatting the tree structure.
* @param {string} [output=''] - The accumulated output string containing the directory structure.
* @returns {string} - The complete directory structure as a string.
import errorResponse from '../utilities/errorResponse.js';
import httpStatus from '../constant/httpStatus.constants.js';
import sendResponse from '../utilities/sendResponse.js';
import loggerService from '../service/logger.service.js';
import toSentenceCase from '../utilities/toSentenceCase.js';
const getResourceById = async (model, populateMethod, resourceId, resourceType) => {
try {
const resource = await populateMethod(model.findById(resourceId));
if (!resource) {
import { Schema } from 'mongoose';
import constants from '../constant/constants.js';
import userConstants from '../modules/api/users/users.constants.js';
import patterns from '../constant/patterns.constants.js';
// Define the shared username schema
const usernameSchema = {
type: String,
trim: true,
import asyncErrorHandlerService from '../utilities/asyncErrorHandler.js';
import getRequesterId from '../utilities/getRequesterId.js';
import loggerService from '../service/logger.service.js';
import getHostData from '../utilities/getHostData.js';
import getRequestedDeviceDetails from '../utilities/getRequestedDeviceDetails.js';
// TODO: Implement the `entity` log
// TODO: utilize the hostData for every entity
const createNewUserEntity = (service, createFunction) =>
import NodeCache from 'node-cache';
import loggerService from '../service/logger.service.js';
const cache = new NodeCache();
const create = (duration = 3600) => {
return (req, res, next) => {
let key;