Building a Temporary Message Sharing API with NestJS, PostgreSQL, Prisma & Redis
I recently built a temporary message-sharing API from scratch using NestJS, PostgreSQL, Prisma and Redis . The idea is simple: Create a message, generate a short code, share it, and let the message automatically expire. But while building it, I wanted to go beyond a basic CRUD API and understand how things like validation, password protection, visit limits, atomic database updates, caching, TTLs,…
The temporary message-sharing API was built using NestJS, PostgreSQL, Prisma, and Redis. The API allows users to create messages with configurable rules, such as maximum length, expiration time, maximum visits, password protection, and one-time access. The API flow involves creating a link, validating input via DTOs, calculating expiration timestamps, storing data in PostgreSQL, and caching with Redis.
The project uses NestJS as the backend framework, TypeScript as the programming language, PostgreSQL as the persistent database, Prisma as the ORM, Redis as a caching server, bcrypt for password hashing, Swagger for API documentation, class-validator for DTO validation, @nestjs/schedule for cleanup cron jobs, and @nestjs/throttler for rate limiting.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.