-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
62 lines (47 loc) · 1.37 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import express from "express";
import bodyParser from "body-parser";
import dataStore from "nedb";
import {handler} from "./front/build/handler.js";
import cors from "cors";
//APIs
import {api_EGO} from './backEGO/indexAPI-EGOv1.js';
import {api_EGO_v2} from './backEGO/indexAPI-EGOv2.js';
import {api_VEG} from './backVEG/api-VEG-v1.js';
import {api_VEG_v2} from './backVEG/api-VEG-v2.js';
import {api_NRM} from './BackNRM/index-api-v2.js';
//para el proxy
import request from "request";
let dbMovies = new dataStore();
let db = new dataStore();
let dbUfc = new dataStore();
let app = express();
const PORT = (process.env.PORT || 10002);
app.use(cors({
"origin": "*",
"methods" : "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"optionsSuccessStatus":204
}));
//Proxy NRM
app.use("/proxyNRM", function(req,res){
var url = "https://sos2324-14.appspot.com/api/v2/ufc-events-data";
console.log("piped: " + req.url);
req.pipe(request(url)).pipe(res);
});
app.use(bodyParser.json());
//app.use("/",express.static("./public"));
app.listen(PORT,()=>{
console.log(`Server listening on port ${PORT}.`);
});
// Nicolas Redondo Moreno
// API v1
api_NRM(app, dbUfc);
// Enrique Garcia Olivares
// API v1
api_EGO(app, dbMovies);
api_EGO_v2(app, dbMovies);
// Víctor Escalera García
// API v1
api_VEG(app, db);
api_VEG_v2(app, db);
app.use(handler);