Created
May 30, 2023 01:01
-
-
Save almcarvalho/f95d9668f8abfe88d10c064b172238f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import cors from 'cors'; | |
import express from 'express'; | |
require('dotenv').config(); | |
const PORT: string | number = process.env.PORT || 5000; | |
const app = express(); | |
app.use(cors()); | |
app.use(express.json()); | |
var valorDoPix = 0; | |
var valorAux = 0; | |
app.get("/rafael", async (req, res) => { | |
if (valorDoPix > 0) { | |
valorAux = valorDoPix; | |
valorDoPix = 0; | |
if (valorAux > 10) { //bloquear maiores que 10. | |
valorAux = 2; | |
} | |
return res.status(200).json({ "": valorAux }); | |
} else { | |
return res.status(200).json({ "": 0 }); | |
} | |
}); | |
app.post("/rota-recebimento", async (req, res) => { | |
try { | |
console.log(req.body.pix.value); | |
valorDoPix = req.body.pix.value; | |
} catch (error) { | |
console.error(error); | |
} | |
return res.status(200).json({ "ok": "ok" }); | |
}); | |
//git push heroku main | |
app.listen(PORT, () => console.log(`localhost:${PORT}`)); | |
//código escrito por Lucas Carvalho em meados de Maio - 2023.. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment