Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

feat(api): add generic lensPg types (#5904)

authored by yoginth.com and committed by

GitHub 9360828b 45e69330

+10 -9
+1 -1
apps/api/src/routes/jumper/getStats.ts
··· 24 24 [address.replace("0x", "\\x")] 25 25 )) as Array<{ address: Buffer }>; 26 26 27 - const result = await lensPg.query( 27 + const result = await lensPg.query<Array<{ type: string; count: string }>>( 28 28 ` 29 29 SELECT 'tip' AS type, COUNT(*) AS count 30 30 FROM post.action_executed
+9 -8
apps/api/src/utils/lensPg.ts
··· 42 42 connectionParameters: IConnectionParameters 43 43 ): InitializeDbResult { 44 44 const pgp = pgPromise({ 45 - error: (error: any) => { 46 - const errorMessage = error.message || error; 45 + error: (error: unknown) => { 46 + const errorMessage = 47 + error instanceof Error ? error.message : String(error); 47 48 console.error(`LENS POSTGRES ERROR WITH TRACE: ${errorMessage}`); 48 49 } 49 50 }); ··· 54 55 }; 55 56 } 56 57 57 - public multi( 58 + public multi<T = unknown>( 58 59 query: DatabaseQuery, 59 60 params: DatabaseParams = null 60 - ): Promise<any[][]> { 61 - return this._readDb.multi(query, params); 61 + ): Promise<T[][]> { 62 + return this._readDb.multi<T>(query, params); 62 63 } 63 64 64 - public query( 65 + public query<T = unknown>( 65 66 query: DatabaseQuery, 66 67 params: DatabaseParams = null 67 - ): Promise<any[]> { 68 - return this._readDb.query(query, params); 68 + ): Promise<T> { 69 + return this._readDb.query<T>(query, params); 69 70 } 70 71 } 71 72