mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-03 17:06:37 -04:00
*much* stricter typescript (and some js) linting 😬
This commit is contained in:
11
api/hits.ts
11
api/hits.ts
@ -61,12 +61,13 @@ export default async (req: VercelRequest, res: VercelResponse) => {
|
||||
Sentry.captureException(error);
|
||||
await Sentry.flush(2000);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
||||
res.status(400).json({ message: error.message });
|
||||
}
|
||||
};
|
||||
|
||||
const incrementPageHits = async (slug: string | string[], client: Client): Promise<PageStats> => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
|
||||
const result = await client.query<any>(
|
||||
q.Let(
|
||||
{ match: q.Match(q.Index("hits_by_slug"), slug) },
|
||||
@ -85,12 +86,13 @@ const incrementPageHits = async (slug: string | string[], client: Client): Promi
|
||||
);
|
||||
|
||||
// send client the *new* hit count
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
||||
return result.data;
|
||||
};
|
||||
|
||||
const getSiteStats = async (client: Client): Promise<OverallStats> => {
|
||||
// get database and RSS results asynchronously
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
|
||||
const [feed, result] = await Promise.all<{ [key: string]: any }, any>([
|
||||
parser.parse(await (await fetch(baseUrl + "feed.xml")).text()), // this is messy but it works :)
|
||||
client.query(
|
||||
@ -101,6 +103,7 @@ const getSiteStats = async (client: Client): Promise<OverallStats> => {
|
||||
),
|
||||
]);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
||||
const pages: PageStats[] = result.data;
|
||||
const stats: OverallStats = {
|
||||
total: { hits: 0 },
|
||||
@ -109,10 +112,14 @@ const getSiteStats = async (client: Client): Promise<OverallStats> => {
|
||||
|
||||
pages.map((p: PageStats) => {
|
||||
// match URLs from RSS feed with db to populate some metadata
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
||||
const match = feed.rss.channel.item.find((x: { link: string }) => x.link === baseUrl + p.slug + "/");
|
||||
if (match) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
p.title = decode(match.title);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
||||
p.url = match.link;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
p.date = new Date(match.pubDate).toISOString();
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ export default async (req: VercelRequest, res: VercelResponse) => {
|
||||
Sentry.captureException(error);
|
||||
await Sentry.flush(2000);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
||||
res.status(400).json({ message: error.message });
|
||||
}
|
||||
};
|
||||
@ -94,7 +95,9 @@ const fetchRepos = async (sort: string, limit: number): Promise<Repository[]> =>
|
||||
}
|
||||
`;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const response = await client.request(query, { sort, limit });
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
||||
const currentRepos: Repository[] = response.user.repositories.edges.map(
|
||||
({ node: repo }: { [key: string]: Repository }) => ({
|
||||
...repo,
|
||||
|
@ -63,6 +63,7 @@ export default async (req: VercelRequest, res: VercelResponse) => {
|
||||
Sentry.captureException(error);
|
||||
await Sentry.flush(2000);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
||||
res.status(400).json({ message: error.message });
|
||||
}
|
||||
};
|
||||
@ -84,6 +85,7 @@ const getAccessToken = async () => {
|
||||
};
|
||||
|
||||
const getNowPlaying = async (): Promise<Track> => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const { access_token } = await getAccessToken();
|
||||
|
||||
const response = await fetch(NOW_PLAYING_ENDPOINT, {
|
||||
@ -98,6 +100,7 @@ const getNowPlaying = async (): Promise<Track> => {
|
||||
return { isPlaying: false };
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const active: Activity = await response.json();
|
||||
|
||||
if (active.is_playing === true && active.item) {
|
||||
@ -122,6 +125,7 @@ const getNowPlaying = async (): Promise<Track> => {
|
||||
};
|
||||
|
||||
const getTopTracks = async (): Promise<Track[]> => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const { access_token } = await getAccessToken();
|
||||
|
||||
const response = await fetch(TOP_TRACKS_ENDPOINT, {
|
||||
@ -132,8 +136,10 @@ const getTopTracks = async (): Promise<Track[]> => {
|
||||
},
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const { items } = await response.json();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
||||
const tracks: Track[] = items.map((track: TrackSchema) => ({
|
||||
artist: track.artists.map((_artist) => _artist.name).join(", "),
|
||||
title: track.name,
|
||||
|
Reference in New Issue
Block a user