Skip to content

Instantly share code, notes, and snippets.

@dhigginbotham
Last active January 2, 2016 23:18
Show Gist options
  • Save dhigginbotham/8375102 to your computer and use it in GitHub Desktop.
Save dhigginbotham/8375102 to your computer and use it in GitHub Desktop.
`npm i express underscore superagent && node test.js`
var express = require('express'),
_ = require('underscore'),
request = require('superagent'),
app = express(),
server = require('http').createServer(app);
app.set('port', 5555);
app.use(express.json());
app.use(express.urlencoded());
var defaultHours = {
sunday: {
open: 0,
close: 0
},
monday: {
open: 0,
close: 0
},
tuesday: {
open: 0,
close: 0
},
wednesday: {
open: 0,
close: 0
},
thursday: {
open: 0,
close: 0
},
friday: {
open: 0,
close: 0
},
saturday: {
open: 0,
close: 0
}
};
app.all('/test', function (req, res) {
return res.send(_.isEqual(defaultHours, req.body));
});
app.listen(app.get('port'));
var newHours = {
saturday: {
close: 0,
open: 0
},
friday: {
close: 0,
open: 0
},
thursday: {
close: 0,
open: 0
},
wednesday: {
close: 0,
open: 0
},
tuesday: {
close: 0,
open: 0
},
monday: {
close: 0,
open: 0
},
sunday: {
close: 0,
open: 0
}
};
request
.post('http://localhost:5555/test')
.send(newHours)
.set('Accept', 'application/json')
.end(function(error, res){
if (error) return console.log(error);
if (res) return console.log(res.body);
});
@dhigginbotham
Copy link
Author

returns true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment