Skip to content

Instantly share code, notes, and snippets.

@smyaseen
smyaseen / middleware.ts
Created June 18, 2024 08:35
Validate user authentication on edge with NextAuth & NextJS Middleware
import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
import { getToken } from 'next-auth/jwt';
import { withAuth } from 'next-auth/middleware';
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
@smyaseen
smyaseen / commit-msg
Last active November 25, 2023 12:44
Husky commit-msg hook to check branch & commit message convention, run lint, prettier and unit tests.
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Checks for branch name
currentBranch=$(git rev-parse --abbrev-ref HEAD)
requiredPattern="^(build|chore|feat|docs|refactor|perf|test)/ABC-\d+-.+$"
if ! echo "$currentBranch" | grep -qE $requiredPattern; then
@smyaseen
smyaseen / PULL_REQUEST_TEMPLATE.md
Last active November 19, 2023 15:06
Extensive GitHub Pull Request Template

Description

What type of PR is this? (check all applicable)

  • 🍕 Feature - A new feature.