
Express REST API
A robust REST API built with Express.js and Igniter.js featuring structured logging and background jobs.
Framework
ExpressUse Case
APIStack
Overview
This template provides a robust and scalable foundation for building high-performance, type-safe REST APIs with Express.js and Igniter.js. It leverages the battle-tested Express framework with modern features like structured logging and background jobs.
Features
- ✅ Battle-Tested Express Server: Built on Express.js, the most popular web framework for Node.js.
- ✅ Type-Safe from the Ground Up: Powered by Igniter.js, ensuring a strongly-typed codebase that is easy to maintain and refactor.
- ✅ Feature-Based Architecture: A scalable project structure that organizes code by business domain, not technical layers.
- ✅ Ready-to-Use Services: Pre-configured examples for:
- Caching: Integrated with Redis via
@igniter-js/adapter-redis. - Background Jobs: Asynchronous task processing with BullMQ via
@igniter-js/adapter-bullmq. - Structured Logging: Production-ready, context-aware logging.
- Caching: Integrated with Redis via
- ✅ Database Ready: Comes with Prisma set up for seamless PostgreSQL database integration.
- ✅ Seamless Integration: Uses the
@igniter-js/core/adaptersto cleanly connect the Igniter.js router to Express.
Project Structure
Quick Start
Clone the Repository
git clone https://github.com/felipebarcelospro/igniter-js.git
cd igniter-js/apps/starter-express-rest-apiInstall Dependencies
npm installpnpm installyarn installbun installConfigure Environment Variables
Create a .env file in the root of this starter and add your database and Redis connection URLs:
# .env
DATABASE_URL="postgresql://user:password@localhost:5432/mydatabase?schema=public"
REDIS_URL="redis://127.0.0.1:6379"Run Database Migrations
npx prisma db pushEnsure you have Node.js (v18 or higher), npm (or compatible package manager), a running Redis instance, and a PostgreSQL database.
Example API Endpoints
This starter includes an example controller to demonstrate key features.
-
Health Check
curl http://localhost:3000/api/v1/example/ -
Cache Demonstration
# First request (live data) curl http://localhost:3000/api/v1/example/cache/my-key # Second request (cached data) curl http://localhost:3000/api/v1/example/cache/my-key -
Schedule a Background Job
curl -X POST -H "Content-Type: application/json" \ -d '{"message": "Hello from curl"}' \ http://localhost:3000/api/v1/example/schedule-job -
List Jobs
curl http://localhost:3000/api/v1/example/jobs
Deployment
This template can be deployed to various platforms that support Node.js applications. Follow the quick start guide to get your API running locally, then refer to Express.js deployment documentation for production environments.