Skip to content

Commit 7552702

Browse files
add success property to json object response.
1 parent b15d6a7 commit 7552702

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ app.use(function(err, req, res, next) {
8080

8181
let status = err.status || 500;
8282
// render the error page
83-
res.status(status).json({message: err.message});
83+
res.status(status).json({success: false, status: status, message: err.message});
8484
});
8585

8686
module.exports = app; //This for testing...

src/routes/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ router.post('/', (req, res, next) => {
2929
return next(err);
3030
}
3131
res.location('/');
32-
return res.status(201).json({message: "User Successfully added!", status: 201, user});
32+
return res.status(201).json({success: true, message: "User Successfully added!", status: 201, user});
3333
});
3434
});
3535
});

test/user_test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const chai = require('chai');
77
const chaiHttp = require('chai-http');
88
const server = require('../src/app');
99
const should = chai.should();
10+
const expect = chai.expect;
1011

1112
const postAPI = '/api/users';
1213

@@ -18,6 +19,10 @@ describe('Users', () => {
1819
});
1920
});
2021

22+
describe('/GET users', () => {
23+
//it('shoul')
24+
25+
});
2126

2227
describe('/POST users', () => {
2328
let user400 = {
@@ -38,9 +43,6 @@ describe('Users', () => {
3843
user400.email = "test@owiejadskla";
3944
postUser400(user400, done);
4045
});
41-
42-
43-
4446
it('should not POST if email Address already exists in DB', (done) => {
4547
let user = {
4648
emailAddress: 'test@gmail.com',

0 commit comments

Comments
 (0)