A robust REST API built with Express.js and Igniter.js featuring structured logging and background jobs.
Discover other templates that might interest you based on similar technologies and use cases.
A high-performance REST API built with Bun runtime and Igniter.js for maximum speed and efficiency.
A secure and modern REST API built with Deno runtime and Igniter.js featuring built-in TypeScript support.
A full-featured real-time chat application built with Next.js and Prisma, showcasing Igniter.js's SSE-based real-time features for instant updates.
@felipebarcelospro
Fundador e Criador de Conteúdo na Vibe Dev | AI | Blockchain | Inteligência Artificial | Web3 | Startups | Crypto | SaaS | Micro-SaaS
Welcome to the Igniter.js starter for building high-performance, type-safe REST APIs with Express.js and Node.js. This template provides a robust and scalable foundation for creating modern back-end services.
Before you begin, ensure you have the following installed:
Follow these steps to get your project up and running:
Clone the Repository
git clone https://github.com/felipebarcelospro/igniter-js.git
cd igniter-js/apps/starter-express-rest-api
Install Dependencies
npm install
Configure Environment Variables
Create a .env
file in the root of this starter (igniter-js/apps/starter-express-rest-api/.env
) 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 push
Run the Development Server
npm run dev
This command starts the Express server using tsx
for hot-reloading. Your API will be available at http://localhost:3000/api/v1
.
This starter uses Express to handle HTTP requests and forwards them to the Igniter.js router.
src/index.ts
)The src/index.ts
file is the main entry point. It creates an Express app and uses the expressAdapter
from Igniter.js. This adapter is a middleware function that seamlessly connects Igniter.js's standard Request
/Response
-based handler to Express's (req, res, next)
-based middleware chain.
The back-end API logic is defined using Igniter.js.
src/igniter.ts
)src/igniter.router.ts
)src/features/example/controllers/example.controller.ts
)src/services/
)The project follows a feature-based architecture to promote scalability and separation of concerns.
src/
├── features/ # Business logic, grouped by feature
│ └── example/
│ └── controllers/ # API endpoint definitions
├── services/ # Service initializations (Redis, Prisma, etc.)
├── igniter.ts # Igniter.js core instance
├── igniter.client.ts # Auto-generated type-safe API client (for consumers)
├── igniter.context.ts # Application context definition
├── igniter.router.ts # Main API router
└── index.ts # Application entry point (Express server)
This starter comes with a pre-built 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
npm run dev
: Starts the development server with hot-reloading via tsx
.npm run build
: Compiles the TypeScript code to JavaScript in the dist
directory.npm run start
: Starts the application from the compiled code for production.To learn more about Igniter.js and its powerful features, check out the official documentation:
This starter is licensed under the MIT License.