| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import { Elysia } from 'elysia'
- import { Eta } from "eta"
- import Meteostanica from '../../utils/meteostanica'
- const eta = new Eta({ views: "./templates" })
- export default (langName, lang) => new Elysia({ prefix: `/history` })
- .get('/', ({ set }) => {
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/index`, { })
- })
- .get(`/:property`, ({ params: { property }, set }) => {
- const data = Meteostanica.getDataPropertyMonthly(property, `2026-03`)
- if (!data) {
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/notFound`, { property })
- }
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/property`, { lang, property, data })
- })
- .get(`/:property/daily`, ({ params: { property }, set }) => {
- const data = Meteostanica.getDataPropertyDaily(property, `2026-03-01`)
- if (!data) {
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/notFound`, { property })
- }
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/property`, { lang, type: `daily`, property, data })
- })
- .get(`/:property/monthly`, ({ params: { property }, set }) => {
- const data = Meteostanica.getDataPropertyMonthly(property, `2026-03`)
- if (!data) {
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/notFound`, { property })
- }
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/property`, { lang, type: `monthly`, property, data })
- })
- .get(`/:property/yearly`, ({ params: { property }, set }) => {
- const data = Meteostanica.getDataPropertyYearly(property, `2026`)
- if (!data) {
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/notFound`, { property })
- }
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/property`, { lang, type: `yearly`, property, data })
- })
- .get(`/:property/allTime`, ({ params: { property }, set }) => {
- const data = Meteostanica.getDataPropertyAllTime(property)
- if (!data) {
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/notFound`, { property })
- }
- set.headers['content-type'] = 'text/html; charset=utf8'
- return eta.render(`${langName}/history/property`, { lang, type: `allTime`, property, data })
- })
|