Skip to content

Commit 47f6b33

Browse files
committed
chore: removed excess comments
1 parent 83500ad commit 47f6b33

1 file changed

Lines changed: 23 additions & 28 deletions

File tree

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1-
import * as v from "valibot";
2-
import { PackageNameSchema } from "#shared/schemas/package";
3-
import {
4-
CACHE_MAX_AGE_ONE_HOUR,
5-
ERROR_NPM_FETCH_FAILED,
6-
} from "#shared/utils/constants";
1+
import * as v from 'valibot'
2+
import { PackageNameSchema } from '#shared/schemas/package'
3+
import { CACHE_MAX_AGE_ONE_HOUR, ERROR_NPM_FETCH_FAILED } from '#shared/utils/constants'
74

85
export default defineCachedEventHandler(
9-
async (event) => {
10-
try {
11-
const pkg = getRouterParam(event, "pkg");
6+
async event => {
7+
try {
8+
const pkg = getRouterParam(event, 'pkg')
129

13-
// T3 Chat: Validates and assigns in one line
14-
const packageName = v.parse(PackageNameSchema, pkg);
10+
const packageName = v.parse(PackageNameSchema, pkg)
1511

16-
return await fetchNpmPackage(packageName);
17-
} catch (error: unknown) {
18-
handleApiError(error, {
19-
statusCode: 502,
20-
message: ERROR_NPM_FETCH_FAILED,
21-
});
22-
}
12+
return await fetchNpmPackage(packageName)
13+
} catch (error: unknown) {
14+
handleApiError(error, {
15+
statusCode: 502,
16+
message: ERROR_NPM_FETCH_FAILED,
17+
})
18+
}
19+
},
20+
{
21+
maxAge: CACHE_MAX_AGE_ONE_HOUR,
22+
swr: true,
23+
getKey: event => {
24+
const pkg = getRouterParam(event, 'pkg') ?? ''
25+
return `packument:v1:${pkg.replace(/\/+$/, '').trim()}`
2326
},
24-
{
25-
maxAge: CACHE_MAX_AGE_ONE_HOUR,
26-
swr: true,
27-
getKey: (event) => {
28-
const pkg = getRouterParam(event, "pkg") ?? "";
29-
// T3 Chat: Using normalized key to match other routes
30-
return `packument:v1:${pkg.replace(/\/+$/, "").trim()}`;
31-
},
32-
},
33-
);
27+
},
28+
)

0 commit comments

Comments
 (0)