
Deno REST API
A secure and modern REST API built with Deno runtime and Igniter.js featuring built-in TypeScript support.
Framework
DenoUse Case
APIStack
Overview
This template provides a robust and scalable foundation for building high-performance, type-safe REST APIs with Deno and Igniter.js. It's designed for developers who prioritize security, modern features, and a strongly-typed backend.
Features
- ✅ Modern Deno Runtime: Built on Deno, a simple, modern, and secure runtime for JavaScript and TypeScript.
- ✅ 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.
- ✅ Auto-Generated Type-Safe Client: Even as a REST API, you can generate a fully-typed client (
src/igniter.client.ts) for consumption by other TypeScript services or a separate front-end application.
Project Structure
Quick Start
Clone the Repository
git clone https://github.com/felipebarcelospro/igniter-js.git
cd igniter-js/apps/starter-deno-rest-apiConfigure 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
This starter uses Prisma for database management. You'll need to add a task to your deno.json to run migrations.
// deno.json
{
"tasks": {
"dev": "deno run --unstable-sloppy-imports --watch --allow-net --allow-env --import-map=import_map.json src/index.ts",
"start": "deno run --unstable-sloppy-imports --allow-net --allow-env --import-map=import_map.json src/index.ts",
"prisma:db:push": "deno run --unstable-sloppy-imports -A npm:prisma db push"
},
// ... rest of the file
}Then, run the task:
deno task prisma:db:pushEnsure you have Deno (v1.x or higher) installed, 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:8000/api/v1/example/ -
Cache Demonstration
# First request (live data) curl http://localhost:8000/api/v1/example/cache/my-key # Second request (cached data) curl http://localhost:8000/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:8000/api/v1/example/schedule-job -
List Jobs
curl http://localhost:8000/api/v1/example/jobs
Deployment
This template can be deployed to various platforms that support Deno applications. Follow the quick start guide to get your API running locally, then refer to Deno's deployment documentation for production environments.