-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Louis Cheung
committed
Jun 5, 2015
1 parent
e65e356
commit fff57be
Showing
1 changed file
with
32 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,49 @@ | ||
|
||
/** | ||
* @swagger | ||
* resourcePath: /apiJs | ||
* description: All about API | ||
*/ | ||
|
||
/** | ||
* @swagger | ||
* path: /login | ||
* operations: | ||
* - httpMethod: POST | ||
* summary: Login with username and password | ||
* notes: Returns a user based on username | ||
* responseClass: User | ||
* nickname: login | ||
* consumes: | ||
* - text/html | ||
* parameters: | ||
* - name: username | ||
* description: Your username | ||
* paramType: query | ||
* required: true | ||
* dataType: string | ||
* - name: password | ||
* description: Your password | ||
* paramType: query | ||
* required: true | ||
* dataType: string | ||
*/ | ||
exports.login = function (req, res) { | ||
var user = {}; | ||
user.username = req.param('username'); | ||
user.password = req.param('password'); | ||
res.json(user); | ||
} | ||
|
||
/** | ||
* @swagger | ||
* models: | ||
* User: | ||
* id: User | ||
* properties: | ||
* username: | ||
* type: String | ||
* password: | ||
* type: String | ||
*/ | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Sets up the routes. | ||
* @param {object} app - Express app | ||
*/ | ||
module.exports.setup = function (app) { | ||
|
||
/** | ||
* @swagger | ||
*/ | ||
app.get('/', rootHandler) | ||
|
||
/** | ||
* @swagger | ||
* path: /login | ||
* operations: | ||
* - httpMethod: POST | ||
* summary: Login with username and password | ||
* notes: Returns a user based on username | ||
* responseClass: User | ||
* nickname: login | ||
* consumes: | ||
* - text/html | ||
* parameters: | ||
* - name: username | ||
* description: Your username | ||
* paramType: query | ||
* required: true | ||
* dataType: string | ||
* - name: password | ||
* description: Your password | ||
* paramType: query | ||
* required: true | ||
* dataType: string | ||
*/ | ||
app.get('/login', loginHandler); | ||
} | ||
|
||
/** | ||
* @swagger | ||
* | ||
*/ | ||
function rootHandler(req, res) { | ||
res.send('Hello World!'); | ||
}); | ||
|
||
/** | ||
* @swagger | ||
* | ||
*/ | ||
function loginHandler(req, res) { | ||
res.send('login'); | ||
var user = {}; | ||
user.username = req.param('username'); | ||
user.password = req.param('password'); | ||
res.json(user); | ||
} |