<commit_before>'use strict';
/* global process */
/* global __dirname */
/*******************************************************************************
 * Copyright (c) 2015 IBM Corp.
 *
 * All rights reserved. 
 *
 * Contributors:
 *   <NAME> - Initial implementation
 *******************************************************************************/
/////////////////////////////////////////
///////////// Setup Node.js /////////////
/////////////////////////////////////////
var express = require('express');
var session = require('express-session');
var compression = require('compression');
var serve_static = require('serve-static');
var path = require('path');
var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var http = require('http');
var app = express();
var url = require('url');
var setup = require('./setup');
var fs = require('fs');
var cors = require('cors');

//// Set Server Parameters ////
var host = setup.SERVER.HOST;
var port = setup.SERVER.PORT;

// Set chaincode variables
var peers = null;
var users = null;
var chaincode = null;

// Set chaincode source repository
var chaincode_zip_url = "https://github.com/apiBlockchain/GscLabChaincode/archive/master.zip";
var	chaincode_unzip_dir ="GscLabChaincode-master";						
var	chaincode_git_url = "https://github.com/apiBlockchain/GscLabChaincode";

// Set chaincode source repository for Part C
//var chaincode_zip_url = "https://github.com/apiBlockchain/GscLabChaincodePartC/archive/master.zip";
//var	chaincode_unzip_dir ="GscLabChaincodePartC-master";						
//var	chaincode_git_url = "https://github.com/apiBlockchain/GscLabChaincodePartC";		


// Quick test for api demo
//var chaincode_zip_url = "https://github.com/apiBlockchain/ApiEconomyDemoChaincode/archive/master.zip";
//var	chaincode_unzip_dir ="ApiEconomyDemoChaincode-master";						
//var	chaincode_git_url = "https://github.com/apiBlockchain/ApiEconomyDemoChaincode";	

////////  Pathing and Module Setup  ////////
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.engine('.html', require('jade').__express);
app.use(compression());
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded()); 
app.use(cookieParser());
app.use('/cc/summary', serve_static(path.join(__dirname, 'cc_summaries')) );												//for chaincode investigator
app.use( serve_static(path.join(__dirname, 'public'), {maxAge: '1d', setHeaders: setCustomCC}) );							//1 day cache
//app.use( serve_static(path.join(__dirname, 'public')) );
app.use(session({secret:'Somethignsomething1234!test', resave:true, saveUninitialized:true}));
function setCustomCC(res, path) {
	if (serve_static.mime.lookup(path) === 'image/jpeg')  res.setHeader('Cache-Control', 'public, max-age=2592000');		//30 days cache
	else if (serve_static.mime.lookup(path) === 'image/png') res.setHeader('Cache-Control', 'public, max-age=2592000');
	else if (serve_static.mime.lookup(path) === 'image/x-icon') res.setHeader('Cache-Control', 'public, max-age=2592000');
}
// Enable CORS preflight across the board.
app.options('*', cors());
app.use(cors());

//---------------------
// Cache Busting Hash<commit_msg>Updatd app.js file<commit_after>'use strict';
/* global process */
/* global __dirname */
/*******************************************************************************
 * Copyright (c) 2015 IBM Corp.
 *
 * All rights reserved. 
 *
 * Contributors:
 *   <NAME> - Initial implementation
 *******************************************************************************/
/////////////////////////////////////////
///////////// Setup Node.js /////////////
/////////////////////////////////////////
var express = require('express');
var session = require('express-session');
var compression = require('compression');
var serve_static = require('serve-static');
var path = require('path');
var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var http = require('http');
var app = express();
var url = require('url');
var setup = require('./setup');
var fs = require('fs');
var cors = require('cors');

//// Set Server Parameters ////
var host = setup.SERVER.HOST;
var port = setup.SERVER.PORT;

// Set chaincode variables
var peers = null;
var users = null;
var chaincode = null;

// Set chaincode source repository for Part B
var chaincode_zip_url 		= "https://github.com/apiBlockchain/GscLabChaincode/archive/master.zip";
var	chaincode_unzip_dir 	= "GscLabChaincode-master";						
var	chaincode_git_url 		= "https://github.com/apiBlockchain/GscLabChaincode";

// Set chaincode source repository for Part C
//var chaincode_zip_url 	= "https://github.com/apiBlockchain/GscLabChaincodePartC/archive/master.zip";
//var chaincode_unzip_dir 	= "GscLabChaincodePartC-master";						
//var chaincode_git_url 	= "https://github.com/apiBlockchain/GscLabChaincodePartC";		


////////  Pathing and Module Setup  ////////
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.engine('.html', require('jade').__express);
app.use(compression());
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded()); 
app.use(cookieParser());
app.use('/cc/summary', serve_static(path.join(__dirname, 'cc_summaries')) );												//for chaincode investigator
app.use( serve_static(path.join(__dirname, 'public'), {maxAge: '1d', setHeaders: setCustomCC}) );							//1 day cache
//app.use( serve_static(path.join(__dirname, 'public')) );
app.use(session({secret:'Somethignsomething1234!test', resave:true, saveUninitialized:true}));
function setCustomCC(res, path) {
	if (serve_static.mime.lookup(path) === 'image/jpeg')  res.setHeader('Cache-Control', 'public, max-age=2592000');		//30 days cache
	else if (serve_static.mime.lookup(path) === 'image/png') res.setHeader('Cache-Control', 'public, max-age=2592000');
	else if (serve_static.mime.lookup(path) === 'image/x-icon') res.setHeader('Cache-Control', 'public, max-age=2592000');
}
// Enable CORS preflight across the board.
app.options('*', cors());
app.use(cors());

//---------------------
// Cache Busting Hash
{'fraction_non_alphanumeric': 0.2510913500404204, 'fraction_numerical': 0.01067097817299919, 'mean_word_length': 4.112396694214876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5113128', 'n_tokens_mistral': 1980, 'n_tokens_neox': 1831, 'n_words': 396}