Initial commit: Supermarket scraper MVP

This commit is contained in:
2025-12-28 23:29:30 +05:00
commit 19c0426cdc
30 changed files with 4839 additions and 0 deletions

29
src/utils/errors.ts Normal file
View File

@@ -0,0 +1,29 @@
export class ScraperError extends Error {
constructor(
message: string,
public readonly code?: string,
public readonly statusCode?: number
) {
super(message);
this.name = 'ScraperError';
}
}
export class DatabaseError extends Error {
constructor(message: string, public readonly originalError?: Error) {
super(message);
this.name = 'DatabaseError';
}
}
export class APIError extends Error {
constructor(
message: string,
public readonly statusCode: number,
public readonly response?: any
) {
super(message);
this.name = 'APIError';
}
}

20
src/utils/logger.ts Normal file
View File

@@ -0,0 +1,20 @@
export class Logger {
static info(message: string, ...args: any[]) {
console.log(`[INFO] ${new Date().toISOString()} - ${message}`, ...args);
}
static error(message: string, ...args: any[]) {
console.error(`[ERROR] ${new Date().toISOString()} - ${message}`, ...args);
}
static warn(message: string, ...args: any[]) {
console.warn(`[WARN] ${new Date().toISOString()} - ${message}`, ...args);
}
static debug(message: string, ...args: any[]) {
if (process.env.DEBUG === 'true') {
console.log(`[DEBUG] ${new Date().toISOString()} - ${message}`, ...args);
}
}
}