Skip to content

Commit

Permalink
chore: added eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Jan 20, 2025
1 parent 5b2fa9b commit 7f6f4ae
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 9 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"chai": "^4.3.10",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"mocha": "^10.2.0",
"prettier": "^3.2.5",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"ts-node": "^10.9.2",
Expand Down
2 changes: 1 addition & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ declare global {
}
}

export {};
export {}
8 changes: 5 additions & 3 deletions src/lib/lookup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {APIClient, API, PublicKey} from '@wharfkit/antelope'
import {APIClient} from '@wharfkit/antelope'
import type {API, PublicKey} from '@wharfkit/antelope'
import type {PermissionLevelType} from '@wharfkit/antelope'
import type {Chain} from './chains'
import {logger} from './utils/logger'

export const networkRequest = (
publicKey: PublicKey,
Expand Down Expand Up @@ -38,7 +40,7 @@ export const lookupNetwork = async (publicKey: PublicKey, chain: Chain, apiClien
const accounts = await networkRequest(publicKey, chain, apiClient)
return {chain, accounts}
} catch (error) {
console.warn(`Lookup error on ${chain.name}: ${error}`)
return {chain, accounts: []}
logger.warn(`Lookup error on ${chain.name}: ${error}`)
return {chain, accounts: [], error: `Lookup error: ${error}`}
}
}
6 changes: 6 additions & 0 deletions src/lib/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable no-console */
export const logger = {
warn: (message: string) => {
console.warn(message)
},
}
3 changes: 1 addition & 2 deletions src/routes/+server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {json} from '@sveltejs/kit'
import type {RequestEvent} from '@sveltejs/kit'

export const GET = async ({}: RequestEvent) => {
export const GET = async () => {
return json({
message: '💡🏠 Lighthouse API',
endpoints: {
Expand Down
5 changes: 3 additions & 2 deletions src/routes/lookup/[publicKey]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const GET = async ({params, url, fetch}: RequestEvent) => {

return json(networkAccounts)
} catch (err) {
console.error(err)
throw error(400, {message: 'Invalid public key'})
// Handle both invalid public key format and lookup errors
const message = err instanceof Error ? err.message : 'Invalid public key'
throw error(400, {message})
}
}
1 change: 0 additions & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {makeClient} from '@wharfkit/mock-data'

const PUBLIC_KEY = 'EOS65BFgzcH8uZW837HqadGcREfNViBV6Fqc1LsmwcWdfUCayHQzf'
const NON_EXISTENT_PUBLIC_KEY = 'EOS8hiZaTNknE75KH2UmBNqcVFN4u3vgJ8PcytevjygaJ6aGWfb7U'
const BAD_PUBLIC_KEY = 'EOS6KybFkAb54UMSvHoj4BMGTKPd21GEw3HUCoB5uc1vabasasqYrV'

const mockClient = makeClient('https://jungle4.greymass.com')

Expand Down

0 comments on commit 7f6f4ae

Please sign in to comment.