From af2ad72c0071d1206d9d9ab9e8e6782dc8d59d76 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Fri, 19 Aug 2022 04:53:17 +0300 Subject: [PATCH] Start create helios distribution api --- src/app.ts | 26 ++++++++++ src/minecraft/1.12.2/heliosDistribution.ts | 55 ++++++++++++++++++++++ src/routes/minecraft/1_12_2/routes.ts | 17 +++++++ src/routes/minecraft/minecraft_routes.ts | 11 +++++ src/routes/routes.ts | 9 ++++ src/server.ts | 3 ++ 6 files changed, 121 insertions(+) create mode 100644 src/app.ts create mode 100644 src/minecraft/1.12.2/heliosDistribution.ts create mode 100644 src/routes/minecraft/1_12_2/routes.ts create mode 100644 src/routes/minecraft/minecraft_routes.ts create mode 100644 src/routes/routes.ts create mode 100644 src/server.ts diff --git a/src/app.ts b/src/app.ts new file mode 100644 index 0000000..7dd4964 --- /dev/null +++ b/src/app.ts @@ -0,0 +1,26 @@ +import express from "express"; + +import routes from "./routes/routes"; +import minecraft_routes from "./routes/minecraft/minecraft_routes"; + +class App { + public server; + + constructor() { + this.server = express(); + + this.middlewares(); + this.routes(); + } + + middlewares() { + this.server.use(express.json()); + } + + routes() { + this.server.use(routes); + this.server.use('/minecraft', minecraft_routes) + } +} + +export default new App().server; diff --git a/src/minecraft/1.12.2/heliosDistribution.ts b/src/minecraft/1.12.2/heliosDistribution.ts new file mode 100644 index 0000000..71c61b8 --- /dev/null +++ b/src/minecraft/1.12.2/heliosDistribution.ts @@ -0,0 +1,55 @@ +import internal from "stream" +import { Url } from "url" + +interface HeliosDistribution{ + version:string + //servers:Minecraft_1_12_2_server +} + +interface MinecraftServer{ + id:string + name:string + description:string + icon:string + version:string + address:string + minecraftVersion:string + mainServer:boolean + autoconnect:boolean + share_required_mods:ForgeMod[] + client_required_mods:ForgeMod[] + client_optional_mods:ForgeMod[] +} + +interface ForgeMod{ + id:ForgeModId + name:string + type:string + artifact:ForgeModArtifact + sub_modules:ForgeMod[] +} + +interface ForgeModId{ + class:string + label:string + version:string +} + +interface ForgeModArtifact{ + size:number + MD5:string + url:Url +} + +export default class Minecraft{ + constructor(){ + this.generateDistribution = this.generateDistribution.bind(this) + } + + public generateDistribution() { + var distribution: HeliosDistribution = { + version: "12.254" + } + return distribution + } +} \ No newline at end of file diff --git a/src/routes/minecraft/1_12_2/routes.ts b/src/routes/minecraft/1_12_2/routes.ts new file mode 100644 index 0000000..0f42923 --- /dev/null +++ b/src/routes/minecraft/1_12_2/routes.ts @@ -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; + + diff --git a/src/routes/minecraft/minecraft_routes.ts b/src/routes/minecraft/minecraft_routes.ts new file mode 100644 index 0000000..dd5cf46 --- /dev/null +++ b/src/routes/minecraft/minecraft_routes.ts @@ -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; diff --git a/src/routes/routes.ts b/src/routes/routes.ts new file mode 100644 index 0000000..2c8150c --- /dev/null +++ b/src/routes/routes.ts @@ -0,0 +1,9 @@ +import { Router } from "express"; + +const routes = Router(); + +routes.get("/", (req, res) => { + return res.json({ message: "Hello World" }); +}); + +export default routes; \ No newline at end of file diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..28736e3 --- /dev/null +++ b/src/server.ts @@ -0,0 +1,3 @@ +import app from "./app"; + +app.listen(3000);