teleren/devto huggingface dataset:
Simplify your Next.js Middleware
Tags: webdev, javascript, programming, nextjs
Published: 2024-01-13 14:14:19

## Motivation
I’m working with Next.js project for a few years now, after Vercel moved multiple /**/_middleware.ts files to a single /middleware.ts file, there was a unfilled gap - but just for now. After a 2023 retro I had found that there is no good solution for that problem, so I took matters into my own hands. I wanted to share that motivation with everyone here, as I think that we all need to remember how it all started.

Hope it will save you some time and would make your project DX better!

## The problem
By default Next.js supports only one middleware.ts file, in which you need match routes with logic by your own which can be pretty problematic and chaotic. Also it’s endlessly making middleware boilerplate bigger.

```ts
// example code source: https://github.com/vercel/next.js/blob/canary/examples/middleware/middleware.ts

import { NextRequest, NextResponse } from 'next/server'

export function middleware(request: NextRequest) {
  if (request.nextUrl.pathname === '/about') {
    return NextResponse.redirect(new URL('/redirected', request.url))
  }
  if (request.nextUrl.pathname === '/another') {
    return NextResponse.rewrite(new URL('/rewrite', request.url))
  }
  return NextResponse.next()
}

export const config = {
  matcher: ['/about/:path*', '/another/:path*'],
}
```

This exmaple is not that scary, but imagine adding more complex logic for few more routes… (ugh)

## The solution
Let me introduce to you my latest package called next-easy-middleware.

### Installation:

```bash
pnpm add next-easy-middleware
```
```bash
npm install next-easy-middleware
```
```bash
yarn add next-easy-middleware
```
```bash
bun add next-easy-middleware
```

### Usage:

```ts
import { createMiddleware } from 'next-easy-middlewares';
import { type NextRequest, NextResponse } from 'next/server';

import { analyticsMiddleware } from '@shared/analytics/middleware';
import { authMiddleware, loginMiddleware } from '@/app/(auth)/_middleware';
import { docsMiddleware } from '@/app/(docs)/_middleware';
import { blogMiddleware, blogViewsMiddleware } from '@/app/(blog)/_middleware';
import { postsMiddleware } from '@/app/(posts)/_middleware';

const middlewares = {
  '/login': loginMiddleware,
  '/docs/:path*: docsMiddleware,
  '/blog/[slug]': blogMiddleware,
  '/blog/[slug]/view': blogViewsMiddleware,
  'regex:^/posts/\\d+$': postsMiddleware,
};

const globalMiddlewares = {
  before: authMiddleware,
  after: analyticsMiddleware
}

export const middleware = createMiddleware(middlewares, globalMiddlewares);

export const config = {
  matcher: ['/((?!api/|_next/|_static|_vercel|[\\w-]+\\.\\w+).*)'],
};
```

## Feedback
I’m awaiting your feedback about that solution, also feelfree to contribute to that package in below repository.

https://github.com/z4nr34l/next-easy-middlewares

Enjoy!
LinkFB88
Published: 2024-01-13 14:11:51

LinkvaoFB88 -  Link vào FB88 mới nhất không bị chặn. Link truy cập chính thống của nhà cái FB88 mới nhất. Tham gia cá cược trực tuyến cực dễ dàng và uy tín cùng nhà cái thể thao hàng đầu. FB88 - Nhà cái đẳng cấp thời thượng nhất 2024
Tên thương hiệu:  FB88
Website: https://linkvaofb88vn.com/
Email: linkvaofb88vn@gmail.com
SĐT: 0368010136
Địa chỉ: 211 Nguyễn Trường Tộ, Hưng Đông, Thành phố Vinh, Nghệ An, Việt Nam
#fb88 #linkvaofb88vn #linkfb88 #linkvaofb88
https://twitter.com/linkvaofb88vn
https://vimeo.com/linkvaofb88vn2024
https://www.pinterest.com/linkvaofb88vn2024/
https://www.tumblr.com/linkvaofb88vn24
https://www.twitch.tv/linkvaofb88vn2024/about
https://www.youtube.com/@linkvaofb88vn24
https://500px.com/p/linkvaofb88vn1?view=photos
https://www.flickr.com/people/199861127@N05/
Please note Cool 3D Portfolio Website
Published: 2024-01-13 14:08:41

Hello Everyone!

Excited to connect with this dynamic group!

With over 7 years of intensive experience in the digital realm, I've honed my skills to become a powerhouse in Web/Mobile/Blockchain app development, with a special flair for immersive 3D experiences utilizing UE5, Unity, Three.js, Fiber, WebGL/AR/VR/XR, and state-of-the-art 3D modeling techniques. 🎨✨

I am thrilled to announce that I am now open to collaborating with new clients who are seeking to breathe life into their visionary projects. Whether it's a groundbreaking app concept or a complex web development idea, I am here to lend my expertise and guide you towards a beautifully executed final product.

But that's not all – I firmly believe in the power of solid planning and an efficient workflow. To show you just how committed I am to the success of your projects, I’m offering FREE consulting sessions to discuss development solutions tailor-fitted to your needs. 🆓📈

Love what you see? I invite you to delve deeper into my portfolio of work at the following link:

🔗 https://cryptosmiler.vercel.app/

Experience first-hand my dedication and passion for crafting digital masterpieces. I’m eager to explore how we can collaborate to turn your ideas into vibrant, interactive realities.

Thank you for considering me as a partner in your journey towards digital innovation. Reach out now to book your free consultation and let's create something incredible together!

🚀 Ready to get started? Contact me directly through my zhijiwang0@gmail.com or just hit reply to this message!

Looking forward to making digital magic with you!

Warm Regards.
Exploring the Benefits and Considerations of Malegra 100
Published: 2024-01-13 13:53:03

**[Malegra 100](https://bit.ly/45l4eXC)** contains sildenafil citrate, a well-known phosphodiesterase type 5 (PDE5) inhibitor. It works by increasing blood flow to the penile region, aiding men in achieving and sustaining an erection. This mechanism of action is similar to that of Viagra, making Malegra 100 a popular and more affordable alternative.
Benefits:
Users often report positive outcomes with Malegra 100, experiencing improved sexual performance and increased confidence. The medication typically takes effect within 30-60 minutes after ingestion, allowing for spontaneity in intimate moments. Many appreciate the convenience and reliability it offers, contributing to an enhanced overall sexual experience.
Considerations and Precautions:
While Malegra 100 has shown efficacy, it's essential to consider individual health factors and consult a healthcare professional before use. Potential side effects may include headaches, dizziness, and indigestion, but these are generally mild and temporary. It's crucial to disclose your medical history and any ongoing medications to ensure compatibility with Malegra 100.
Dosage and Usage:
The recommended starting dose is often 50mg, with adjustments made based on individual response and tolerance. It's crucial not to exceed the prescribed dosage and to avoid alcohol consumption while using Malegra 100, as it can increase the risk of side effects.
Community Experiences:
If you've used Malegra 100, please share your experiences here. How has it impacted your life? Were there any side effects or considerations you wish you had known earlier? Your insights can be valuable for others considering or currently using Malegra 100.
Remember, individual responses to medications can vary, and professional medical advice is essential. Let's keep this discussion informative and supportive for everyone in the community!
Visit Also:  **[Vilitra 20](https://erxcart.com/product/vilitra-20-mg/)** | **[Vilitra 40 ](https://erxcart.com/product/vilitra-40-mg/)**| **[Cenforce 100](https://bit.ly/3RQLY5y)** | **[Malegra 200](https://bit.ly/3PHxMJn)** | **[Fildena 100
](https://erxcart.com/product/fildena-100-mg/)**
Apple iPhone Service Centre
Published: 2024-01-13 13:49:14

Welcome to iCure Solutions, [Apple Service Centre in Delhi](https://www.icuresolutions.com). We specialize in comprehensive Apple computer and iPhone repair services, ensuring your devices get the care they deserve. Our skilled technicians at the Apple Service Centre in Preet Vihar are dedicated to delivering top-notch Mac computer repair and iPhone services. Conveniently located, we are the go-to Apple Service Centre near you. From Macbook repairs to iPhone fixes, our expert team is equipped to handle it all. For reliable Apple service and support, contact iCure Solutions at 9643440430. Your satisfaction is our priority.

Visit: [https://www.icuresolutions.com](https://www.icuresolutions.com)
Discover Awesome Productivity Tools On GitHub
Tags: productivity, productivitytips, productivitydirectory, productivitytools
Published: 2024-01-13 13:41:57

### Introducing My GitHub Repository: Awesome Productivity Tools & The Upcoming [Productivity Directory](https://Productivity.Directory) Website

As an indie maker passionate about productivity, I'm thrilled to introduce two of my latest projects designed to boost your efficiency and organization: my meticulously curated GitHub repository, [Awesome Productivity Tools](https://github.com/productivitydirectory/awesome-productivity-tools), and the upcoming launch of my comprehensive website, productivity.directory.

**What is Awesome Productivity Tools?**

[Awesome Productivity Tools](https://github.com/productivitydirectory/awesome-productivity-tools) is a GitHub repository where I've compiled the top productivity tools across various categories like task management, time tracking, and note-taking. It's a carefully selected list aimed at those looking to enhance their productivity practices.

**But There's More - Announcing Productivity.Directory!**

While the GitHub repository showcases a selection of top-rated tools, I understand the need for a more exhaustive resource. That's why I'm creating productivity.directory - a website that will host a diverse range of tools, insightful articles, and tips to supercharge your productivity journey. Whether you're just starting or looking to upgrade your productivity skills, productivity.directory will be your go-to resource.

**Why You Should Be Excited**

1. **Curated Quality**: My GitHub list presents the best tools in each category, ensuring you get the most reliable recommendations.
2. **Community Involvement**: I welcome your suggestions and insights to enhance these resources.
3. **Continuous Updates**: The world of productivity tools is always evolving, and so will these resources.

**How You Can Get Involved**

Your participation and feedback are vital. You can contribute to [Awesome Productivity Tools](https://github.com/productivitydirectory/awesome-productivity-tools) by suggesting tools that have significantly boosted your productivity. And keep an eye out for the launch of productivity.directory for an expansive array of productivity resources.

**A Peek Into the Repository**

Some categories in the GitHub repository include:
- Task Management (e.g., Trello, Asana)
- Note Taking (e.g., Evernote, Notion)
- Time Tracking (e.g., Toggl, RescueTime)
- ... and more, featuring only the best tools in each category!

**Join Me on This Productivity Journey**

My mission is to create a space where discovering the right productivity tools is straightforward and efficient. Explore [Awesome Productivity Tools](https://github.com/productivitydirectory/awesome-productivity-tools) today, and stay tuned for the upcoming launch of productivity.directory. Let's navigate the vast world of productivity tools together and find those that best suit our individual needs.

**Together, Let's Make Every Day More Productively Remarkable!**
Simplifying Vue Router with Vue Route Handler: A Laravel-inspired Approach
Tags: vue, vuerouter, laravel, vuelaravel
Published: 2024-01-13 13:29:26


Vue Route Handler is a powerful library designed to streamline the process of defining routes for Vue Router. Taking inspiration from the elegant structure of Laravel routes, this library offers a fluent and expressive syntax for constructing routes in Vue applications.

## Installation
To get started with Vue Route Handler, simply install the latest version using npm or yarn:

```
npm i vue-route-handler
# or
yarn add vue-route-handler
```

## Overview
Vue Route Handler simplifies the declaration of route definitions for Vue Router by employing chained calls, reminiscent of Laravel. This allows you to easily group and nest routes as deeply as necessary.

Let’s explore a basic example:

```
import { createRouter, createWebHistory } from "vue-router";
import { Factory, Guard, Route } from "vue-route-handler";
import Home from "./views/Home.vue";
import About from "./views/About.vue";


Route.view({ path: "/", view: Home }).name("home");
Route.view({ path: "about", view: About }).name("about");

const router = createRouter({
  routes: Factory.routes(),
  history: createWebHistory(),
});

export default router;
```

The above code sets up a router using the Vue Route Handler, providing a clean and organized way to define routes.

## Laravel-inspired Structure

Taking inspiration from Laravel, Vue Route Handler introduces a familiar structure to Vue Router. You can group routes, apply guards, and nest routes within each other, creating a hierarchy that mirrors the organization of your application.

## Using Resolver for Dynamic Imports
Vue Route Handler supports dynamic imports using the usingResolver method and import.meta.globEager. This allows you to import views dynamically, providing a more efficient and modular approach to managing your views.

Package Link :[https://www.npmjs.com/package/vue-route-handler](https://www.npmjs.com/package/vue-route-handler)
Demo Link: [https://vue-route-handler.vercel.app/](https://vue-route-handler.vercel.app/)
Ibuprofeno.py💊| #22: Explica este código Python
Tags: python, learning, beginners, spanish
Published: 2024-01-13 13:22:23

## **<center>Explica este código Python</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```py
## Reto #22

persona = {
  "nombre": "Cris",
  "apellido": "Villca",
  "edad": 27,
  "soltero": False,
  "direccion": {
    "calle": 17,
    "avenida": "Tomas Monje",
    "pasaje": "A"
  }
}

print(persona.get("direccion").get("avenida").upper())
```

- A. `None`
- B. `TOMAS MONJE`
- C. `tomas monje`
- D. `ToMaS mOnJe`

---

Respuesta en el primer comentario.
minhtruongceofabetwin
Published: 2024-01-13 13:00:49

Minh Trường Fabet là một tác giả và người sáng lập đằng sau trang web https://fabet.win/, một nền tảng cá cược bóng đá và nhà cái thể thao uy tín hàng đầu. Với sự tận tâm và đam mê trong lĩnh vực cá cược, Minh Trường đã xây dựng một trang web đáng tin cậy và phục vụ hàng triệu người chơi trên khắp thế giới.#minhtruong #minhtruongfabet #adminfabetwin #ceofabetwinThông tin chi tiết:Email: minhtruongceofabetwin@gmail.comĐịa chỉ: 34 Trương Định, Tương Mai, Hoàng Mai, Hà Nội, Vietnam 
[https://fabet.win/](https://fabet.win/)
Unlocking State Management Simplicity with Zustand! 🚀
Published: 2024-01-13 12:53:51



Hey fellow developers! 💻✨ Today, let's talk about Zustand, a state management library for React that brings simplicity to a whole new level. If you're tired of boilerplate code and looking for a lightweight yet powerful solution, Zustand might be your new best friend. 🌐🚀

Why Zustand?
🚄 Lightweight: Say goodbye to heavy setups. Zustand weighs only a few KBs, keeping your app nimble and fast.
⚛️ React-First Approach: Built with React in mind, seamlessly integrates into your components.
🔄 Effortless Setup: With minimal setup, you're ready to manage state with ease.

Why We Love It:
💡 Predictable State Updates: Zustand simplifies state updates, making your code predictable and maintainable.
🔄 Efficient Reactivity: Automatically re-renders components when relevant state changes, optimizing performance.

🌟 Zustand is a must-try for your next project! Its ease of use and flexibility make it a great alternative to other state managers like Redux, Jotai, or Recoil.

## Code:

```
// bookStore.ts
import create from 'zustand';

interface IBook {
  amount: number;
  updateAmount: (newAmount: number) => void;
}

export const useBookStore = create<IBook>((set) => ({
  amount: 40,
  updateAmount: (newAmount: number) => set({ amount: newAmount }),
}));


// App.tsx
import { useBookStore } from './store/bookStore';

const App = () => {
  const amount = useBookStore(state => state.amount);
  const updateAmount = useBookStore(state => state.updateAmount);

  return (
    <div>
      <h1> Books: {amount} </h1>
      <button onClick={() => updateAmount(10)}> Update Amount </button>
    </div>
  )
}
```

Ready to Simplify Your State Management? Let's dive into Zustand! 👩‍💻👨‍💻
iPad Screen Replacement
Tags: ipadrepair
Published: 2024-01-13 12:52:59

Discover expert iPad repair services at iCure Solutions! We specialize in [iPad screen replacement](https://www.icuresolutions.com/ipad-repair/) and display repairs, ensuring your device looks brand new. Our [Apple Service Centre](https://www.icuresolutions.com/) is equipped to handle various iPad models, offering quality solutions for any issue. Trust us for efficient and reliable iPad repair service. Call iCure Solutions at 9643440430 for a hassle-free experience. Your iPad deserves the best – choose iCure Solutions for excellence in iPad repair!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/prnfdlgptc05hdxkzshr.jpg)
The responsive state engine Helux's playground has been released
Published: 2024-01-13 12:30:24

The responsive state engine Helux's playground has been released. Welcome to experience it, real time editing of code and viewing of runtime effects helps to quickly learn the basic usage methods of APIs.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84hvyh2qsiog426zbxa8.png)
"Day 10: Excel Essentials Unveiled - Sharing Today's Insights on My Learning Adventure! 📊🚀 #ExcelSkills #LearningJourney"
Tags: data, analyst, excel, datascience
Published: 2024-01-13 12:24:33

EXCEL - 9



Data Validation: Setting up Drop-down Lists and Ensuring Data Accuracy

Data validation in Excel is a feature that allows you to control and restrict the type of data that can be entered into a cell. It ensures data accuracy, reduces errors, and streamlines data entry by defining specific rules or criteria. Two key aspects of data validation are setting up drop-down lists and ensuring data accuracy.

Setting up Drop-down Lists:
One of the most common uses of data validation is to create drop-down lists. This feature limits the choices available in a cell to a predefined list of options.

How to set up a drop-down list:
Select the cell or range where you want the drop-down list.
Go to the "Data" tab on the Ribbon.
Click on "Data Validation."
In the Data Validation dialog box, choose "List" as the validation criteria.
Specify the source of the list (e.g., a range of cells or a predefined list).
Click "OK" to apply the drop-down list.



Ensuring Data Accuracy:
Data validation helps ensure the accuracy and consistency of your data by preventing users from entering invalid or unexpected values.

Types of validation criteria:

Whole Number/Decimal: Restricts entries to whole numbers or decimals.
Date/Time: Ensures entries are valid dates or times.
Text Length: Limits the length of the text entered.
Custom Formula: Allows you to define custom criteria using Excel formulas.
List: As mentioned earlier, restricts entries to a specified list of options.
By enforcing these criteria, data validation reduces the likelihood of errors and maintains the integrity of your dataset.

Benefits of Data Validation:
Consistency
Efficiency
Data Integrity
User-Friendly

In summary, data validation is a powerful tool in Excel that enhances data accuracy and efficiency.

Follow me on this where every day will be added if i learn something new about it  :- https://dev.to/nitinbhatt46



Thank you for your time.
recover from panic in Golang
Tags: go, panic
Published: 2024-01-13 12:22:43

I am back after almost a year. Meanwhile I started learning golang, and next few blogs will be on golang. Go is good language to build efficient and reliable software. Like any other programming language, there is possibility of error also in Go. Compile time errors detected by compiler before application run. Runtime time error occur during program execution, and if it is not handle properly, it can break the application and abort program. While writing code, a programmer try to cover all the error scenario, but there is possibility we might not handle some errors. When runtime error occur, it refer as program panicked. Runtime error is panic in golang.

Recover is a built-in function provided by go to handle panic. A recover can stop a panic from aborting the program. A recover function can handle the panic in the goroutine that has implemented the recover and not all goroutine. You can refer the below code to understand how recover handle the panic in respective goroutine.

```
package gortntry

import "fmt"

func panicFun(flag int) {
	if flag == 2 {
		defer func() {
			recover()
		}()
	}
	fmt.Println("inside the panic func")
	panic("panic in goroutine")
}

func TryPanic(flag int) {
	if flag == 1 || flag == 2 {
		defer func() {
			recover()
		}()
	}
	go panicFun(flag)
	panic("panic in main")
}
```
We have two function TryPanic and panicFunc. TryPanic is the main entry function, and we call panicFunc inside it. Recover enabled in TryPanic for flag value 1 or 2 and in panincFunc for value 2. I have used defer here that I will explain in different blog post.

When we pass flag value **1** in TryPanic the output is:

```
panic: panic in goroutine

goroutine 5 [running]:
golibcustom/goroutineplgrnd.panicFun(0x0?)
	/Users/amitt/Documents/Personal Data/personalproj/go-practice/goroutineplgrnd/gortn-panic.go:13 +0x50
created by golibcustom/goroutineplgrnd.TryPanic in goroutine 1
	/Users/amitt/Documents/Personal Data/personalproj/go-practice/goroutineplgrnd/gortn-panic.go:22 +0x64
exit status 2
```

It means recover in TryPanic handle the main goroutine panic but not the panic that occur in other goroutine in panicFunc.

For flag value **2** there is no panic because both goroutine has recover function.

If we use any **other** value for example 3 then main goroutine panic and it abort the program without waiting for the panicFunc.

```
panic: panic in main

goroutine 1 [running]:
golibcustom/goroutineplgrnd.TryPanic(0x2)
	/Users/amitt/Documents/Personal Data/personalproj/go-practice/goroutineplgrnd/gortn-panic.go:23 +0x78
main.main()
	/Users/amitt/Documents/Personal Data/personalproj/go-practice/main.go:36 +0x20
exit status 2
```
Latest Newsletter: Everything Bitcoin (Issue #149)
Tags: javascript, tech, webdev, discuss
Published: 2024-01-13 12:12:30

---
title: Latest Newsletter: Everything Bitcoin (Issue #149)
published: true
description: Bitcoin ETFs, Bitcoin history, generative AI legal discussion, webdev juniors vs AI, and my website’s new incredibly sexy everything RSS feed. Lol worst issue desc ever. Brain full.
tags: javascript, tech, webdev, discuss
---
Latest Newsletter: Everything Bitcoin (Issue #149)

Bitcoin ETFs, Bitcoin history, generative AI legal discussion, webdev juniors vs AI, and my website’s new incredibly sexy everything RSS feed. Lol worst issue desc ever. Brain full.

https://markjgsmith.substack.com/p/saturday-13th-january-2024-everything

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)