-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update route file, Improve test and implement swagger documentation
- Loading branch information
1 parent
ff152f8
commit 7ba3629
Showing
6 changed files
with
238 additions
and
153 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,11 +1,11 @@ | ||
import express from 'express'; | ||
import AuthRoute from './routes/auth/auth.route'; | ||
import authRoute from './routes/auth.route'; | ||
|
||
const app = express(); | ||
|
||
app.use(express.urlencoded({ extended: false })); | ||
app.use(express.json()); | ||
|
||
app.use('/api/auth', AuthRoute); | ||
app.use('/api/auth', authRoute); | ||
|
||
export default app; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import express from 'express'; | ||
import UsersController from '../controllers/user.controller'; | ||
import { signupValidator, sendVerificationLinkValidator } from '../validations/auth.validation'; | ||
import Validations from '../middlewares/route-access.middleware'; | ||
|
||
const router = express.Router(); | ||
|
||
router.post('/signup', signupValidator, UsersController.signUp); | ||
router.patch('/user/verify', Validations.checkRouteAccess, UsersController.verifyAccount); | ||
router.get('/user/resendLink', sendVerificationLinkValidator, UsersController.resendAccVerificationLink); | ||
export default router; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,217 @@ | ||
/** | ||
* @swagger | ||
* definitions: | ||
* Signup: | ||
* type: object | ||
* properties: | ||
* firstName: | ||
* type: string | ||
* lastName: | ||
* type: string | ||
* email: | ||
* type: string | ||
* format: email | ||
* password: | ||
* type: string | ||
* format: password | ||
* required: | ||
* - firstName | ||
* - lastName | ||
* - password | ||
* Login: | ||
* type: object | ||
* properties: | ||
* email: | ||
* type: string | ||
* password: | ||
* type: string | ||
* format: password | ||
* required: | ||
* - password | ||
* Resend Account Verification Link: | ||
* type: object | ||
* properties: | ||
* email: | ||
* type: string | ||
* required: | ||
*/ | ||
|
||
/** | ||
* @swagger | ||
* /api/auth/signup: | ||
* post: | ||
* tags: | ||
* - User | ||
* name: Signup | ||
* summary: Signup a user in a system | ||
* produces: | ||
* - application/json | ||
* consumes: | ||
* - application/json | ||
* parameters: | ||
* - name: body | ||
* in: body | ||
* schema: | ||
* $ref: '#/definitions/Signup' | ||
* type: object | ||
* properties: | ||
* firstName: | ||
* type: string | ||
* lastName: | ||
* type: string | ||
* email: | ||
* type: string | ||
* password: | ||
* type: string | ||
* format: password | ||
* required: | ||
* - firstName | ||
* - lastName | ||
* - password | ||
* responses: | ||
* '201': | ||
* description: User created. | ||
* '400': | ||
* description: Bad request. | ||
* '409': | ||
* description: User already exist. | ||
* | ||
* /api/auth/login: | ||
* post: | ||
* tags: | ||
* - User | ||
* name: Login | ||
* summary: Log a user in a system | ||
* produces: | ||
* - application/json | ||
* consumes: | ||
* - application/json | ||
* parameters: | ||
* - name: body | ||
* in: body | ||
* schema: | ||
* $ref: '#/definitions/Login' | ||
* type: object | ||
* properties: | ||
* email: | ||
* type: string | ||
* password: | ||
* type: string | ||
* format: password | ||
* required: | ||
* - password | ||
* responses: | ||
* '200': | ||
* description: User logged in successfully | ||
* '401': | ||
* description: Incorrect credentials. | ||
*/ | ||
/** | ||
* @swagger | ||
* /api/auth/logout: | ||
* post: | ||
* tags: | ||
* - User | ||
* name: Logout | ||
* summary: Logs out a user from system | ||
* parameters: | ||
* - name: authorization | ||
* in: header | ||
* schema: | ||
* type: string | ||
* produces: | ||
* - application/json | ||
* consumes: | ||
* - application/json | ||
* responses: | ||
* '200': | ||
* description: Succesful | ||
* '401': | ||
* description: No Token supplied | ||
*/ | ||
/** | ||
* @swagger | ||
* /api/auth/protected: | ||
* get: | ||
* tags: | ||
* - User | ||
* name: Protected | ||
* summary: Protected route that can be accessed only by logged in user | ||
* parameters: | ||
* - name: authorization | ||
* in: header | ||
* schema: | ||
* type: string | ||
* produces: | ||
* - application/json | ||
* consumes: | ||
* - application/json | ||
* responses: | ||
* '200': | ||
* description: Succesful | ||
* '401': | ||
* description: No Token supplied | ||
* | ||
*/ | ||
/** | ||
* @swagger | ||
* /api/auth/user/verify: | ||
* patch: | ||
* tags: | ||
* - User | ||
* name: Verify Account | ||
* summary: Verify Newly Created User's Account | ||
* parameters: | ||
* - name: authorization | ||
* in: header | ||
* schema: | ||
* type: string | ||
* produces: | ||
* - application/json | ||
* consumes: | ||
* - application/json | ||
* responses: | ||
* '200': | ||
* description: Account verified successfully. You can proceed to login | ||
* '400': | ||
* description: Bad Request | ||
* '403': | ||
* description: Forbiden | ||
*/ | ||
/** | ||
* @swagger | ||
* /api/auth/user/resendLink: | ||
* get: | ||
* tags: | ||
* - User | ||
* name: Resend Verification Link | ||
* summary: Resend Account Verification Link | ||
* produces: | ||
* - application/json | ||
* consumes: | ||
* - application/json | ||
* parameters: | ||
* - name: body | ||
* in: body | ||
* schema: | ||
* $ref: '#/definitions/Resend Account Verification Link' | ||
* type: object | ||
* properties: | ||
* email: | ||
* type: string | ||
* required: | ||
* responses: | ||
* '200': | ||
* description: Verification Link Successfully Sent, | ||
* Visit Your Email To Activate Account | ||
* '400': | ||
* description: Bad request. | ||
* '404': | ||
* description: Email Not Found in The Database. To Get a Link You Must Register | ||
*/ |
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
Oops, something went wrong.