Last active
August 29, 2015 13:56
-
-
Save VessoVit/8922493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var js = require('jsonfile'), util = require('util'); | |
//DateTime library | |
var moment = require('moment'); | |
//Default Date() Node | |
var date = new Date(); | |
var n = date.toJSON(); | |
//moment library diff test | |
var startDate = moment('2014-1-10 0:00:00', 'YYYY-M-DD HH:mm:ss') | |
var endDate = moment('2014-1-10 0:19:00', 'YYYY-M-DD HH:mm:ss') | |
var secondsDiff = endDate.diff(startDate, 'minutes') | |
var now = moment('YYYY-M-DD HH:mm:ss') | |
var msg = 'msg.txt'; | |
var jfile = 'jfile.json'; | |
exports.index = function(req, res){ | |
res.json({ Love: 'Hello, World! '}) | |
res.json(500, { error: 'message'}) | |
}; | |
exports.send = function(req, res){ | |
// | |
var jsonConst = { | |
msg: 'Love Send', | |
dataTime: n, | |
user: 'test' | |
}; | |
jsonString = JSON.stringify(jsonConst); | |
// res.json(jsonString); | |
res.send(jsonString); | |
fs.appendFile('msg.txt', jsonString + '\n ' , function(err, data){ | |
if (err) { | |
return console.log(err); | |
} | |
console.log('The "data to append" was appended to file!'); | |
}; | |
exports.status = function(req, res){ | |
var jsondata = fs.readFileSync(jfile, "utf8"); | |
res.send(jsondata); | |
} | |
exports.lastLove = function(req, res){ | |
var LovePackage = { | |
msg: 'Love is the air', | |
dateTime: secondsDiff, | |
user: 'test user' | |
} | |
res.json(LovePackage); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment