-
Notifications
You must be signed in to change notification settings - Fork 0
/
route.js
34 lines (28 loc) · 868 Bytes
/
route.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// inicia as rotas
const express = require("express");
const bodyParser = require("body-parser");
const morgan = require("morgan");
const cors = require("cors"); // permitir acesso de determinado dominio
const path = require("path");
const main = require("./index");
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(morgan("dev"));
app.use(cors());
app.get("/gen/:breakPoint", (req, res) => {
const { breakPoint } = req.params;
console.log(breakPoint);
try {
const fn = main(100, parseFloat(breakPoint));
let result = fn.start();
res.json(result);
} catch (error) {
console.log(error);
res.status(400).send({ error: "sorry" });
}
});
app.use(express.static(path.join(__dirname, "public")));
const porta = process.env.PORT || 3001;
console.log(`[D]Porta: ${porta}`);
app.listen(porta);