More TypeScript :)
All checks were successful
pipeline / build-and-push-images (push) Successful in 22s
pipeline / deploy (push) Successful in 7s

This commit is contained in:
2024-11-29 18:39:32 +01:00
parent 0d50eb3085
commit b87e0db676
2 changed files with 6 additions and 5 deletions

View File

@@ -1,15 +1,16 @@
import { MongoClient } from 'mongodb';
import {connectToDatabase, fetchLatestPatch} from '../../utils/mongo'
async function championInfos(client, patch, championAlias) {
async function championInfos(client: MongoClient, patch: string, championAlias: string) {
const database = client.db("champions");
const collection = database.collection(patch);
const query = { alias:championAlias };
const championInfo = await collection.findOne(query);
const championInfo = (await collection.findOne(query)) as unknown as ChampionData;
return championInfo
}
export default defineEventHandler(async (event) => {
const championAlias = getRouterParam(event, "alias").toLowerCase()
const championAlias = (getRouterParam(event, "alias") as string).toLowerCase()
const client = await connectToDatabase();
const latestPatch = await fetchLatestPatch(client);
const data = await championInfos(client, latestPatch, championAlias);