Also apply basic linting to Netlify functions

This commit is contained in:
Taevas 2024-04-27 18:45:18 +02:00
parent 3d38ba1768
commit eb85319f73
11 changed files with 272 additions and 258 deletions

View file

@ -1,6 +1,6 @@
import { Handler } from '@netlify/functions'
import fetch from "node-fetch"
import { GitlabInfo } from '../../src/components/infos/Git'
import {type Handler} from "@netlify/functions";
import fetch from "node-fetch";
import {type GitlabInfo} from "../../src/components/Info/Git.js";
const handler: Handler = async () => {
const gitlab = await fetch("https://gitlab.com/api/v4/events?action=pushed", {
@ -8,26 +8,26 @@ const handler: Handler = async () => {
headers: {
"PRIVATE-TOKEN": process.env.API_GITLAB!,
"Content-Type": "application/json",
"Accept": "application/json"
}
})
"Accept": "application/json",
},
});
if (gitlab.status !== 200) {
return {
statusCode: 404,
body: ""
}
body: "",
};
}
const json = await gitlab.json() as {[key: string]: any}
const json = await gitlab.json() as Record<string, any>;
const activity: GitlabInfo = {
date: json[0].created_at.substring(0, json[0].created_at.indexOf("T"))
}
date: json[0].created_at.substring(0, json[0].created_at.indexOf("T")),
};
return {
statusCode: 200,
body: JSON.stringify(activity)
}
}
body: JSON.stringify(activity),
};
};
export { handler }
export {handler};