Skip to content

Commit

Permalink
updated routes to accept date in milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoythander committed Jan 8, 2019
1 parent 816a382 commit a7437c0
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 52 deletions.
33 changes: 31 additions & 2 deletions routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ router.route('/profile')
* @api {get} /admin/profile Get admin profile
* @apiHeader {String} Content-Type application/json
* @apiHeader {String} access-key Admin authentication token.
* @apiVersion 0.1.0
* @apiVersion 1.0.0
* @apiGroup AdminProfile
* @apiName GetAdminProfile
* @apiExample Example usage:
Expand Down Expand Up @@ -78,6 +78,35 @@ router.route('/profile')
* @apiParam {String} profile.phone Phone number.
* @apiParam {Date} profile.dob Date of birth.
*/

/**
* @api {put} /admin/profile Update admin profile
* @apiHeader {String} Content-Type application/json
* @apiHeader {String} access-key Admin authentication token.
* @apiVersion 1.0.0
* @apiGroup AdminProfile
* @apiName UpdateAdminProfile
* @apiExample Example usage:
* url: http://localhost:3484/admin/profile
*
* body:
* {
* "name": "John Doe",
* "profile": {
* "address": "Sylhet, BD",
* "company": "Owlette",
* "phone": "+8801413667755",
* "dob": 1546973225829
* }
* }
*
* @apiParam {String} name Admin's name.
* @apiParam {Object} profile Profile object.
* @apiParam {String} profile.address Address.
* @apiParam {String} profile.company Company.
* @apiParam {String} profile.phone Phone number.
* @apiParam {Date} profile.dob Date of birth(in millis).
*/
.put(function(req, res) {
Admin.findById(req.decoded._id, function(err, admin) {
if (err) {
Expand All @@ -93,7 +122,7 @@ router.route('/profile')
admin.profile.address = req.body.profile.address;
admin.profile.company = req.body.profile.company;
admin.profile.phone = req.body.profile.phone;
admin.profile.updated_at = Date.now();
admin.profile.updated_at = (new Date()).getTime();

admin.save(function(err, admin) {
if (err) {
Expand Down
50 changes: 48 additions & 2 deletions routes/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ var createHash = function(password){
* @apiParam {Date} dob Users date of birth.
* @apiParam {String} pass Users password.
*/

/**
* @api {post} /token/user/signup User Signup
* @apiHeader {String} Content-Type application/json
* @apiVersion 1.0.0
* @apiGroup Authentication
* @apiName UserSignup
* @apiExample Example usage:
* url: http://localhost:3484/token/user/signup
*
* body:
* {
* "name": "John Doe",
* "email": "[email protected]",
* "dob": 1546973225829,
* "pass": "thisIsPassword"
* }
*
* @apiParam {String} name Users name.
* @apiParam {String} email Users email.
* @apiParam {Number} dob Users date of birth(in millis).
* @apiParam {String} pass Users password.
*/
router.route('/user/signup')
.post(function(req, res) {
User.findOne({'email':req.body.email}, function(err, user) {
Expand Down Expand Up @@ -95,7 +118,7 @@ router.route('/user/signup')
/**
* @api {post} /token/user/login User Login
* @apiHeader {String} Content-Type application/json
* @apiVersion 0.1.0
* @apiVersion 1.0.0
* @apiGroup Authentication
* @apiName UserLogin
* @apiExample Example usage:
Expand Down Expand Up @@ -176,6 +199,29 @@ router.route('/user/login')
* @apiParam {Date} dob Admins date of birth.
* @apiParam {String} pass Admins password.
*/

/**
* @api {post} /token/admin/signup Admin Signup
* @apiHeader {String} Content-Type application/json
* @apiVersion 1.0.0
* @apiGroup Authentication
* @apiName AdminSignup
* @apiExample Example usage:
* url: http://localhost:3484/token/admin/signup
*
* body:
* {
* "name": "John Doe",
* "email": "[email protected]",
* "dob": 1546973225829,
* "pass": "thisIsPassword"
* }
*
* @apiParam {String} name Admins name.
* @apiParam {String} email Admins email.
* @apiParam {Number} dob Admins date of birth(in millis).
* @apiParam {String} pass Admins password.
*/
router.route('/admin/signup')
.post(function(req, res) {
Admin.findOne({'email':req.body.email}, function(err, admin) {
Expand Down Expand Up @@ -231,7 +277,7 @@ router.route('/admin/signup')
/**
* @api {post} /token/admin/login Admin Login
* @apiHeader {String} Content-Type application/json
* @apiVersion 0.1.0
* @apiVersion 1.0.0
* @apiGroup Authentication
* @apiName AdminLogin
* @apiExample Example usage:
Expand Down
Loading

0 comments on commit a7437c0

Please sign in to comment.