Skip to content

Commit 78cb308

Browse files
committed
cleanup and heroku setup
1 parent e172cc0 commit 78cb308

File tree

68 files changed

+260
-2141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+260
-2141
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
2+
node_modules_old/
23
.vscode/
34
keyValStore/

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node app.js

app.js

Lines changed: 2 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*******************************************************************************/
99

1010
let express = require('express');
11-
let session = require('express-session');
12-
let cookieParser = require('cookie-parser');
1311
let bodyParser = require('body-parser');
1412
let app = express();
1513
let url = require('url');
@@ -25,11 +23,7 @@ let configFile = require(__dirname + '/server/configurations/configuration.js');
2523
let blocks = require(__dirname + '/server/blockchain/blocks/blocks.js');
2624
let block = require(__dirname + '/server/blockchain/blocks/block/block.js');
2725
let identity = require(__dirname + '/server/blockchain/identity/identity.js');
28-
let vehicles = require(__dirname + '/server/blockchain/assets/vehicles/vehicles.js');
29-
let vehicle = require(__dirname + '/server/blockchain/assets/vehicles/vehicle/vehicle.js');
3026
let issuers = require(__dirname + '/server/blockchain/issuers/issuers.js');
31-
let chaincode = require(__dirname + '/server/blockchain/chaincode/chaincode.js');
32-
let transactions = require(__dirname + '/server/blockchain/transactions/transactions.js');
3327
let startup = require(__dirname + '/server/configurations/startup/startup.js');
3428
let http = require('http');
3529

@@ -44,8 +38,6 @@ let port = process.env.VCAP_APP_PORT || configFile.config.appPort;
4438
//////// Pathing and Module Setup ////////
4539
app.use(bodyParser.json());
4640
app.use(bodyParser.urlencoded());
47-
app.use(cookieParser());
48-
app.use(session({ secret: 'Somethignsomething1234!test', resave: true, saveUninitialized: true }));
4941

5042
// Enable CORS preflight across the board.
5143
app.options('*', cors());
@@ -60,12 +52,12 @@ app.use('/node_modules', express.static(__dirname + '/node_modules'));
6052
//-----------------------------------------------------------------------------------------------
6153
// Blockchain - Identity
6254
//-----------------------------------------------------------------------------------------------
63-
app.post('/blockchain/identity/:providerEnrollmentID', function (req, res, next) //Sets the session user to have the account address for the page they are currently on
55+
app.post('/blockchain/identity/:providerEnrollmentID', function (req, res, next)
6456
{
6557
identity.create(req, res,next);
6658
});
6759

68-
app.post('/blockchain/identity/initialize/new', function (req, res, next) //Sets the session user to have the account address for the page they are currently on
60+
app.post('/blockchain/identity/initialize/new', function (req, res, next)
6961
{
7062
identity.initialize(req, res, next);
7163
});
@@ -81,12 +73,6 @@ app.get('/blockchain/identity/:providerEnrollmentID/:identityCode', function (re
8173
identity.getIdentity(req, res, next);
8274
});
8375

84-
//-----------------------------------------------------------------------------------------------
85-
// Blockchain - chaincode
86-
//-----------------------------------------------------------------------------------------------
87-
app.post('/blockchain/chaincode/vehicles', function (req, res, next) {
88-
chaincode.vehicles.create(req, res, next, usersToSecurityContext);
89-
});
9076

9177
//-----------------------------------------------------------------------------------------------
9278
// Blockchain - Blocks8d55b8daf0
@@ -110,110 +96,12 @@ app.get('/blockchain/issuers', function (req, res, next) {
11096
issuers.read(req, res, next);
11197
});
11298

113-
//-----------------------------------------------------------------------------------------------
114-
// Blockchain - Assets - Vehicles - Vehicle
115-
//-----------------------------------------------------------------------------------------------
116-
117-
app.get('/blockchain/assets/vehicles/:v5cID', function (req, res, next) {
118-
vehicle.read(req, res, next, usersToSecurityContext);
119-
});
120-
121-
//-----------------------------------------------------------------------------------------------
122-
// Blockchain - Assets - Vehicles - Vehicle - Owner
123-
//-----------------------------------------------------------------------------------------------
124-
app.get('/blockchain/assets/vehicles/:v5cID/owner', function (req, res, next) {
125-
vehicle.owner.read(req, res, next, usersToSecurityContext);
126-
});
127-
128-
app.put('/blockchain/assets/vehicles/:v5cID/owner', function (req, res, next) {
129-
vehicle.owner.update(req, res, next, usersToSecurityContext);
130-
});
131-
132-
//-----------------------------------------------------------------------------------------------
133-
// Blockchain - Assets - Vehicles - Vehicle - VIN
134-
//-----------------------------------------------------------------------------------------------
135-
app.get('/blockchain/assets/vehicles/:v5cID/VIN', function (req, res, next) {
136-
vehicle.VIN.read(req, res, next, usersToSecurityContext);
137-
});
138-
139-
app.put('/blockchain/assets/vehicles/:v5cID/VIN', function (req, res, next) {
140-
vehicle.VIN.update(req, res, next, usersToSecurityContext);
141-
});
142-
143-
//-----------------------------------------------------------------------------------------------
144-
// Blockchain - Assets - Vehicles - Vehicle - Colour
145-
//-----------------------------------------------------------------------------------------------
146-
app.get('/blockchain/assets/vehicles/:v5cID/colour', function (req, res, next) {
147-
vehicle.colour.read(req, res, next, usersToSecurityContext);
148-
});
149-
150-
app.put('/blockchain/assets/vehicles/:v5cID/colour', function (req, res, next) {
151-
vehicle.colour.update(req, res, next, usersToSecurityContext);
152-
});
153-
154-
155-
//-----------------------------------------------------------------------------------------------
156-
// Blockchain - Assets - Vehicles - Vehicle - Make
157-
//-----------------------------------------------------------------------------------------------
158-
app.get('/blockchain/assets/vehicles/:v5cID/make', function (req, res, next) {
159-
vehicle.make.read(req, res, next, usersToSecurityContext);
160-
});
161-
162-
app.put('/blockchain/assets/vehicles/:v5cID/make', function (req, res, next) {
163-
vehicle.make.update(req, res, next, usersToSecurityContext);
164-
});
165-
166-
//-----------------------------------------------------------------------------------------------
167-
// Blockchain - Assets - Vehicles - Vehicle - Model
168-
//-----------------------------------------------------------------------------------------------
169-
app.get('/blockchain/assets/vehicles/:v5cID/model', function (req, res, next) {
170-
vehicle.model.read(req, res, next, usersToSecurityContext);
171-
});
172-
173-
app.put('/blockchain/assets/vehicles/:v5cID/model', function (req, res, next) {
174-
vehicle.model.update(req, res, next, usersToSecurityContext);
175-
});
176-
177-
//-----------------------------------------------------------------------------------------------
178-
// Blockchain - Assets - Vehicles - Vehicle - Reg
179-
//-----------------------------------------------------------------------------------------------
180-
app.get('/blockchain/assets/vehicles/:v5cID/reg', function (req, res, next) {
181-
vehicle.reg.read(req, res, next, usersToSecurityContext);
182-
});
183-
184-
app.put('/blockchain/assets/vehicles/:v5cID/reg', function (req, res, next) {
185-
186-
vehicle.reg.update(req, res, next, usersToSecurityContext);
187-
});
188-
189-
//-----------------------------------------------------------------------------------------------
190-
// Blockchain - Assets - Vehicles - Vehicle - Scrapped
191-
//-----------------------------------------------------------------------------------------------
192-
app.delete('/blockchain/assets/vehicles/:v5cID', function (req, res, next) {
193-
vehicle.delete(req, res, next, usersToSecurityContext);
194-
});
195-
196-
app.get('/blockchain/assets/vehicles/:v5cID/scrap', function (req, res, next) {
197-
vehicle.scrapped.read(req, res, next, usersToSecurityContext);
198-
});
199-
200-
201-
//-----------------------------------------------------------------------------------------------
202-
// Blockchain - Transactions
203-
//------------------------chain.setDeployWaitTime(100);-----------------------------------------------------------------------
204-
app.get('/blockchain/transactions', function (req, res, next) {
205-
transactions.read(req, res, next, usersToSecurityContext);
206-
});
20799

208100
/////////// Configure Webserver ///////////
209101
app.use(function (req, res, next) {
210102
let keys;
211103
console.log('------------------------------------------ incoming request ------------------------------------------');
212104
console.log('New ' + req.method + ' request for', req.url);
213-
req.bag = {}; //create my object for my stuff
214-
req.session.count = eval(req.session.count) + 1;
215-
req.bag.session = req.session;
216-
217105
let url_parts = url.parse(req.url, true);
218106
req.parameters = url_parts.query;
219107
keys = Object.keys(req.parameters);
@@ -236,12 +124,6 @@ app.use(function (err, req, res, next) { // = development error handler,
236124
console.log('Error Handler -', req.url, err);
237125
let errorCode = err.status || 500;
238126
res.status(errorCode);
239-
if (req.bag) {
240-
req.bag.error = { msg: err.stack, status: errorCode };
241-
if (req.bag.error.status === 404) {
242-
req.bag.error.msg = 'Sorry, I cannot locate that file';
243-
}
244-
}
245127
//res.render('template/error', {bag: req.bag});
246128
res.send({ 'message': err });
247129
});
@@ -332,20 +214,6 @@ io.sockets.on('connection', (socket) => {
332214
eventEmitter.emit('setup', demoStatus);
333215
});
334216

335-
function setSetupError(err) {
336-
demoStatus.status = 'ERROR';
337-
demoStatus.success = false;
338-
if (!process.env.VCAP_SERVICES) {
339-
demoStatus.error = 'There was an error starting the demo. Please try again.';
340-
demoStatus.detailedError = err.message || 'Server error';
341-
} else {
342-
demoStatus.error = 'There was an error starting the demo. Please try again. Ensure you delete both the demo and the blockchain service';
343-
demoStatus.detailedError = err.message || 'Server error';
344-
}
345-
if (eventEmitter) {
346-
eventEmitter.emit('setup', demoStatus);
347-
}
348-
}
349217

350218

351219
let chaincodeID;

0 commit comments

Comments
 (0)