From 67818d7e80796ae987cba4348acb814726273b48 Mon Sep 17 00:00:00 2001 From: tanmoythander Date: Thu, 8 Feb 2018 12:37:47 +0600 Subject: [PATCH] Added apidoc --- .gitignore | 1 + apidoc.json | 6 ++++ routes/token.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 apidoc.json diff --git a/.gitignore b/.gitignore index 1ca9571..b247721 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ +apidoc/ npm-debug.log diff --git a/apidoc.json b/apidoc.json new file mode 100644 index 0000000..5a60a93 --- /dev/null +++ b/apidoc.json @@ -0,0 +1,6 @@ +{ + "name": "Node REST Server", + "version": "0.0.1", + "description": "REST API documentation for Node REST Server", + "title": "API Documentation - Node REST Server" +} diff --git a/routes/token.js b/routes/token.js index 6a19d93..c82c01c 100644 --- a/routes/token.js +++ b/routes/token.js @@ -18,6 +18,23 @@ var createHash = function(password){ }; +/** + * @api {post} /user/login User Login + * @apiVersion 0.0.1 + * @apiGroup Authentication + * @apiName UserLogin + * @apiExample Example usage: + * url: http://localhost:3484/user/login + * + * body: + * { + * "email": "example@example.com", + * "pass": "thisIsPassword" + * } + * + * @apiParam {String} email Users email. + * @apiParam {String} pass Users password. + */ router.route('/user/login') .post(function(req, res) { User.findOne({ "email" : req.body.email }, function(err, user) { @@ -62,6 +79,27 @@ router.route('/user/login') }); }); +/** + * @api {post} /user/signup User Signup + * @apiVersion 0.0.1 + * @apiGroup Authentication + * @apiName UserSignup + * @apiExample Example usage: + * url: http://localhost:3484/user/signup + * + * body: + * { + * "name": "John Doe", + * "email": "example@example.com", + * "dob": "Thu Dec 16 1971 00:00:00 GMT+0600 (+06)", + * "pass": "thisIsPassword" + * } + * + * @apiParam {String} name Users name. + * @apiParam {String} email Users email. + * @apiParam {Date} dob Users date of birth. + * @apiParam {String} pass Users password. + */ router.route('/user/signup') .post(function(req, res) { User.findOne({ "email": req.body.email }, function(err, user) { @@ -114,6 +152,23 @@ router.route('/user/signup') }); }); +/** + * @api {post} /admin/login Admin Login + * @apiVersion 0.0.1 + * @apiGroup Authentication + * @apiName AdminLogin + * @apiExample Example usage: + * url: http://localhost:3484/admin/login + * + * body: + * { + * "email": "example@example.com", + * "pass": "thisIsPassword" + * } + * + * @apiParam {String} email Admins email. + * @apiParam {String} pass Admins password. + */ router.route('/admin/login') .post(function(req, res) { Admin.findOne({ "email" : req.body.email }, function(err, admin) { @@ -158,6 +213,27 @@ router.route('/admin/login') }); }); +/** + * @api {post} /admin/signup Admin Signup + * @apiVersion 0.0.1 + * @apiGroup Authentication + * @apiName AdminSignup + * @apiExample Example usage: + * url: http://localhost:3484/admin/signup + * + * body: + * { + * "name": "John Doe", + * "email": "example@example.com", + * "dob": "Thu Dec 16 1971 00:00:00 GMT+0600 (+06)", + * "pass": "thisIsPassword" + * } + * + * @apiParam {String} name Admins name. + * @apiParam {String} email Admins email. + * @apiParam {Date} dob Admins date of birth. + * @apiParam {String} pass Admins password. + */ router.route('/admin/signup') .post(function(req, res) { Admin.findOne({ "email": req.body.email }, function(err, admin) {