nestjs-telescope
Version:
A debugging and monitoring tool for NestJS applications, inspired by Laravel Telescope
224 lines (163 loc) ⢠7.01 kB
Markdown
# NestJS Telescope š
A powerful debugging and monitoring tool for NestJS applications, inspired by Laravel Telescope. Provides real-time HTTP request monitoring, exception tracking, and a beautiful web interface for debugging your applications.
[](https://badge.fury.io/js/nestjs-telescope)
[](https://opensource.org/licenses/MIT)
[](https://github.com/HiGeorges/NestJs-Telescope/stargazers)
[](https://github.com/HiGeorges/NestJs-Telescope/network)
## ⨠Features
- **š Real-time HTTP Monitoring**: Capture and inspect all HTTP requests and responses
- **šØ Exception Tracking**: Detailed stack traces and error information
- **š Live Statistics**: Real-time metrics and performance analytics
- **šØ Beautiful UI**: Modern React-based interface with dark mode support
- **š Optional Authentication**: Basic auth protection for sensitive environments
- **ā” High Performance**: Minimal overhead with efficient data storage
- **š§ Easy Integration**: Simple setup with NestJS applications
- **š± Responsive Design**: Works seamlessly on desktop and mobile
## š Quick Start
### Installation
```bash
npm install nestjs-telescope
```
### Super Simple Setup āØ
Just add **one line** to your `main.ts` - that's it!
```typescript
// main.ts
import { NestFactory } from '@nestjs/common';
import { AppModule } from './app.module';
import { TelescopeModule } from 'nestjs-telescope';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// š One line setup - magic!
TelescopeModule.setup(app);
await app.listen(3000);
}
bootstrap();
```
**No module imports needed!** Your `AppModule` stays unchanged:
```typescript
// app.module.ts - No changes required!
import { Module } from '@nestjs/common';
@Module({
imports: [], // No need to import TelescopeModule
// ... your controllers and providers
})
export class AppModule {}
```
### Access the Dashboard
Visit `http://localhost:3000/telescope` and start debugging! š
## š Documentation
### Configuration Options
```typescript
interface TelescopeConfig {
enabled?: boolean; // Enable/disable telescope
auth?: { // Basic auth credentials
username: string;
password: string;
};
maxEntries?: number; // Maximum entries to store (default: 1000)
autoClearAfter?: number; // Auto-clear after time in ms
captureRequestBody?: boolean; // Capture request bodies
captureResponseBody?: boolean; // Capture response bodies
captureHeaders?: boolean; // Capture headers
captureQuery?: boolean; // Capture query parameters
captureIP?: boolean; // Capture IP addresses
captureUserAgent?: boolean; // Capture user agents
}
```
### Alternative Setup (Legacy)
If you prefer the traditional module import approach:
```typescript
// app.module.ts
import { Module } from '@nestjs/common';
import { TelescopeModule } from 'nestjs-telescope';
@Module({
imports: [TelescopeModule],
// ... your providers
})
export class AppModule {}
```
> ā ļø **Note**: Use either `TelescopeModule.setup(app)` OR module import, not both!
### API Endpoints
The module provides the following REST endpoints:
- `GET /telescope` - Web interface
- `GET /telescope/api/entries` - List all entries
- `GET /telescope/api/entries/:id` - Get specific entry
- `GET /telescope/api/stats` - Get statistics
- `DELETE /telescope/api/entries` - Clear all entries
## šÆ Use Cases
- **Development Debugging**: Monitor API calls during development
- **Production Monitoring**: Track errors and performance in production
- **API Testing**: Inspect request/response data for testing
- **Performance Analysis**: Analyze response times and bottlenecks
- **Security Auditing**: Monitor suspicious requests and patterns
## š Production Ready
### ā
What's New in v1.0.12
- **š§ Zero-config setup**: Just `TelescopeModule.setup(app)` and you're done!
- **šØ Fixed production UI**: No more blank screens in production environments
- **š¦ Enhanced asset serving**: Works with Docker, serverless, and all deployment types
- **ā” Better performance**: Optimized middleware and asset caching
- **š”ļø Improved security**: Better header sanitization and error handling
### š Production Deployment
Telescope now works seamlessly in production across all environments:
- ā
**Docker containers** - Assets served from correct paths
- ā
**Serverless** (AWS Lambda, Vercel, etc.) - Bundled assets
- ā
**Traditional servers** - npm package resolution
- ā
**CDN/static hosting** - Proper MIME types and caching headers
## š ļø Development
### Prerequisites
- Node.js >= 18.0.0
- npm >= 8.0.0
### Setup
```bash
# Clone the repository
git clone https://github.com/HiGeorges/NestJs-Telescope.git
cd NestJs-Telescope
# Install dependencies
npm install
# Build all packages
npm run build
# Start development
npm run dev
```
### Project Structure
```
āāā packages/
ā āāā core/ # NestJS backend module
ā ā āāā src/
ā ā āāā dist/
ā āāā ui/ # React frontend
ā āāā src/
ā āāā dist/
āāā apps/
ā āāā demo/ # Demo application
āāā README.md
```
### Available Scripts
```bash
npm run build # Build all packages
npm run dev # Start development server
npm run test # Run all tests
npm run lint # Lint all packages
npm run clean # Clean build artifacts
```
## š¤ Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
### Development Workflow
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## š License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## š Acknowledgments
- Inspired by [Laravel Telescope](https://laravel.com/docs/telescope)
- Built with [NestJS](https://nestjs.com/) and [React](https://reactjs.org/)
- Styled with [Tailwind CSS](https://tailwindcss.com/)
## š Support
- š§ Email: georges.heloussato@epitech.eu
- š Issues: [GitHub Issues](https://github.com/HiGeorges/NestJs-Telescope/issues)
- š Documentation: [GitHub Wiki](https://github.com/HiGeorges/NestJs-Telescope/wiki)
- šØāš» Author: [HiGeorges](https://github.com/HiGeorges)
---
Made with ā¤ļø by [Georges HELOUSSATO](https://github.com/HiGeorges)