thunder-bolt-api
v1.0.4
Published
A backend application using Fastify with TypeScript, providing a high-performance, modular, and extensible API server. The application includes structured routing, plugin-based architecture, strong typing, and supports scalable features such as request va
Downloads
25
Readme
thunderbolt-api
A Fastify/TypeScript backend library with decorators, dependency injection, and modular architecture. Designed for rapid development, scalable APIs, and easy integration as an npm package.
Features
- Fastify-based routing and middleware
- TypeScript-first with type definitions
- Custom decorators for controllers, methods, and middleware
- Dependency injection (DI) system
- Modular structure for scalable projects
- MongoDB connection utility
Installation
npm install thunderbolt-apiUsage
Import and use decorators, DI, and utilities in your Fastify project:
import { Controller, Get, Post, UseMiddleware, Inject, Injectable, Connection } from 'backend-template';
@Injectable()
class UserService {
getUsers() {
return [{ id: 1, name: 'Alice' }];
}
}
@Controller('/users')
export class UserController {
@Inject(UserService)
private userService!: UserService;
@Get('/')
listUsers() {
return this.userService.getUsers();
}
}API Reference
@Controller(path: string)— Define a controller and its base route@Get(path: string)/@Post(path: string)— Define route handlers@UseMiddleware(fn)— Attach middleware to controllers or methods@Injectable()— Mark a class as injectable for DI@Inject(Service)— Inject a service into a classConnection.connect(uri, db)— Connect to MongoDB
License
ISC
