Skip to main content

Posts

Showing posts from February, 2025

How to Publish a Test Version of Your NPM Package

When developing an NPM package, you often need to test pre-release versions before publishing a stable release. Whether for internal development, beta testing, or experimental features, following the right approach ensures a smooth and structured deployment process. This guide walks you through publishing a test version of your package on NPM without affecting production releases. ✅ Steps to Publish a Test Version on NPM 1️⃣ Log In to NPM Before publishing, ensure you are authenticated with NPM: npm login This command will prompt for your NPM username, password, and email . Once authenticated, you can proceed with publishing your test package. 2️⃣ Update package.json Modify your package.json file to include a test version identifier : { "name" : "@your-org/your-package" , "version" : "1.0.0-beta.0" , // Add 'beta' , 'alpha' , or a unique tag "publishConfig" : { "access" : "public" } }...

Should You Use user._id as the customerKey in Toss Payments?

Using user._id directly as customerKey in Toss Payments is not secure because: Exposure Risk  — If customerKey is leaked, attackers can guess or generate valid user IDs. Predictability  — MongoDB ObjectIDs are not cryptographically secure and can be iterated. Tampering  — A user can manipulate their own customerKey if it's predictable. πŸ” Secure Solution: Encrypt the User ID The best approach is to encrypt user._id when using it as customerKey , and be able to decrypt it later for verification. ✅ Step 1: Install crypto for Encryption First, install the crypto module if it's not already included in your project: npm install crypto ✅ Step 2: Create encrypt.js Utility File Create a helper function to encrypt and decrypt user._id securely. import crypto from 'crypto' ; const SECRET_KEY = process. env . ENCRYPTION_KEY || 'your-secure-key-here' ; // Use a secure 32-character key const IV_LENGTH = 16 ; // Initialization vector must be 16 bytes exp...

Fixing FirebaseMessagingError: Requested entity was not found.

If you’re working with Firebase Cloud Messaging (FCM) and encounter the error: FirebaseMessagingError: Requested entity was not found. with the error code: messaging/registration-token-not-registered this means that the FCM registration token is invalid, expired, or unregistered . This issue can prevent push notifications from being delivered to users. πŸ” Possible Causes & Solutions 1️⃣ Invalid or Expired FCM Token FCM tokens are not permanent and may expire over time. If you’re storing tokens in your database, some might be outdated. ✅ Solution: Remove invalid tokens from your database when sending push notifications. Refresh and store the latest FCM token when the app starts. Example: Automatically Refresh Token firebase. messaging (). onTokenRefresh ( ( newToken ) => { // Send newToken to your backend and update the stored token }); 2️⃣ Token Unregistered on Client Device A token might become unregistered if: The app is uninstalled on the user’s device. ...

Fixing expo-updates Error: checkForUpdateAsync() Not Supported in Development

When working with expo-updates , you may encounter the following error: checkForUpdateAsync() is not supported in development builds. This happens because expo-updates only allows update checks in production builds (EAS Update or a standalone app). If you try to run checkForUpdateAsync() in a development environment, it will fail. In this guide, we’ll walk through the solution and explain how to prevent this error from occurring in your Expo project. ✅ Solution: Wrap the Update Check in a Production Check To avoid calling checkForUpdateAsync() in development, modify your function to check if the app is running in a production environment before executing the update logic. Updated Code: import * as Updates from 'expo-updates' ; async function onFetchUpdateAsync ( ) { if (! Updates . isEmbeddedLaunch ) { console . log ( 'Skipping update check in development mode.' ); return ; } try { const update = await Updates . checkForUpdateAsync ();...

Best Practices for Managing Test Data in NestJS with Jest

When writing unit tests for a NestJS application using Jest , effectively managing test data is crucial for ensuring reliability, maintainability, and isolation. In this guide, we'll cover how to organize, create, and utilize test data in NestJS projects following best practices. ✅ 1. Creating Test Data Factory Functions (Dynamic Data Generation) Factory functions allow you to create reusable mock data tailored for different test cases. // src/collection-orders/__mocks__/collectionOrder.factory.ts import { Types } from 'mongoose'; export const createMockCollectionOrder = (overrides = {}) => ({ _id: new Types.ObjectId(), collectionVolume: 10, pickupRequestDate: new Date(), deliveryMan: new Types.ObjectId(), retailStore: new Types.ObjectId(), status: 'booking', ...overrides, // Allow custom overrides }); Fixtures (Static Data) Fixtures are great for static, unchanging data that’s reused across multiple tests. // src/collection-orders/__mocks__/coll...

Cryptocurrency in 2024: Is It Still Worth Investing?

Cryptocurrency has come a long way since Bitcoin’s inception in 2009. The digital asset landscape has evolved rapidly, experiencing massive growth, volatility, regulatory scrutiny, and technological advancements. As we step into 2024, many investors are asking the crucial question: Is it still worth investing in cryptocurrency? In this article, we’ll explore the current state of the crypto market, potential opportunities, risks, and what to consider before making investment decisions. The State of Cryptocurrency in 2024 1. Market Maturity and Stabilization The cryptocurrency market has matured significantly. While volatility remains, we’ve seen more institutional adoption , government involvement , and mainstream acceptance : Bitcoin ETFs are now available in several countries, making it easier for traditional investors to gain exposure. Ethereum’s evolution with Layer 2 scaling solutions has improved transaction speed and reduced costs. Stablecoins like USDC and USDT are widely...

Best AI Tools for Productivity in 2025

As we enter 2025, artificial intelligence (AI) continues to reshape the way we work, enhancing productivity across industries. From automating mundane tasks to providing powerful data-driven insights, AI tools are now indispensable for professionals seeking efficiency and growth. Here’s a roundup of the best AI tools for productivity in 2025 that you should consider integrating into your workflow. 1. ChatGPT (OpenAI) Best for: Writing, brainstorming, and coding assistance ChatGPT remains a top choice for professionals due to its versatile capabilities: Content Creation: Draft emails, articles, and reports effortlessly. Code Generation: Assist with programming tasks, debugging, and code optimization. Idea Generation: Brainstorm creative ideas for marketing campaigns, product names, and more. Pro Tip: Leverage ChatGPT’s advanced APIs to integrate AI into your custom applications. 2. Notion AI Best for: Note-taking, project management, and document organization Notion AI t...

How I Solved the Sandbox Permission Error in Expo for iOS πŸš€

While working on my React Native project with Expo, I encountered this unexpected error when trying to run the iOS app: ❌ error: Sandbox: bash(46816) deny(1) file-read-data /Users/jay/Projects/refeed/thechium/mobile-app/ios/Pods/Target Support Files/Pods-app/expo-configure-project.sh ( in target 'app' from project 'app' ) At first, this error left me puzzled, but after some trial and error, I finally found the solution. Here’s how I approached it and what ultimately fixed the issue. Initial Troubleshooting Steps I initially thought the issue was related to caching problems, so I tried the following steps: ✅ Step 1: Clear Expo Cache Manually expo start - c This command clears the Metro bundler cache, which can resolve many caching-related issues. ✅ Step 2: Clear Derived Data (Xcode Cache) rm -rf ~ /Library/ Developer / Xcode / DerivedData Clearing Xcode’s derived data helps remove old build artifacts that might interfere with the current build. ✅ Step 3: Clear npm/Yar...

Top 10 High-Yield Investment Strategies for 2025

As we step into 2025, investors are looking for high-yield strategies to maximize their returns in an ever-evolving financial landscape. With technological advancements, global market shifts, and changing economic conditions, understanding the best investment opportunities is crucial. Here are the top 10 high-yield investment strategies for 2025 that can help you grow your wealth smartly and securely. 1. Technology Stocks in Emerging Sectors The tech industry remains a powerhouse, but in 2025, the focus is shifting to emerging sectors: Artificial Intelligence (AI): Companies specializing in AI, machine learning, and automation are experiencing explosive growth. Quantum Computing: A frontier technology with immense potential, attracting significant investor interest. Green Tech: Sustainable energy and eco-friendly technologies continue to rise. Tip: Look for tech companies with strong R&D pipelines and solid financials to ensure long-term growth. 2. Real Estate Investment T...