-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
50 lines (44 loc) · 1.88 KB
/
server.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
'use strict';
/**
* _ _ ______ _______ _ _ _______ ____ _____ _____ _
* | | | | ____| |__ __| | | |__ __/ __ \| __ \|_ _| /\ | |
* | |__| | |__ | | | | | | | | | | | | |__) | | | / \ | |
* | __ | __| | | | | | | | | | | | | _ / | | / /\ \ | |
* | | | | | | | | |__| | | | | |__| | | \ \ _| |_ / ____ \| |____
* |_| |_|_| |_| \____/ |_| \____/|_| \_\_____/_/ \_\______|
*
* ===========================================================================
* Aplicacion realizada en NodeJS que se conecta con una red Hyperledger Fabric
* ======================
* @author Antonio Paya
*
*/
//==========MODULOS===============
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var rest = require('request');
var RedFabric = require('./redFabric.js');
//==========VARIABLES===============
app.set('port', 8081);
app.set('rest',rest);
const redFabric = new RedFabric('admin');
//==========INICIACION=============
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Credentials", "true");
res.header("Access-Control-Allow-Methods", "POST, GET, DELETE, UPDATE, PUT");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, token");
next();
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static('public'));
//==========RUTAS================
require("./routes.js")(app, redFabric);
//===========RUN===============
// Lanza el servidor
app.listen(app.get('port'), function() {
console.log("Autor: Antonio Paya Gonzalez");
console.log("Servidor activo en el puerto: 8081");
});