Skip to content

Commit

Permalink
feat: local api
Browse files Browse the repository at this point in the history
  • Loading branch information
enzonotario committed Feb 3, 2024
1 parent d6978da commit 1f94c99
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 1 deletion.
18 changes: 18 additions & 0 deletions api/api.esjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
importar { Hono } desde 'hono'
importar { cors } desde 'hono/cors'
importar fs desde 'node:fs'

exportar const app = crear Hono()

app.use('*', cors())

app.get('/v1/cotizaciones/dolares', asincrono (c) => {
const json = fs.readFileSync(
'./datos/v1/cotizaciones/dolares/index.json',
'utf8',
)

retornar c.json(JSON.analizar(json))
})

exportar porDefecto app
8 changes: 8 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { handle } from 'hono/vercel'
import { app } from '../dist/servidor/api.js'

export const config = {
runtime: 'edge',
}

export default handle(app)
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"cron": "node ./dist/index.js"
"cron": "node ./dist/index.js",
"api:dev": "vite --config vite.api.config.js --host",
"api:build": "vite build --config vite.api.config.js --ssr --mode=production"
},
"devDependencies": {
"@es-js/core": "^0.0.20",
"@es-js/vite-plugin-esjs": "^0.0.15",
"@hono/vite-dev-server": "^0.0.12",
"hono": "^3.9.0",
"cheerio": "1.0.0-rc.12",
"collect.js": "^4.36.1",
"date-fns": "^3.2.0",
Expand Down
Loading

0 comments on commit 1f94c99

Please sign in to comment.