Skip to content

Commit

Permalink
Refactor routes imports to use default
Browse files Browse the repository at this point in the history
  • Loading branch information
Vylpes committed Feb 16, 2024
1 parent 3174d62 commit c741b4a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import connectFlash from "connect-flash";
import { PugMiddleware } from "./middleware/pugMiddleware";
import AppDataSource from "./database/dataSources/appDataSource";

import { AuthRouter } from "./routes/auth";
import { DashboardRouter } from "./routes/dashboard";
import { IndexRouter } from "./routes/index";
import AuthRouter from "./routes/auth";
import DashboardRouter from "./routes/dashboard";
import IndexRouter from "./routes/index";
import SettingsRouter from "./routes/settings";
import ItemsRouter from "./routes/items";
import ItemPurchasesRouter from "./routes/itemPurchases";
Expand Down
6 changes: 3 additions & 3 deletions src/routes/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Route } from "../../contracts/Route";
import AdminRegister from "./adminRegister";
import { Login } from "./login";
import { Logout } from "./logout";
import Login from "./login";
import Logout from "./logout";
import PasswordResetRouter from "./passwordReset";
import verificationTokenRouter from "./verificationToken";
import Verify from "./verify";

export class AuthRouter extends Route {
export default class AuthRouter extends Route {
constructor() {
super();

Expand Down
6 changes: 2 additions & 4 deletions src/routes/auth/login.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Router, Request, Response, NextFunction } from "express";
import { Request, Response, NextFunction } from "express";
import Page from "../../contracts/Page";
import { User } from "../../database/entities/User";
import BodyValidator from "../../helpers/Validation/BodyValidator";
import { sys } from "typescript";
import { threadId } from "worker_threads";
import MessageHelper from "../../helpers/MessageHelper";

export class Login implements Page {
export default class Login implements Page {
OnGet(req: Request, res: Response, next: NextFunction) {
if (res.locals.viewData.isAuthenticated) {
res.redirect('/dashboard');
Expand Down
2 changes: 1 addition & 1 deletion src/routes/auth/logout.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router, Request, Response, NextFunction } from "express";
import Page from "../../contracts/Page";

export class Logout implements Page {
export default class Logout implements Page {
OnGet(req: Request, res: Response, next: NextFunction) {
req.session.destroy(() => {
res.redirect('/');
Expand Down
4 changes: 2 additions & 2 deletions src/routes/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Route } from "../../contracts/Route";
import Calculator from "./calculator";
import { Index } from "./indexPage";
import Index from "./indexPage";

export class DashboardRouter extends Route {
export default class DashboardRouter extends Route {
constructor() {
super(true);

Expand Down
2 changes: 1 addition & 1 deletion src/routes/dashboard/indexPage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from "express";
import Page from "../../contracts/Page";

export class Index implements Page {
export default class Index implements Page {
OnGet(req: Request, res: Response) {
res.render('dashboard/index', res.locals.viewData);
}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/index/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Route } from "../../contracts/Route";
import { Index } from "./indexPage";
import Index from "./indexPage";

export class IndexRouter extends Route {
export default class IndexRouter extends Route {
constructor() {
super();

Expand Down
4 changes: 2 additions & 2 deletions src/routes/index/indexPage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router, Request, Response } from "express";
import { Request, Response } from "express";
import Page from "../../contracts/Page";

export class Index implements Page {
export default class Index implements Page {
OnGet(req: Request, res: Response) {
if (res.locals.viewData.isAuthenticated) {
res.redirect('/dashboard');
Expand Down

0 comments on commit c741b4a

Please sign in to comment.