Реализовать загрузку 3D-моделей в Scene manager и выгрузку файлов для запуска симуляции
This commit is contained in:
parent
11ca9cdb5e
commit
3fefd60b72
109 changed files with 2726 additions and 1190 deletions
|
@ -1,11 +1,11 @@
|
|||
import express from "express";
|
||||
import { Routes } from "../interfaces/router";
|
||||
import cors from "cors";
|
||||
import fileUpload from "express-fileupload";
|
||||
import { Routes } from "../interfaces/router";
|
||||
import { Server } from "socket.io";
|
||||
import { createServer } from "http";
|
||||
import { SocketSubscriber } from "./socket_controller";
|
||||
import { dirname } from "path";
|
||||
import fileUpload from "express-fileupload";
|
||||
import { SetLastActivePipelineToRealTimeServiceScenario } from "../scenarios/set_active_pipeline_to_realtime_service_scenario";
|
||||
import { CheckAndCreateStaticFilesFolderUseCase } from "../usecases/check_and_create_static_files_folder_usecase";
|
||||
import { DataBaseConnectUseCase } from "../usecases/database_connect_usecase";
|
||||
|
@ -13,7 +13,7 @@ import { TypedEvent } from "../helpers/typed_event";
|
|||
|
||||
export enum ServerStatus {
|
||||
init = "init",
|
||||
finished = "finshed",
|
||||
finished = "finished",
|
||||
error = "error",
|
||||
}
|
||||
export enum Environment {
|
||||
|
@ -85,7 +85,7 @@ export class App extends TypedEvent<ServerStatus> {
|
|||
this.app.use(cors());
|
||||
this.app.use(express.json());
|
||||
this.app.use(express.urlencoded({ extended: true }));
|
||||
this.app.use(express.static("public"));
|
||||
this.app.use(express.static(App.staticFilesStoreDir()));
|
||||
|
||||
this.app.use(
|
||||
fileUpload({
|
||||
|
@ -118,6 +118,7 @@ export class App extends TypedEvent<ServerStatus> {
|
|||
static staticFilesStoreDir = () => {
|
||||
const dir = dirname(__filename);
|
||||
const rootDir = dir.slice(0, dir.length - 20);
|
||||
|
||||
return rootDir + "public/";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,20 +2,20 @@ import { validationModelMiddleware } from "../middlewares/validation_model";
|
|||
import { Result } from "../helpers/result";
|
||||
import { Router, Request, Response } from "express";
|
||||
import { IRouteModel, Routes } from "../interfaces/router";
|
||||
import { CoreValidation } from "../validations/core_validation";
|
||||
|
||||
export type HttpMethodType = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "PATCH" | "HEAD";
|
||||
|
||||
export type ResponseBase = Promise<Result<any, any>>;
|
||||
|
||||
export abstract class CallbackStrategyWithEmpty {
|
||||
abstract call(): ResponseBase;
|
||||
}
|
||||
export abstract class CallbackStrategyWithValidationModel<V> {
|
||||
abstract validationModel: V;
|
||||
abstract call(a: V): ResponseBase;
|
||||
abstract call(model: V): ResponseBase;
|
||||
}
|
||||
export abstract class CallbackStrategyWithIdQuery {
|
||||
abstract idValidationExpression: RegExp | null;
|
||||
abstract idValidationExpression: CoreValidation;
|
||||
abstract call(id: string): ResponseBase;
|
||||
}
|
||||
export abstract class CallBackStrategyWithQueryPage {
|
||||
|
@ -25,7 +25,8 @@ export abstract class CallBackStrategyWithQueryPage {
|
|||
|
||||
export abstract class CallbackStrategyWithFileUpload {
|
||||
abstract checkingFileExpression: RegExp;
|
||||
abstract call(file: File): ResponseBase;
|
||||
abstract idValidationExpression: CoreValidation;
|
||||
abstract call(file: File, id: string, description: string): ResponseBase;
|
||||
}
|
||||
|
||||
interface ISubSetFeatureRouter<T> {
|
||||
|
@ -84,7 +85,24 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
|||
throw Error("needs to be implimed");
|
||||
}
|
||||
if (el.fn instanceof CallbackStrategyWithIdQuery) {
|
||||
throw Error("needs to be implimed");
|
||||
if (req.query.id === undefined) {
|
||||
res.status(400).json("request query id is null, need query id ?id={id:String}");
|
||||
return;
|
||||
}
|
||||
if (el.fn.idValidationExpression !== undefined) {
|
||||
if (!el.fn.idValidationExpression.regExp.test(req.query.id)) {
|
||||
res
|
||||
.status(400)
|
||||
.json(
|
||||
`request query id must fall under the pattern: ${el.fn.idValidationExpression.regExp} message: ${el.fn.idValidationExpression.message} `
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
await this.responseHelper(res, el.fn.call(req.query.id));
|
||||
}
|
||||
} else {
|
||||
await this.responseHelper(res, el.fn.call(req["files"]["file"]));
|
||||
}
|
||||
}
|
||||
if (el.fn instanceof CallBackStrategyWithQueryPage) {
|
||||
throw Error("needs to be implimed");
|
||||
|
@ -99,17 +117,32 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
|||
res.status(400).json("need files to form-data request");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req["files"]["file"] === undefined) {
|
||||
res.status(400).json("need file to form data request");
|
||||
return;
|
||||
}
|
||||
if (req.query.description === undefined) {
|
||||
res
|
||||
.status(400)
|
||||
.json("request query description is null, need query description &description={description:String}");
|
||||
return;
|
||||
}
|
||||
if (req.query.id === undefined) {
|
||||
res.status(400).json("request query id is null, need query id ?id={id:String}");
|
||||
return;
|
||||
}
|
||||
if (!el.fn.idValidationExpression.regExp.test(req.query.id)) {
|
||||
res.status(400).json(el.fn.idValidationExpression.message);
|
||||
return;
|
||||
}
|
||||
if (el.fn instanceof CallbackStrategyWithFileUpload) {
|
||||
if (!el.fn.checkingFileExpression.test(req["files"]["file"]["name"])) {
|
||||
res.status(400).json("a file with this extension is expected: " + String(el.fn.checkingFileExpression));
|
||||
return;
|
||||
}
|
||||
}
|
||||
await this.responseHelper(res, el.fn.call(req["files"]["file"]));
|
||||
await this.responseHelper(res, el.fn.call(req["files"]["file"], req.query.id, req.query.description));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { NixStoreManagerPresentation } from "../../features/nix_store_manager/nix_store_manager";
|
||||
import { PipelinePresentation } from "../../features/pipelines/pipeline_presentation";
|
||||
import { ProcessPresentation } from "../../features/process/process_presentation";
|
||||
import { ProjectInstancePresentation } from "../../features/project_instance/project_instance_presentation";
|
||||
import {
|
||||
ProjectInstancePresentation,
|
||||
RobossemblerAssetsPresentation,
|
||||
} from "../../features/project_instance/project_instance_presentation";
|
||||
import { ProjectsPresentation } from "../../features/projects/projects_presentation";
|
||||
import { RealTimePresentation } from "../../features/realtime/realtime_presentation";
|
||||
import { TriggerPresentation } from "../../features/triggers/triggers_presentation";
|
||||
|
@ -21,6 +24,7 @@ export const httpRoutes: Routes[] = [
|
|||
new RealTimePresentation(),
|
||||
new ProjectInstancePresentation(),
|
||||
new NixStoreManagerPresentation(),
|
||||
new RobossemblerAssetsPresentation(),
|
||||
]
|
||||
.concat(routersImplementPureCrud)
|
||||
.map((el) => el.call());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue