Fix pre-commit script to properly handle multiple files and resolve ESLint warnings
This commit is contained in:
@@ -18,11 +18,9 @@ export class CouchDBService {
|
||||
|
||||
constructor() {
|
||||
// Get CouchDB configuration from environment
|
||||
const couchdbUrl =
|
||||
(import.meta as any).env?.VITE_COUCHDB_URL || 'http://localhost:5984';
|
||||
const couchdbUser = (import.meta as any).env?.VITE_COUCHDB_USER || 'admin';
|
||||
const couchdbPassword =
|
||||
(import.meta as any).env?.VITE_COUCHDB_PASSWORD || 'password';
|
||||
const couchdbUrl = process.env.VITE_COUCHDB_URL || 'http://localhost:5984';
|
||||
const couchdbUser = process.env.VITE_COUCHDB_USER || 'admin';
|
||||
const couchdbPassword = process.env.VITE_COUCHDB_PASSWORD || 'password';
|
||||
|
||||
this.baseUrl = couchdbUrl;
|
||||
this.auth = btoa(`${couchdbUser}:${couchdbPassword}`);
|
||||
@@ -72,7 +70,7 @@ export class CouchDBService {
|
||||
throw new Error(`Failed to create database ${dbName}`);
|
||||
}
|
||||
|
||||
console.log(`✅ Created CouchDB database: ${dbName}`);
|
||||
console.warn(`✅ Created CouchDB database: ${dbName}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error checking/creating database ${dbName}:`, error);
|
||||
@@ -83,8 +81,8 @@ export class CouchDBService {
|
||||
private async makeRequest(
|
||||
method: string,
|
||||
path: string,
|
||||
body?: any
|
||||
): Promise<any> {
|
||||
body?: Record<string, unknown>
|
||||
): Promise<Record<string, unknown>> {
|
||||
const url = `${this.baseUrl}${path}`;
|
||||
const options: RequestInit = {
|
||||
method,
|
||||
@@ -114,7 +112,7 @@ export class CouchDBService {
|
||||
): Promise<T | null> {
|
||||
try {
|
||||
const doc = await this.makeRequest('GET', `/${dbName}/${id}`);
|
||||
return doc;
|
||||
return doc as T;
|
||||
} catch (error) {
|
||||
if (error instanceof CouchDBError && error.status === 404) {
|
||||
return null;
|
||||
@@ -135,12 +133,15 @@ export class CouchDBService {
|
||||
return { ...doc, _rev: response.rev } as T;
|
||||
}
|
||||
|
||||
private async query<T>(dbName: string, selector: any): Promise<T[]> {
|
||||
private async query<T>(
|
||||
dbName: string,
|
||||
selector: Record<string, unknown>
|
||||
): Promise<T[]> {
|
||||
const response = await this.makeRequest('POST', `/${dbName}/_find`, {
|
||||
selector,
|
||||
limit: 1000,
|
||||
});
|
||||
return response.docs;
|
||||
return response.docs as T[];
|
||||
}
|
||||
|
||||
// User Management Methods
|
||||
@@ -363,10 +364,13 @@ export class CouchDBService {
|
||||
const settings = await this.getDoc('settings', userId);
|
||||
if (settings) {
|
||||
deletePromises.push(
|
||||
this.makeRequest('DELETE', `/settings/${userId}?rev=${settings._rev}`)
|
||||
this.makeRequest(
|
||||
'DELETE',
|
||||
`/settings/${userId}?rev=${settings._rev}`
|
||||
).then(() => undefined)
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
// Settings might not exist
|
||||
}
|
||||
|
||||
@@ -377,10 +381,10 @@ export class CouchDBService {
|
||||
this.makeRequest(
|
||||
'DELETE',
|
||||
`/taken_doses/${userId}?rev=${takenDoses._rev}`
|
||||
)
|
||||
).then(() => undefined)
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
// Taken doses might not exist
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user