Skip to content

Instantly share code, notes, and snippets.

View CorentynDevPro's full-sized avatar
🎯
Focusing

CorentynDevPro CorentynDevPro

🎯
Focusing
  • France
  • 04:55 (UTC +02:00)
View GitHub Profile
@CorentynDevPro
CorentynDevPro / auth.js
Created May 1, 2025 16:29
🧠 JWT Authentication Middleware in Express.js
// middleware/auth.js
const jwt = require('jsonwebtoken');
// The secret must be stored in the environment variables
const JWT_SECRET = process.env.JWT_SECRET;
const authenticateToken = (req, res, next) => {
// Retrieve the token from the Authorization header
const authHeader = req.headers['authorization'];
@CorentynDevPro
CorentynDevPro / hashPassword.go
Created May 1, 2025 15:55
Hashing a password with bcrypt (JS, Python, Go)
package main
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func main() {
password := []byte("mySecurePassword123")
@CorentynDevPro
CorentynDevPro / server.py
Created May 1, 2025 14:28
💻 The Code: FastAPI server minimal in 10 lines
# 1. Import FastAPI
from fastapi import FastAPI
# 2. Create the app
app = FastAPI()
# 3. Main GET route
@app.get("/")
async def read_root():
return {"message": "Hello World"}
@CorentynDevPro
CorentynDevPro / server.js
Created May 1, 2025 08:58
🚀Create an ultra-minimalist server with Express.js
// Import the Express framework
const express = require('express');
// Create the Express application
const app = express();
// Default port or the one defined by the environment
const PORT = process.env.PORT || 3000;
// Define a basic GET route
@CorentynDevPro
CorentynDevPro / README.md
Created May 1, 2025 08:04
🏷️Generate a UUID (v4) in JS, Python, Bash, Go, Rust

Prerequisites

In order to be able to generate a UUID you have to pay attention on the several configurations below.


Bash

  • uuidgen comes pre-installed on most UNIX systems. Please take a look if you have an error while generating the UUID.
@CorentynDevPro
CorentynDevPro / generateJsonWebToken.js
Last active April 29, 2025 18:11
🔐 Need a secure JWT_SECRET for your API?
// Module import to generate random keys
const crypto = require('crypto');
// Generate 64 random octets then convert them in a hexadecimal String
const secret = crypto.randomBytes(64).toString('hex');
// Print the JsonWebToken secret in the console
console.log(secret);