Guest User

Untitled

a guest
Jul 4th, 2018
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *  @description Default Imports
  3.  */
  4.  
  5. import { Request, Response, NextFunction } from 'express';
  6. import chalk from 'chalk';
  7. import * as passport from 'passport';
  8.  
  9. /**
  10.  *  @description Controller Imports
  11.  */
  12.  
  13. import { AuthenticationController } from '../controllers/controller';
  14.  
  15. export class Routes {
  16.     public authenticationController: AuthenticationController = new AuthenticationController();
  17.  
  18.     public routes(app: any): void {
  19.         try {
  20.             app.route('/').get((req: Request, res: Response) => {
  21.                 try {
  22.                     console.log(chalk.cyanBright('Request from: ') + chalk.yellowBright(req.originalUrl));
  23.                     console.log(chalk.cyanBright('Request type: ') + chalk.yellowBright(req.method));
  24.  
  25.                     res.status(200).send({ statusCode: 200, message: 'What reason do you have for wanting to access the root route ?-_-?' });
  26.                 } catch (error) {
  27.                     console.error(chalk.redBright(error));
  28.                 }
  29.             });
  30.  
  31.             app.route('/authenticate').post((req: Request, res: Response, next: NextFunction) => {
  32.                 try {
  33.                     console.log(chalk.cyanBright('Request from: ') + chalk.yellowBright(req.originalUrl));
  34.                     console.log(chalk.cyanBright('Request type: ') + chalk.yellowBright(req.method));
  35.  
  36.                     next();
  37.                 } catch (error) {
  38.                     console.error(chalk.redBright(error));
  39.                 }
  40.             }, this.authenticationController.authenticate);
  41.         } catch (error) {
  42.             console.error(chalk.redBright(error));
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment