Powerful Features for Developers
AskDev.ai gives you the tools to understand any codebase faster and more efficiently than ever before.
Ask Questions in Plain English
No need to learn complex query languages or syntax. Just ask your questions naturally, the way you'd ask a senior developer on your team.
- How does the authentication system work?
- What's the data flow for user registration?
- Explain the caching mechanism in this repo
- Where is the API rate limiting implemented?
How does the error handling work in this codebase?
This codebase uses a centralized error handling approach with custom error classes and middleware:
// Custom error classes
class AppError extends Error {
constructor(message, statusCode) {
super(message);
this.statusCode = statusCode;
this.status = `${statusCode}`.startsWith('4') ? 'fail' : 'error';
this.isOperational = true;
Error.captureStackTrace(this, this.constructor);
}
}
// Global error handling middleware
const errorHandler = (err, req, res, next) => {
err.statusCode = err.statusCode || 500;
err.status = err.status || 'error';
// Different handling for development vs production
if (process.env.NODE_ENV === 'development') {
sendDevError(err, res);
} else {
sendProdError(err, res);
}
};
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject, Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { User } from '../models/user.model';
import { environment } from '../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class AuthService {
private currentUserSubject: BehaviorSubject<User | null>;
public currentUser: Observable<User | null>;
constructor(private http: HttpClient) {
this.currentUserSubject = new BehaviorSubject<User | null>(
JSON.parse(localStorage.getItem('currentUser') || 'null')
);
this.currentUser = this.currentUserSubject.asObservable();
}
public get currentUserValue(): User | null {
return this.currentUserSubject.value;
}
login(email: string, password: string) {
return this.http.post<any>(`${environment.apiUrl}/auth/login`, { email, password })
.pipe(
map(response => {
// store user details and jwt token in local storage
localStorage.setItem('currentUser', JSON.stringify(response.user));
localStorage.setItem('token', response.token);
this.currentUserSubject.next(response.user);
return response.user;
})
);
}
logout() {
// remove user from local storage
localStorage.removeItem('currentUser');
localStorage.removeItem('token');
this.currentUserSubject.next(null);
}
}
How does this auth service handle token expiration?
Integrate with Your Favorite Tools
AskDev.ai works seamlessly with your favorite coding environments. Use it in VS Code, Cursor, Claude Code, and other MCP clients to get answers without disrupting your workflow.
- Get answers directly in your IDE
- No context switching required
- Works with files you're actively editing
- Supports all major programming languages
More Powerful Features
Everything you need to understand code faster and more efficiently
Ready to Try AskDev.ai?
Get started for free and see how AskDev.ai can transform your coding experience.