mirror of
https://github.com/skidoodle/erettsegi-browser.git
synced 2025-02-15 05:39:15 +01:00
minor changes pt.2
This commit is contained in:
parent
6275b083db
commit
76f75a2f60
17 changed files with 416 additions and 276 deletions
|
@ -2,7 +2,7 @@ import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
|||
import { Analytics } from '@vercel/analytics/react'
|
||||
import { NextUIProvider } from '@nextui-org/react'
|
||||
import { Inter } from 'next/font/google'
|
||||
import { AppProps } from 'next/app'
|
||||
import type { AppProps } from 'next/app'
|
||||
import Head from 'next/head'
|
||||
import '@/styles/globals.css'
|
||||
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { subjects } from '@/utils/subjects'
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { vizsgatargy, ev, idoszak, szint } = req.query
|
||||
const { vizsgatargy, ev, idoszak, szint } = req.query as {
|
||||
vizsgatargy: string
|
||||
ev: string
|
||||
idoszak: string
|
||||
szint: string
|
||||
}
|
||||
|
||||
const baseUrl = `https://dload-oktatas.educatio.hu/erettsegi/feladatok_${ev}${idoszak}_${szint}/`
|
||||
|
||||
const missingParams = []
|
||||
|
@ -17,16 +23,16 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||
.json({ error: `Hiányzó paraméterek: ${missingParams.join(', ')}` })
|
||||
}
|
||||
|
||||
if (ev! <= '2012') {
|
||||
if (ev <= '2012') {
|
||||
return res.status(400).json({ error: 'Érvénytelen év' })
|
||||
}
|
||||
|
||||
const validSubjects = subjects.map((subject) => subject.value)
|
||||
if (!vizsgatargy || !validSubjects.includes(vizsgatargy as string)) {
|
||||
if (!vizsgatargy || !validSubjects.includes(vizsgatargy)) {
|
||||
return res.status(400).json({ error: 'Érvénytelen vizsgatárgy' })
|
||||
}
|
||||
|
||||
let honap
|
||||
let honap: string
|
||||
switch (idoszak) {
|
||||
case 'osz':
|
||||
honap = 'okt'
|
||||
|
@ -38,7 +44,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||
return res.status(400).json({ error: 'Érvénytelen időszak' })
|
||||
}
|
||||
|
||||
let prefix
|
||||
let prefix: string
|
||||
switch (szint) {
|
||||
case 'emelt':
|
||||
prefix = `e_${vizsgatargy}`
|
||||
|
@ -54,7 +60,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||
const utmutato = 'ut'
|
||||
const forras = 'for'
|
||||
const megoldas = 'meg'
|
||||
const shortev = ev!.slice(-2)
|
||||
const shortev = ev.slice(-2)
|
||||
|
||||
let flPdfUrl, utPdfUrl, flZipUrl, utZipUrl
|
||||
switch (vizsgatargy) {
|
||||
|
|
29
src/pages/api/validate.ts
Normal file
29
src/pages/api/validate.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const { link } = req.query as { link: string }
|
||||
let MissingParam: string | null = null
|
||||
if (!link) {
|
||||
MissingParam = 'link'
|
||||
}
|
||||
|
||||
if (MissingParam) {
|
||||
return res.status(400).json({ error: `Hiányzó paraméter: ${MissingParam}` })
|
||||
}
|
||||
|
||||
const domain = link.split('/')[2]
|
||||
if (domain !== 'dload-oktatas.educatio.hu') {
|
||||
return res.status(400).json({ error: 'Érvénytelen link' })
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(link, { method: 'HEAD' })
|
||||
const status = response.status
|
||||
res.status(200).json({ status })
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Hiányzó paraméterek:' })
|
||||
}
|
||||
}
|
|
@ -39,7 +39,7 @@ export default function Home() {
|
|||
|
||||
useEffect(() => {
|
||||
if (selectedLevel && selectedPeriod && selectedSubject && selectedYear) {
|
||||
fetchData(
|
||||
void fetchData(
|
||||
selectedSubject,
|
||||
selectedYear,
|
||||
selectedPeriod,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue