Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @description Default Imports
- */
- import { Request, Response, NextFunction } from 'express';
- import chalk from 'chalk';
- import * as passport from 'passport';
- /**
- * @description Controller Imports
- */
- import { AuthenticationController } from '../controllers/controller';
- export class Routes {
- public authenticationController: AuthenticationController = new AuthenticationController();
- public routes(app: any): void {
- try {
- app.route('/').get((req: Request, res: Response) => {
- try {
- console.log(chalk.cyanBright('Request from: ') + chalk.yellowBright(req.originalUrl));
- console.log(chalk.cyanBright('Request type: ') + chalk.yellowBright(req.method));
- res.status(200).send({ statusCode: 200, message: 'What reason do you have for wanting to access the root route ?-_-?' });
- } catch (error) {
- console.error(chalk.redBright(error));
- }
- });
- app.route('/authenticate').post((req: Request, res: Response, next: NextFunction) => {
- try {
- console.log(chalk.cyanBright('Request from: ') + chalk.yellowBright(req.originalUrl));
- console.log(chalk.cyanBright('Request type: ') + chalk.yellowBright(req.method));
- next();
- } catch (error) {
- console.error(chalk.redBright(error));
- }
- }, this.authenticationController.authenticate);
- } catch (error) {
- console.error(chalk.redBright(error));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment