-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
52 lines (40 loc) · 1.56 KB
/
app.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
var express = require('express');
var exphbs = require('express-handlebars');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var logger = require('morgan');
var yaml = require('js-yaml');
var path = require('path');
var fs = require('fs');
var home = require('./routes/home.js');
var login = require('./routes/login.js');
var contract = require('./routes/contract.js');
var examples = require('./routes/examples.js');
var keys = require('./routes/keys.js');
var blocRootDir = path.normalize(path.join(__dirname, '..'));
var configFile = yaml.safeLoad(fs.readFileSync('config.yaml'));
var app = express();
app.engine('.hbs', exphbs({defaultLayout: 'main', extname: '.hbs'}));
app.set('view engine', '.hbs');
app.set('views', path.join(__dirname, 'views'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(session({resave: true,
saveUninitialized: true,
secret: 'session-to-track-global-wallet-pass-in-memory',
cookie: { maxAge: 60000 }}));
app.use('/', home);
app.use('/login', login);
app.use('/contracts', contract);
app.use('/examples', examples);
app.use('/keys', keys);
app.use('/css', express.static('css'));
app.use('/images', express.static('images'));
var server = app.listen(3000, 'localhost', function () {
var host = server.address().address;
var port = server.address().port;
console.log('bloc is listening on http://%s:%s', host, port);
});