Skip to content

Commit

Permalink
shop and admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
NebraskyTheWolf committed Jan 27, 2024
1 parent 5ba861b commit 11a0d5d
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 19 deletions.
38 changes: 38 additions & 0 deletions src/api/Server/AbstractWebRoutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* AbstractRoutes.ts :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alle.roy <alle.roy.student@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/29 15:35:24 by alle.roy #+# #+# */
/* Updated: 2023/02/11 04:19:41 by alle.roy ### ########.fr */
/* */
/* ************************************************************************** */

import Base from "../../abstracts/Base";
import { Router, Response } from "express";
import express from "express";

import CacheManager from "../../cache/CacheManager";
import Authentication from "./middlewares/Authentication";

export default abstract class AbstractWebRoutes extends Base {
protected router: Router
public isProtected: boolean;
public prefix: string

public constructor() {
super("routes", "", "SERVER")
this.router = router;

this.register(); // SELF REGISTERING.
}

public abstract register(): void
public routing(): Router {
return router;
}
}

export const router = express.Router()
3 changes: 2 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export default class ServerManager {
app.use('/api', route.routing())
}
})
this.server.listen(3443)

this.server.listen(3443)
this.gateway.listen(8443)
this.website.initServer()
}
Expand Down
2 changes: 0 additions & 2 deletions src/api/website/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ export interface CustomResponse extends Response {
}

export default class WebsiteServer {
private routes: Tuple<AbstractRoutes>
private server: http.Server
private passport: Passport

public constructor() {
this.routes = new Tuple<AbstractRoutes>()
this.passport = new Passport()

app.set('trust proxy', 1) // trust first proxy
Expand Down
5 changes: 2 additions & 3 deletions src/api/website/routes/Admin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import AbstractRoutes from '../../Server/AbstractRoutes'
import { Request } from "express"
import { IUser } from '../passport'
import CAdminAuthentication from '../middleware/CAdminAuthentication'
import AbstractWebRoutes from '../../Server/AbstractWebRoutes'

export default class Admin extends AbstractRoutes {
export default class Admin extends AbstractWebRoutes {
async register () {
this.router.get('/', new CAdminAuthentication().handle, function (req: Request, res) {

Expand Down
4 changes: 2 additions & 2 deletions src/api/website/routes/Auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AbstractRoutes from '../../Server/AbstractRoutes'
import passport from 'passport'
import AbstractWebRoutes from '../../Server/AbstractWebRoutes'

export default class Auth extends AbstractRoutes {
export default class Auth extends AbstractWebRoutes {
async register () {

this.prefix = 'auth'
Expand Down
5 changes: 2 additions & 3 deletions src/api/website/routes/Dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import AbstractRoutes from '../../Server/AbstractRoutes'
import { Request } from "express"
import { IUser } from '../passport'
import pug from "pug"
import Guild from '@riniya.ts/database/Guild/Guild'
import { isNull } from '@riniya.ts/types'
import Riniya from '@riniya.ts'
import CAuthMiddleware from '../middleware/CAuthMiddleware'
import AbstractWebRoutes from '../../Server/AbstractWebRoutes'

export default class Dashboard extends AbstractRoutes {
export default class Dashboard extends AbstractWebRoutes {
async register () {
this.isProtected = true;

Expand Down
4 changes: 2 additions & 2 deletions src/api/website/routes/Profile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AbstractRoutes from '../../Server/AbstractRoutes'
import AbstractWebRoutes from '../../Server/AbstractWebRoutes'

export default class Profile extends AbstractRoutes {
export default class Profile extends AbstractWebRoutes {
async register () {
this.prefix = 'profile'
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/website/routes/Server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AbstractRoutes from '../../Server/AbstractRoutes'
import AbstractWebRoutes from '../../Server/AbstractWebRoutes'

export default class Server extends AbstractRoutes {
export default class Server extends AbstractWebRoutes {
async register () {
this.prefix = 'servers'
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/website/routes/Shop.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import AbstractRoutes from '../../Server/AbstractRoutes'
import { Request } from "express"
import { IUser } from '../passport'
import CAuthMiddleware from '../middleware/CAuthMiddleware'
import AbstractWebRoutes from '../../Server/AbstractWebRoutes'

export default class Shop extends AbstractRoutes {
export default class Shop extends AbstractWebRoutes {
async register () {
this.prefix = 'shop'

Expand Down
4 changes: 2 additions & 2 deletions src/api/website/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import AbstractRoutes from '../../Server/AbstractRoutes'
import { CustomRequest } from '../index'
import { isNull } from '@riniya.ts/types'
import AbstractWebRoutes from '../../Server/AbstractWebRoutes'

export default class Index extends AbstractRoutes {
export default class Index extends AbstractWebRoutes {
async register () {
this.router.get('/', function (req, res) {

Expand Down

0 comments on commit 11a0d5d

Please sign in to comment.