Skip to content

Commit 74c59f9

Browse files
author
Benjamin E White
authored
Merge pull request #7 from tsongas/serialize
change apiRepr() to serialize(), mocha version bump
2 parents 35b9d00 + e0bf549 commit 74c59f9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

auth/router.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const localAuth = passport.authenticate('local', {session: false});
1919
router.use(bodyParser.json());
2020
// The user provides a username and password to login
2121
router.post('/login', localAuth, (req, res) => {
22-
const authToken = createAuthToken(req.user.apiRepr());
22+
const authToken = createAuthToken(req.user.serialize());
2323
res.json({authToken});
2424
});
2525

users/models.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const UserSchema = mongoose.Schema({
1818
lastName: {type: String, default: ''}
1919
});
2020

21-
UserSchema.methods.apiRepr = function() {
21+
UserSchema.methods.serialize = function() {
2222
return {
2323
username: this.username || '',
2424
firstName: this.firstName || '',

users/router.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ router.post('/', jsonParser, (req, res) => {
122122
});
123123
})
124124
.then(user => {
125-
return res.status(201).json(user.apiRepr());
125+
return res.status(201).json(user.serialize());
126126
})
127127
.catch(err => {
128128
// Forward validation errors on to the client, otherwise give a 500
@@ -140,7 +140,7 @@ router.post('/', jsonParser, (req, res) => {
140140
// verify this in the Mongo shell.
141141
router.get('/', (req, res) => {
142142
return User.find()
143-
.then(users => res.json(users.map(user => user.apiRepr())))
143+
.then(users => res.json(users.map(user => user.serialize())))
144144
.catch(err => res.status(500).json({message: 'Internal server error'}));
145145
});
146146

0 commit comments

Comments
 (0)