-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
se implementó la funcionalidad que obtiene los valores para dolar y e…
…uro al día
- Loading branch information
Showing
6 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const express_1 = __importDefault(require("express")); | ||
const obtener_tasa_1 = require("./obtener_tasa"); | ||
const app = (0, express_1.default)(); | ||
const port = 4010; | ||
app.get('/', (req, res) => { | ||
res.send('Hello, TypeScript with Express!'); | ||
}); | ||
app.get('/tasa_de_cambio', async (req, res) => { | ||
try { | ||
const data = await (0, obtener_tasa_1.obtener_tasa_de_cambio)(); | ||
res.json(data); | ||
} | ||
catch (error) { | ||
if (error instanceof Error) { | ||
res.status(500).json({ message: error.message }); | ||
} | ||
else { | ||
res.status(500).json({ message: 'An unknown error occurred' }); | ||
} | ||
} | ||
}); | ||
app.listen(port, () => { | ||
console.log(`Server is running on http://localhost:${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.obtener_tasa_de_cambio = void 0; | ||
//SF43718 dolar | ||
//SF46410 euro | ||
const token_1 = require("./token"); | ||
async function obtener_tasa_de_cambio() { | ||
var url = "https://www.banxico.org.mx/SieAPIRest/service/v1/series/SF46410%2CSF43718/datos/oportuno"; | ||
const response = await fetch(url, { | ||
method: "GET", | ||
headers: { | ||
"Content-type": "application/json; charset=UTF-8", | ||
"Bmx-Token": token_1.token | ||
} | ||
}); | ||
const json = await response.json(); | ||
return json; | ||
} | ||
exports.obtener_tasa_de_cambio = obtener_tasa_de_cambio; | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.token = void 0; | ||
exports.token = 'c355bd604fb1ac3e65ed97187b63a6232f5be74f6da89434e53799aea3ee7620'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
import express from 'express'; | ||
|
||
import { obtener_tasa_de_cambio } from './obtener_tasa'; | ||
const app = express(); | ||
const port = 4010; | ||
|
||
app.get('/', (req, res) => { | ||
res.send('Hello, TypeScript with Express!'); | ||
}); | ||
|
||
|
||
app.get('/tasa_de_cambio', async (req, res) => { | ||
try { | ||
const data = await obtener_tasa_de_cambio(); | ||
res.json(data); | ||
} catch (error: unknown) { | ||
if (error instanceof Error) { | ||
res.status(500).json({ message: error.message }); | ||
} else { | ||
res.status(500).json({ message: 'An unknown error occurred' }); | ||
} | ||
} | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server is running on http://localhost:${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters