Skip to content

Commit

Permalink
#167313409 Users should be able to follow each other (#20)
Browse files Browse the repository at this point in the history
* rebase

* feature(follow-users):Users should be able to follow each other [Finishes #167313409]

* feature(follow-users):Improve follow user tests[Finishes #167313409]
  • Loading branch information
nkalyesubula authored and minega25 committed Aug 30, 2019
1 parent b76787a commit 4f0b5e4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/models/follow.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const Follow = sequelize.define('Follow', {
followerId: DataTypes.INTEGER,
followedUserId: DataTypes.INTEGER
}, {});
Follow.associate = ({ user }) => {
// associations can be defined here
Follow.belongsTo(user, {
foreignKey: 'followerId',
onDelete: 'CASCADE',
as: 'followerDetails'
});
Follow.belongsTo(user, {
foreignKey: 'followedUserId',
onDelete: 'CASCADE',
as: 'authorDetails'
});
};
return Follow;
};
const Follow = sequelize.define('Follow', {
followerId: DataTypes.INTEGER,
followedUserId: DataTypes.INTEGER
}, {});
Follow.associate = ({ user }) => {
// associations can be defined here
Follow.belongsTo(user, {
foreignKey: 'followerId',
onDelete: 'CASCADE',
as: 'followerDetails'
});
Follow.belongsTo(user, {
foreignKey: 'followedUserId',
onDelete: 'CASCADE',
as: 'authorDetails'
});
};
return Follow;
};
32 changes: 32 additions & 0 deletions src/routes/api/user/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,36 @@
* description: Successfully reset your password
* 400:
* description: Validation error
* /users/profiles/{userId}/follow:
* post:
* description: follow user
* produces:
* - application/json
* parameters:
* - in: path
* name: userId
* schema:
* type: integer
* required: true
* responses:
* 200:
* description: You are now following
* 400:
* description: userId must be a non negative integer
* /users/profiles/following:
* get:
* description: get all users that i follow
* produces:
* - application/json
* responses:
* 200:
* description: You currently do not follow anyone
* /users/profiles/followers:
* get:
* description: get all users that i follow
* produces:
* - application/json
* responses:
* 200:
* description: You currently do not have any followers
*/

0 comments on commit 4f0b5e4

Please sign in to comment.