Skip to content

Commit 5043d74

Browse files
author
Your Name
committed
fix: refactor code by formatting the components and types
1 parent 45e8b97 commit 5043d74

5 files changed

Lines changed: 131 additions & 143 deletions

File tree

app/components/Compare/FacetSelector.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ function deselectAllFacet(category: string) {
106106
:key="facet.id"
107107
:title="facet.comingSoon ? $t('compare.facets.coming_soon') : facet.description"
108108
class="inline-flex items-center gap-1 px-1.5 rounded border transition-colors text-fg-subtle bg-bg-subtle border-border-subtle hover:(text-fg-muted border-border) has-[:checked]:(text-fg-muted bg-fg/10 border-fg/20 hover:(bg-fg/20 text-fg/50)) has-[:focus-visible]:(outline outline-accent/70)"
109-
:class="facet.comingSoon ? 'cursor-not-allowed text-fg-subtle/50 bg-bg-subtle border-border-subtle hover:(text-fg-subtle/50 border-border-subtle)' : 'cursor-pointer'"
109+
:class="
110+
facet.comingSoon
111+
? 'cursor-not-allowed text-fg-subtle/50 bg-bg-subtle border-border-subtle hover:(text-fg-subtle/50 border-border-subtle)'
112+
: 'cursor-pointer'
113+
"
110114
>
111115
<input
112116
type="checkbox"
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
import type { KeytraceAccount, KeytraceResponse } from "#shared/types/keytrace";
1+
import type { KeytraceAccount, KeytraceResponse } from '#shared/types/keytrace'
22

3-
const statusPriority: Record<KeytraceAccount["status"], number> = {
3+
const statusPriority: Record<KeytraceAccount['status'], number> = {
44
verified: 0,
55
unverified: 1,
66
stale: 2,
77
failed: 3,
8-
};
8+
}
99

1010
export function useKeytraceProfile(domain: MaybeRefOrGetter<string>) {
1111
const asyncData = useFetch<KeytraceResponse>(
1212
() => `/api/keytrace/${encodeURIComponent(toValue(domain))}`,
1313
{
1414
default: () => ({
1515
profile: {
16-
name: "",
17-
avatar: "",
18-
description: "",
16+
name: '',
17+
avatar: '',
18+
description: '',
1919
},
2020
accounts: [],
2121
}),
2222
},
23-
);
23+
)
2424

25-
const profile = computed(() => asyncData.data.value?.profile);
26-
const accounts = computed(() => asyncData.data.value?.accounts ?? []);
25+
const profile = computed(() => asyncData.data.value?.profile)
26+
const accounts = computed(() => asyncData.data.value?.accounts ?? [])
2727

2828
const sortedAccounts = computed(() =>
2929
[...accounts.value].sort((a, b) => {
30-
const statusSort = statusPriority[a.status] - statusPriority[b.status];
30+
const statusSort = statusPriority[a.status] - statusPriority[b.status]
3131
if (statusSort !== 0) {
32-
return statusSort;
32+
return statusSort
3333
}
3434

35-
return a.platform.localeCompare(b.platform);
35+
return a.platform.localeCompare(b.platform)
3636
}),
37-
);
37+
)
3838

3939
const verifiedAccounts = computed(() =>
40-
sortedAccounts.value.filter((account) => account.status === "verified"),
41-
);
40+
sortedAccounts.value.filter(account => account.status === 'verified'),
41+
)
4242

4343
const nonVerifiedAccounts = computed(() =>
44-
sortedAccounts.value.filter((account) => account.status !== "verified"),
45-
);
44+
sortedAccounts.value.filter(account => account.status !== 'verified'),
45+
)
4646

4747
return {
4848
profile,
4949
accounts: sortedAccounts,
5050
verifiedAccounts,
5151
nonVerifiedAccounts,
5252
loading: asyncData.pending,
53-
};
53+
}
5454
}

server/api/keytrace/[domain].ts

Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,65 @@
1-
import type { KeytraceResponse } from "#shared/types/keytrace";
1+
import type { KeytraceResponse } from '#shared/types/keytrace'
22

33
const MOCK_KEYTRACE_PROFILES: Record<string, KeytraceResponse> = {
4-
"npmx.dev": {
4+
'npmx.dev': {
55
profile: {
6-
name: "npmx Team",
7-
avatar: "https://api.dicebear.com/9.x/shapes/svg?seed=npmx",
6+
name: 'npmx Team',
7+
avatar: 'https://api.dicebear.com/9.x/shapes/svg?seed=npmx',
88
banner:
9-
"https://images.unsplash.com/photo-1515879218367-8466d910aaa4?auto=format&fit=crop&w=1400&q=80",
10-
description:
11-
"Open source developers building better tooling around package discovery.",
9+
'https://images.unsplash.com/photo-1515879218367-8466d910aaa4?auto=format&fit=crop&w=1400&q=80',
10+
description: 'Open source developers building better tooling around package discovery.',
1211
},
1312
accounts: [
1413
{
15-
platform: "github",
16-
username: "npmx-dev",
17-
displayName: "npmx-dev",
18-
avatar: "https://avatars.githubusercontent.com/u/178563400?v=4",
19-
url: "https://github.com/npmx-dev",
20-
status: "verified",
21-
proofMethod: "github",
22-
addedAt: "2026-03-10T12:00:00.000Z",
23-
lastCheckedAt: "2026-04-20T09:30:00.000Z",
14+
platform: 'github',
15+
username: 'npmx-dev',
16+
displayName: 'npmx-dev',
17+
avatar: 'https://avatars.githubusercontent.com/u/178563400?v=4',
18+
url: 'https://github.com/npmx-dev',
19+
status: 'verified',
20+
proofMethod: 'github',
21+
addedAt: '2026-03-10T12:00:00.000Z',
22+
lastCheckedAt: '2026-04-20T09:30:00.000Z',
2423
},
2524
{
26-
platform: "npm",
27-
username: "npmx",
28-
displayName: "npmx",
29-
avatar: "https://api.dicebear.com/9.x/identicon/svg?seed=npmx",
30-
url: "https://www.npmjs.com/~npmx",
31-
status: "stale",
32-
proofMethod: "npm",
33-
addedAt: "2026-02-18T15:20:00.000Z",
34-
lastCheckedAt: "2026-03-05T08:00:00.000Z",
35-
failureReason: "Proof has not been re-verified recently.",
25+
platform: 'npm',
26+
username: 'npmx',
27+
displayName: 'npmx',
28+
avatar: 'https://api.dicebear.com/9.x/identicon/svg?seed=npmx',
29+
url: 'https://www.npmjs.com/~npmx',
30+
status: 'stale',
31+
proofMethod: 'npm',
32+
addedAt: '2026-02-18T15:20:00.000Z',
33+
lastCheckedAt: '2026-03-05T08:00:00.000Z',
34+
failureReason: 'Proof has not been re-verified recently.',
3635
},
3736
{
38-
platform: "mastodon",
39-
username: "@npmx@fosstodon.org",
40-
displayName: "npmx",
41-
avatar:
42-
"https://api.dicebear.com/9.x/identicon/svg?seed=fosstodon-npmx",
43-
url: "https://fosstodon.org/@npmx",
44-
status: "failed",
45-
proofMethod: "mastodon",
46-
addedAt: "2026-01-22T11:40:00.000Z",
47-
lastCheckedAt: "2026-04-19T22:15:00.000Z",
48-
failureReason:
49-
"Linked proof URL could not be resolved during verification.",
37+
platform: 'mastodon',
38+
username: '@npmx@fosstodon.org',
39+
displayName: 'npmx',
40+
avatar: 'https://api.dicebear.com/9.x/identicon/svg?seed=fosstodon-npmx',
41+
url: 'https://fosstodon.org/@npmx',
42+
status: 'failed',
43+
proofMethod: 'mastodon',
44+
addedAt: '2026-01-22T11:40:00.000Z',
45+
lastCheckedAt: '2026-04-19T22:15:00.000Z',
46+
failureReason: 'Linked proof URL could not be resolved during verification.',
5047
},
5148
],
5249
},
53-
"empty.dev": {
50+
'empty.dev': {
5451
profile: {
55-
name: "Empty Developer",
56-
avatar: "https://api.dicebear.com/9.x/initials/svg?seed=empty.dev",
57-
description: "A profile with no linked accounts yet.",
52+
name: 'Empty Developer',
53+
avatar: 'https://api.dicebear.com/9.x/initials/svg?seed=empty.dev',
54+
description: 'A profile with no linked accounts yet.',
5855
},
5956
accounts: [],
6057
},
61-
};
58+
}
6259

6360
function domainToDisplayName(domain: string): string {
64-
const firstSegment = domain.split(".")[0] || domain;
65-
return firstSegment.charAt(0).toUpperCase() + firstSegment.slice(1);
61+
const firstSegment = domain.split('.')[0] || domain
62+
return firstSegment.charAt(0).toUpperCase() + firstSegment.slice(1)
6663
}
6764

6865
function buildFallbackProfile(domain: string): KeytraceResponse {
@@ -74,52 +71,52 @@ function buildFallbackProfile(domain: string): KeytraceResponse {
7471
},
7572
accounts: [
7673
{
77-
platform: "github",
74+
platform: 'github',
7875
username: domain,
7976
displayName: domain,
8077
avatar: `https://api.dicebear.com/9.x/identicon/svg?seed=github-${encodeURIComponent(domain)}`,
8178
url: `https://github.com/${domain}`,
82-
status: "verified",
83-
proofMethod: "github",
84-
addedAt: "2026-04-01T10:00:00.000Z",
85-
lastCheckedAt: "2026-04-21T10:00:00.000Z",
79+
status: 'verified',
80+
proofMethod: 'github',
81+
addedAt: '2026-04-01T10:00:00.000Z',
82+
lastCheckedAt: '2026-04-21T10:00:00.000Z',
8683
},
8784
{
88-
platform: "npm",
85+
platform: 'npm',
8986
username: domain,
9087
displayName: domain,
9188
avatar: `https://api.dicebear.com/9.x/identicon/svg?seed=npm-${encodeURIComponent(domain)}`,
9289
url: `https://www.npmjs.com/~${domain}`,
93-
status: "unverified",
94-
proofMethod: "npm",
95-
addedAt: "2026-04-01T10:00:00.000Z",
96-
lastCheckedAt: "2026-04-01T10:00:00.000Z",
97-
failureReason: "Proof exists but has not been verified yet.",
90+
status: 'unverified',
91+
proofMethod: 'npm',
92+
addedAt: '2026-04-01T10:00:00.000Z',
93+
lastCheckedAt: '2026-04-01T10:00:00.000Z',
94+
failureReason: 'Proof exists but has not been verified yet.',
9895
},
9996
{
100-
platform: "mastodon",
97+
platform: 'mastodon',
10198
username: `@${domain}@mastodon.social`,
10299
displayName: domain,
103100
avatar: `https://api.dicebear.com/9.x/identicon/svg?seed=mastodon-${encodeURIComponent(domain)}`,
104101
url: `https://mastodon.social/@${encodeURIComponent(domain)}`,
105-
status: "stale",
106-
proofMethod: "mastodon",
107-
addedAt: "2026-04-01T10:00:00.000Z",
108-
lastCheckedAt: "2026-04-08T10:00:00.000Z",
109-
failureReason: "Verification check is out of date.",
102+
status: 'stale',
103+
proofMethod: 'mastodon',
104+
addedAt: '2026-04-01T10:00:00.000Z',
105+
lastCheckedAt: '2026-04-08T10:00:00.000Z',
106+
failureReason: 'Verification check is out of date.',
110107
},
111108
],
112-
};
109+
}
113110
}
114111

115-
export default defineEventHandler((event) => {
116-
const domain = getRouterParam(event, "domain")?.trim().toLowerCase();
112+
export default defineEventHandler(event => {
113+
const domain = getRouterParam(event, 'domain')?.trim().toLowerCase()
117114
if (!domain) {
118115
throw createError({
119116
statusCode: 400,
120-
message: "Domain is required",
121-
});
117+
message: 'Domain is required',
118+
})
122119
}
123120

124-
return MOCK_KEYTRACE_PROFILES[domain] ?? buildFallbackProfile(domain);
125-
});
121+
return MOCK_KEYTRACE_PROFILES[domain] ?? buildFallbackProfile(domain)
122+
})
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
1-
import type {
2-
KeytraceReverifyRequest,
3-
KeytraceReverifyResponse,
4-
} from "#shared/types/keytrace";
1+
import type { KeytraceReverifyRequest, KeytraceReverifyResponse } from '#shared/types/keytrace'
52

6-
export default defineEventHandler(async (event) => {
7-
const body = await readBody<KeytraceReverifyRequest>(event);
3+
export default defineEventHandler(async event => {
4+
const body = await readBody<KeytraceReverifyRequest>(event)
85

9-
const platform = body?.platform?.trim().toLowerCase();
10-
const username = body?.username?.trim();
6+
const platform = body?.platform?.trim().toLowerCase()
7+
const username = body?.username?.trim()
118

129
if (!platform || !username) {
1310
throw createError({
1411
statusCode: 400,
15-
message: "platform and username are required",
16-
});
12+
message: 'platform and username are required',
13+
})
1714
}
1815

19-
const lastCheckedAt = new Date().toISOString();
16+
const lastCheckedAt = new Date().toISOString()
2017

2118
// TODO: Implement per-platform proof verification for KeytraceReverifyResponse
2219
// construction here (including mastodon and npm short-username logic), ideally
2320
// via a verifyProofForPlatform(platform, username, proofData) helper.
2421
const response: KeytraceReverifyResponse = {
25-
status: "unverified",
22+
status: 'unverified',
2623
lastCheckedAt,
27-
failureReason: "Proof verification is not implemented yet.",
28-
};
29-
return response;
30-
});
24+
failureReason: 'Proof verification is not implemented yet.',
25+
}
26+
return response
27+
})

shared/types/keytrace.ts

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,40 @@
11
export type KeytraceProfile = {
2-
name: string;
3-
avatar: string;
4-
banner?: string;
5-
description: string;
6-
};
2+
name: string
3+
avatar: string
4+
banner?: string
5+
description: string
6+
}
77

8-
export type KeytraceVerificationStatus =
9-
| "verified"
10-
| "unverified"
11-
| "stale"
12-
| "failed";
8+
export type KeytraceVerificationStatus = 'verified' | 'unverified' | 'stale' | 'failed'
139

14-
export type KeytraceProofMethod =
15-
| "dns"
16-
| "github"
17-
| "npm"
18-
| "mastodon"
19-
| "pgp"
20-
| "other";
10+
export type KeytraceProofMethod = 'dns' | 'github' | 'npm' | 'mastodon' | 'pgp' | 'other'
2111

2212
export type KeytraceAccount = {
23-
platform: string;
24-
username: string;
25-
displayName?: string;
26-
avatar?: string;
27-
url?: string;
28-
status: KeytraceVerificationStatus;
29-
proofMethod: KeytraceProofMethod;
30-
addedAt: string;
31-
lastCheckedAt: string;
32-
failureReason?: string;
33-
};
13+
platform: string
14+
username: string
15+
displayName?: string
16+
avatar?: string
17+
url?: string
18+
status: KeytraceVerificationStatus
19+
proofMethod: KeytraceProofMethod
20+
addedAt: string
21+
lastCheckedAt: string
22+
failureReason?: string
23+
}
3424

3525
export type KeytraceResponse = {
36-
profile: KeytraceProfile;
37-
accounts: KeytraceAccount[];
38-
};
26+
profile: KeytraceProfile
27+
accounts: KeytraceAccount[]
28+
}
3929

4030
export type KeytraceReverifyRequest = {
41-
platform: string;
42-
username: string;
43-
url?: string;
44-
};
31+
platform: string
32+
username: string
33+
url?: string
34+
}
4535

4636
export type KeytraceReverifyResponse = {
47-
status: KeytraceVerificationStatus;
48-
lastCheckedAt: string;
49-
failureReason?: string;
50-
};
37+
status: KeytraceVerificationStatus
38+
lastCheckedAt: string
39+
failureReason?: string
40+
}

0 commit comments

Comments
 (0)