split to public/private routes
This commit is contained in:
parent
7058a9baa6
commit
056d193d10
25
src/private_api.ts
Normal file
25
src/private_api.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import express from "express";
|
||||
import privateRoutes from "./routes/private_routes";
|
||||
|
||||
class PrivateApi{
|
||||
public server;
|
||||
|
||||
constructor() {
|
||||
this.server = express();
|
||||
|
||||
this.middlewares();
|
||||
this.routes();
|
||||
this.server.set('view engine', 'ejs');
|
||||
this.server.use(express.static('public'));
|
||||
}
|
||||
|
||||
middlewares() {
|
||||
this.server.use(express.json());
|
||||
}
|
||||
|
||||
routes() {
|
||||
this.server.use(privateRoutes);
|
||||
}
|
||||
}
|
||||
|
||||
export default new PrivateApi().server;
|
30
src/public_api.ts
Normal file
30
src/public_api.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import express from "express";
|
||||
|
||||
import routes from "./routes/public_routes";
|
||||
import minecraft_routes from "./routes/public/minecraft/minecraft_routes";
|
||||
|
||||
class PublicApi {
|
||||
public server;
|
||||
|
||||
constructor() {
|
||||
this.server = express();
|
||||
|
||||
this.middlewares();
|
||||
this.routes();
|
||||
this.server.set('view engine', 'ejs');
|
||||
this.server.use(express.static('public'));
|
||||
}
|
||||
|
||||
middlewares() {
|
||||
this.server.use(express.json());
|
||||
}
|
||||
|
||||
routes() {
|
||||
//this.server.use(routes);
|
||||
this.server.use('/minecraft', minecraft_routes)
|
||||
}
|
||||
}
|
||||
|
||||
export default new PublicApi().server;
|
||||
|
||||
|
13
src/routes/private_routes.ts
Normal file
13
src/routes/private_routes.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Router } from "express";
|
||||
|
||||
const privateRoutes = Router();
|
||||
|
||||
privateRoutes.get("/", (req, res) => {
|
||||
var data = {
|
||||
content: 'Hi',
|
||||
title: 'Example'
|
||||
}
|
||||
return res.render('dashboard');
|
||||
});
|
||||
|
||||
export default privateRoutes;
|
17
src/routes/public/minecraft/1_12_2/routes.ts
Normal file
17
src/routes/public/minecraft/1_12_2/routes.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { Router } from "express";
|
||||
import Minecraft from "../../../../minecraft/1.12.2/heliosDistribution"
|
||||
|
||||
const minecraft = new Minecraft //Is this right?
|
||||
const routes = Router();
|
||||
|
||||
routes.get("/", (req, res) => {
|
||||
return res.json({ message: "yes" });
|
||||
});
|
||||
|
||||
routes.get("/distribution", (req, res) =>{
|
||||
res.send(minecraft.generateDistribution())
|
||||
});
|
||||
|
||||
export default routes;
|
||||
|
||||
|
11
src/routes/public/minecraft/minecraft_routes.ts
Normal file
11
src/routes/public/minecraft/minecraft_routes.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Router } from "express";
|
||||
import minecraft_1_12_2_routes from './1_12_2/routes'
|
||||
|
||||
const routes = Router();
|
||||
|
||||
routes.get("/", (req, res) => {
|
||||
return res.json({ message: "Hello World" });
|
||||
});
|
||||
routes.use
|
||||
routes.use('/1.12.2', minecraft_1_12_2_routes)
|
||||
export default routes;
|
9
src/routes/public_routes.ts
Normal file
9
src/routes/public_routes.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Router } from "express";
|
||||
|
||||
const publicRoutes = Router();
|
||||
|
||||
publicRoutes.get("/", (req, res) => {
|
||||
return res.json("work")
|
||||
});
|
||||
|
||||
export default publicRoutes;
|
Loading…
Reference in New Issue
Block a user