Skip to content

Instantly share code, notes, and snippets.

@benewen96
Last active August 6, 2016 12:24
Show Gist options
  • Save benewen96/bc60e2893d3475bd833a0aaebeba6e5a to your computer and use it in GitHub Desktop.
Save benewen96/bc60e2893d3475bd833a0aaebeba6e5a to your computer and use it in GitHub Desktop.
var SFserver = require("./conn.js");
var createRecord = require("./createRecord.js");
var http = require('http');
var conn = undefined;
//create a new record object
var newRecord = function() {
SFserver.Connect(function(err, connection) { //connect to sf
if(err) {
console.log(err);
}
else {
console.log('Connect success');
conn = connection; //pull connection to index.js
createRecord.Create(conn,function(err, ret) { //call create record method
if(err) {
console.log('Couldnt create record');
}
else {
console.log('RECORD CREATED: ' + ret.id);
}
});
}
});
}
var server = function() {
http.createServer(function (request, response) {
request.on('data', function(chunk) {
response.write(chunk.length); //test write length of chuck received
}).on('end', function() {
newRecord(); //create a new record
response.end('RECORD Created');
})
}).listen(process.env.PORT, process.env.IP);
}
server();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment