Compare commits
No commits in common. "fcf444bb8199b46fc50b031e65d2726c22c4c4fa" and "b1bc2b10f614e2560e7bc6d8e48373960fbebbb2" have entirely different histories.
fcf444bb81
...
b1bc2b10f6
9
.gitignore
vendored
9
.gitignore
vendored
@ -103,6 +103,7 @@ dist
|
|||||||
|
|
||||||
# vuepress v2.x temp and cache directory
|
# vuepress v2.x temp and cache directory
|
||||||
.temp
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
# Docusaurus cache and generated files
|
# Docusaurus cache and generated files
|
||||||
.docusaurus
|
.docusaurus
|
||||||
@ -129,11 +130,3 @@ dist
|
|||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
# idea
|
|
||||||
.idea/workspace.xml
|
|
||||||
.idea/vcs.xml
|
|
||||||
.idea/SkirdaNodeBackend.iml
|
|
||||||
.idea/modules.xml
|
|
||||||
|
|
||||||
# vs code
|
|
||||||
/.vscode/launch.json
|
|
||||||
|
5
.idea/.gitignore
generated
vendored
5
.idea/.gitignore
generated
vendored
@ -1,5 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
@ -1,6 +1,6 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import games_routes from "./routes/public/games/games.route"
|
import routes from "./routes/routes";
|
||||||
import minecraft_routes from "./routes/public/games/minecraft/minecraft_routes";
|
import minecraft_routes from "./routes/public/minecraft/minecraft_routes";
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
public server;
|
public server;
|
||||||
@ -17,7 +17,7 @@ class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
routes() {
|
routes() {
|
||||||
this.server.use('/games', games_routes);
|
this.server.use(routes);
|
||||||
this.server.use('/minecraft', minecraft_routes)
|
this.server.use('/minecraft', minecraft_routes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
import Game, { IGame, GameStatus, IPlatforms } from "../objects/game.object"
|
|
||||||
import { Schema, model, connect, Model } from 'mongoose';
|
|
||||||
|
|
||||||
export default class Games {
|
|
||||||
public async getGames() {
|
|
||||||
connect('mongodb://172.17.0.2:27017/game');
|
|
||||||
let games = await Game.find()
|
|
||||||
let games_list: IGame[] = []
|
|
||||||
games.forEach(game => {
|
|
||||||
games_list.push(game.toObject())
|
|
||||||
})
|
|
||||||
|
|
||||||
return games_list
|
|
||||||
}
|
|
||||||
|
|
||||||
public async writeNewGame(game_id:string, game_name:string, game_icon_url:string, game_backgrounds:string[], game_status:GameStatus, game_platforms:IPlatforms) {
|
|
||||||
await connect('mongodb://172.17.0.2:27017/game');
|
|
||||||
const newGame = new Game({
|
|
||||||
id: game_id,
|
|
||||||
name: game_name,
|
|
||||||
icon: game_icon_url,
|
|
||||||
backgrounds: game_backgrounds,
|
|
||||||
status: game_status,
|
|
||||||
platforms: game_platforms
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(newGame)
|
|
||||||
await newGame.save()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +1,38 @@
|
|||||||
import { IHeliosDistribution, IMinecraftServer } from "./helios_distribution"
|
import {IHeliosDistribution, IMinecraftServer} from "./helios_distribution"
|
||||||
import mongoose, { Schema, model, connect, Model } from 'mongoose';
|
import { Schema, model, connect, Model } from 'mongoose';
|
||||||
import MinecraftServer from "./models";
|
|
||||||
|
|
||||||
export default class Minecraft {
|
const SolFileSchema = new Schema({
|
||||||
public async getServers() {
|
id:{ type: String, required: true }
|
||||||
connect('mongodb://172.17.0.2:27017/minecraft');
|
})
|
||||||
let servers = await MinecraftServer.find()
|
|
||||||
let servers_list: IMinecraftServer[] = []
|
const minecraftServerSchema = new Schema({
|
||||||
servers.forEach(element => {
|
id: { type: String, required: true },
|
||||||
servers_list.push(element.toObject())
|
name: { type: String, required: true },
|
||||||
|
description: { type: String, required: true },
|
||||||
|
icon: { type: String, required: true },
|
||||||
|
minecraftVersion: { type: String, required: true },
|
||||||
|
address: { type: String, required: true },
|
||||||
|
share_required_mods:[ SolFileSchema ]
|
||||||
});
|
});
|
||||||
|
|
||||||
return servers_list
|
const MinecraftServer = model('Server', minecraftServerSchema)
|
||||||
|
|
||||||
|
export default class Minecraft{
|
||||||
|
constructor(){
|
||||||
|
this.getDistribution = this.getDistribution.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async writeServer() {
|
public async getDistribution(){
|
||||||
|
var servers_string = {id:"asd"}
|
||||||
|
await connect('mongodb://172.17.0.2:27017/minecraft');
|
||||||
|
|
||||||
|
var servers = await MinecraftServer.find()
|
||||||
|
console.log(servers)
|
||||||
|
servers_string = servers[0].toObject()
|
||||||
|
return servers_string
|
||||||
|
}
|
||||||
|
|
||||||
|
public async writeServer(){
|
||||||
await connect('mongodb://172.17.0.2:27017/minecraft');
|
await connect('mongodb://172.17.0.2:27017/minecraft');
|
||||||
const newSrv = new MinecraftServer({
|
const newSrv = new MinecraftServer({
|
||||||
id: 'kek',
|
id: 'kek',
|
||||||
@ -26,5 +44,11 @@ export default class Minecraft {
|
|||||||
})
|
})
|
||||||
await newSrv.save()
|
await newSrv.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getServers(): Promise<IMinecraftServer[]>{
|
||||||
|
var servers:IMinecraftServer[] = []
|
||||||
|
await connect('mongodb://172.17.0.2:27017/minecraft');
|
||||||
|
return servers
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
import { Document, Schema, model } from "mongoose"
|
|
||||||
|
|
||||||
export interface IMinecraftServer extends Document {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
description: string
|
|
||||||
icon: string
|
|
||||||
minecraftVersion: string
|
|
||||||
address: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MinecraftServerSchema = new Schema({
|
|
||||||
id: { type: String, required: true },
|
|
||||||
name: { type: String, required: true },
|
|
||||||
description: { type: String, required: true },
|
|
||||||
icon: { type: String, required: true },
|
|
||||||
minecraftVersion: { type: String, required: true },
|
|
||||||
address: { type: String, required: true }
|
|
||||||
})
|
|
||||||
|
|
||||||
MinecraftServerSchema.set('toObject', { // Delete mongoDB document fields
|
|
||||||
virtuals: true,
|
|
||||||
transform: function (doc, ret) {
|
|
||||||
delete ret._id;
|
|
||||||
delete ret.__v;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const SolFileSchema = new Schema({
|
|
||||||
id: { type: String, required: true }
|
|
||||||
})
|
|
||||||
|
|
||||||
const MinecraftServer = model<IMinecraftServer>('server', MinecraftServerSchema)
|
|
||||||
export default MinecraftServer;
|
|
@ -1,40 +0,0 @@
|
|||||||
import { Document, Schema, model } from "mongoose"
|
|
||||||
|
|
||||||
export enum GameStatus {
|
|
||||||
"active",
|
|
||||||
"inactive",
|
|
||||||
"pending"
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPlatforms {
|
|
||||||
windows: boolean
|
|
||||||
linux: boolean,
|
|
||||||
macOS: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export const platformsSchema = new Schema({
|
|
||||||
windows: { type: Schema.Types.Boolean, required: true, default: false },
|
|
||||||
linux: { type: Schema.Types.Boolean, required: true, default: false },
|
|
||||||
macOS: { type: Schema.Types.Boolean, required: true, default: false }
|
|
||||||
})
|
|
||||||
|
|
||||||
export interface IGame extends Document {
|
|
||||||
id: string,
|
|
||||||
name: string,
|
|
||||||
icon: URL,
|
|
||||||
backgrounds: string[],
|
|
||||||
status: GameStatus
|
|
||||||
platforms: IPlatforms
|
|
||||||
}
|
|
||||||
|
|
||||||
export const GameSchema = new Schema({
|
|
||||||
id: { type: String, required: true },
|
|
||||||
name: { type: String, required: true },
|
|
||||||
icon: { type: String, URL, required: true },
|
|
||||||
backgrounds: [{ type: String, required: true }],
|
|
||||||
status: { type: String, enum: Object.values(GameStatus), default: GameStatus.inactive, required: true },
|
|
||||||
platforms: platformsSchema
|
|
||||||
})
|
|
||||||
|
|
||||||
const Game = model<IGame>('game', GameSchema)
|
|
||||||
export default Game;
|
|
@ -1,5 +1,7 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
|
|
||||||
import routes from "./routes/public_routes";
|
import routes from "./routes/public_routes";
|
||||||
|
import minecraft_routes from "./routes/public/minecraft/minecraft_routes";
|
||||||
|
|
||||||
class PublicApi {
|
class PublicApi {
|
||||||
public server;
|
public server;
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
import { Router } from "express";
|
|
||||||
import { GameStatus, IPlatforms } from "../../../objects/game.object"
|
|
||||||
import Games from "../../../modules/game.module";
|
|
||||||
|
|
||||||
const games = new Games
|
|
||||||
const routes = Router();
|
|
||||||
|
|
||||||
routes.get("/", async (req, res) => {
|
|
||||||
|
|
||||||
let games_list = await games.getGames()
|
|
||||||
await res.json(games_list);
|
|
||||||
});
|
|
||||||
|
|
||||||
routes.get("/writeServer", async (req, res) => {
|
|
||||||
let game_id: string = 'test'
|
|
||||||
let game_name: string = 'Test'
|
|
||||||
let game_icon_url: string = 'http://1.jpg'
|
|
||||||
let game_backgrounds: string[] = ['http://bg1.jpg', 'http://bg2.jpg']
|
|
||||||
let game_status: GameStatus = GameStatus.active
|
|
||||||
let game_platforms: IPlatforms = { windows: true, linux: false, macOS: false }
|
|
||||||
await games.writeNewGame(game_id, game_name, game_icon_url, game_backgrounds, game_status, game_platforms)
|
|
||||||
await res.send("end")
|
|
||||||
});
|
|
||||||
|
|
||||||
routes.use
|
|
||||||
export default routes;
|
|
@ -1,21 +0,0 @@
|
|||||||
import { Router } from "express";
|
|
||||||
import Minecraft from "../../../../../modules/minecraft/1.12.2/minecraft_distribution"
|
|
||||||
|
|
||||||
const minecraft = new Minecraft //Is this right?
|
|
||||||
const routes = Router();
|
|
||||||
|
|
||||||
routes.get("/", (req, res) => {
|
|
||||||
return res.json({ message: "yes" });
|
|
||||||
});
|
|
||||||
|
|
||||||
routes.get("/distribution", async (req, res) =>{
|
|
||||||
let servers = await minecraft.getServers()
|
|
||||||
//console.log(kek)
|
|
||||||
res.send(servers)
|
|
||||||
});
|
|
||||||
|
|
||||||
routes.get("/writeServer", (req, res) =>{
|
|
||||||
res.send(minecraft.writeServer())
|
|
||||||
});
|
|
||||||
|
|
||||||
export default routes;
|
|
25
src/routes/public/minecraft/1_12_2/routes.ts
Normal file
25
src/routes/public/minecraft/1_12_2/routes.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import Minecraft from "../../../../modules/minecraft/1.12.2/minecraft_distribution"
|
||||||
|
|
||||||
|
import GetMinecraftServers from "../../../../modules/mongoose/db_connect"
|
||||||
|
|
||||||
|
const minecraft = new Minecraft //Is this right?
|
||||||
|
const routes = Router();
|
||||||
|
const test_db = new GetMinecraftServers
|
||||||
|
routes.get("/", (req, res) => {
|
||||||
|
return res.json({ message: "yes" });
|
||||||
|
});
|
||||||
|
|
||||||
|
routes.get("/distribution", (req, res) =>{
|
||||||
|
res.send(minecraft.getDistribution())
|
||||||
|
});
|
||||||
|
|
||||||
|
routes.get("/writeServer", (req, res) =>{
|
||||||
|
res.send(minecraft.writeServer())
|
||||||
|
});
|
||||||
|
|
||||||
|
routes.get("/test", (req, res) =>{
|
||||||
|
res.send(test_db.writeTestModel())
|
||||||
|
});
|
||||||
|
|
||||||
|
export default routes;
|
9
src/routes/routes.ts
Normal file
9
src/routes/routes.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
|
||||||
|
const routes = Router();
|
||||||
|
|
||||||
|
routes.get("/", (req, res) => {
|
||||||
|
return res.json({ message: "Hello World" });
|
||||||
|
});
|
||||||
|
|
||||||
|
export default routes;
|
Loading…
Reference in New Issue
Block a user