Snippets
Small pieces of code pulled out of my projects: the fixes and patterns I'd otherwise go hunting for again. Copy anything you need.
- TypeScriptfrom PortfolioFix NextAuth Discord login: issuer must be configuredDiscord now sends iss on the OAuth callback, and NextAuth v4 rejects it unless the provider declares an issuer.NextAuthDiscordOAuth
- TypeScriptfrom PortfolioRun a job once per time window with a Redis lockLet any number of callers trigger a job, but run it at most once every 5 minutes.RedisUpstashCron
- TypeScriptfrom PortfolioSend each Discord announcement exactly onceUse SADD's return value to announce new devlog posts once, and retry when Discord fails.RedisDiscordWebhooks
- Luafrom Conflict RoleplayA small HTTP API inside a FiveM resourceRoute GET and POST requests to Lua handlers with SetHttpHandler, with a shared-secret check.FiveMLuaHTTP