-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (33 loc) · 1.28 KB
/
app.js
File metadata and controls
40 lines (33 loc) · 1.28 KB
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
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const http = require('http');
const cors = require('cors');
require('dotenv').config();
const loggerCommon = require('./utils/logger');
const routeChannel = require('./routes/channel');
const routeChaincode = require('./routes/chaincode');
const routePeer = require('./routes/peer');
const routeCA = require('./routes/ca');
const logger = loggerCommon.getLogger('admin-service');
const app = express();
const host = process.env.HOST || 'localhost';
const port = process.env.PORT || '4001';
// app.set('view engine', 'ejs');
app.options('*', cors());
app.use(cors());
// support parsing of application/json type post data
app.use(bodyParser.json());
// support parsing of application/x-www-form-urlencoded post data
app.use(bodyParser.urlencoded({
extended: true,
}));
app.use('/api/v2/channels', routeChannel);
app.use('/api/v2/chaincodes', routeChaincode);
app.use('/api/v2/peers', routePeer);
app.use('/api/v2/cas', routeCA);
const server = http.createServer(app).listen(port, () => {
logger.info('****************** SERVER STARTED ************************');
logger.info('*************** http://%s:%s ******************', host, port);
});
server.timeout = 240000;