forked from XinFinOrg/Faucet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (41 loc) · 1.12 KB
/
index.js
File metadata and controls
47 lines (41 loc) · 1.12 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
41
42
43
44
45
46
47
const express = require('express')
const fs = require('fs')
const bodyParser = require('body-parser')
let app = express();
const morgan = require('morgan')
// require('./src/helpers/blockchain-helper')(app)
require('./src/helpers/blockchain-helper')(app)
let config
const configPath = './config.json'
const configExists = fs.existsSync(configPath, fs.F_OK)
if (configExists) {
config = JSON.parse(fs.readFileSync(configPath, 'utf8'))
} else {
return console.log('There is no config.json file')
}
app.config = config
let web3
app.use(morgan('short'))
app.configureWeb3(config)
.then(web3 => {
app.web3 = web3
app.use(express.static(__dirname + '/public'))
app.use(bodyParser.json({
limit: '100mb',
}))
app.use(bodyParser.urlencoded({
limit: '100mb',
extended: true,
}))
require('./src/controllers/index')(app)
app.get('/', function(request, response) {
response.send('XDC Apothem Network Faucet')
});
app.set('port', (process.env.PORT || 3000))
app.listen(app.get('port'), function () {
console.log('XDC Apothem Network Faucet is running on port', app.get('port'))
})
})
.catch(error => {
return console.log(error)
})