1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-10-26 01:05:49 -04:00

add getStaticProps types

This commit is contained in:
2022-06-30 20:56:34 -04:00
parent 5f22b7989d
commit 887c24d317
17 changed files with 67 additions and 50 deletions

View File

@@ -26,7 +26,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
// these are both backups to client-side validations just in case someone squeezes through without them. the codes
// are identical so they're caught in the same fashion.
if (!body || !body.name || !body.email || !body.message) {
if (!body.name || !body.email || !body.message) {
// all fields are required
throw new Error("USER_MISSING_DATA");
}
@@ -63,7 +63,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
}
};
const validateCaptcha = async (formResponse: unknown) => {
const validateCaptcha = async (formResponse: unknown): Promise<unknown> => {
const response = await fetch(HCAPTCHA_API_ENDPOINT, {
method: "POST",
headers: {
@@ -76,13 +76,12 @@ const validateCaptcha = async (formResponse: unknown) => {
}),
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result: any = await response.json();
const result = await response.json();
return result.success as boolean;
return result.success;
};
const sendToAirtable = async (data: unknown) => {
const sendToAirtable = async (data: unknown): Promise<boolean> => {
const response = await fetch(`${AIRTABLE_API_ENDPOINT}${AIRTABLE_BASE}/Messages`, {
method: "POST",
headers: {

View File

@@ -54,7 +54,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
await logServerError(error);
// 500 Internal Server Error
return res.status(500).json({ success: false, message });
return res.status(500).json({ message });
}
};
@@ -75,7 +75,7 @@ const getAccessToken = async () => {
const { access_token: token } = await response.json();
return token as string;
return token;
};
const getNowPlaying = async (token: string): Promise<Track | false> => {
@@ -120,7 +120,7 @@ const getTopTracks = async (token: string): Promise<Track[]> => {
const { items } = (await response.json()) as { items: SpotifyTrackSchema[] };
const tracks: Track[] = items.map((track: SpotifyTrackSchema) => ({
const tracks = items.map<Track>((track) => ({
artist: track.artists.map((artist) => artist.name).join(", "),
title: track.name,
album: track.album.name,