main.js 483 B

123456789101112131415161718
  1. import { Elysia } from 'elysia'
  2. import { Eta } from "eta"
  3. const eta = new Eta({ views: "./templates" })
  4. import Meteostanica from '../../utils/meteostanica'
  5. export default (langName) => new Elysia()
  6. .get('/', ({ set }) => {
  7. const data = Meteostanica.getData()
  8. set.headers['content-type'] = 'text/html; charset=utf8'
  9. return eta.render(`${langName}/index`, { data })
  10. })
  11. .get('/currentData', () => {
  12. const data = Meteostanica.getData()
  13. return data?.[0]
  14. })