progress
This commit is contained in:
parent
40eebf9dd8
commit
d7e8c825cb
12 changed files with 77 additions and 23 deletions
|
@ -9,6 +9,9 @@ import { dirname } from "path";
|
|||
import { CheckAndCreateStaticFilesFolderUseCase } from "../usecases/check_and_create_static_files_folder_usecase";
|
||||
import { DataBaseConnectUseCase } from "../usecases/database_connect_usecase";
|
||||
import { TypedEvent } from "../helpers/typed_event";
|
||||
import { CalculationInstanceDBModel } from "../../features/calculations_instance/models/calculations_instance_database_model";
|
||||
import * as fs from "fs";
|
||||
import { WriteFileSystemFileUseCase } from "../usecases/write_file_system_file_usecase";
|
||||
|
||||
export enum ServerStatus {
|
||||
init = "init",
|
||||
|
@ -85,7 +88,25 @@ export class App extends TypedEvent<ServerStatus> {
|
|||
this.app.use(express.json());
|
||||
this.app.use(express.urlencoded({ extended: true }));
|
||||
this.app.use(express.static(App.staticFilesStoreDir()));
|
||||
this.app.get('/logs', async (req, res) => {
|
||||
const id = req.query.id;
|
||||
|
||||
if (id === undefined) {
|
||||
return res.status(400).json('need req query id?=')
|
||||
}
|
||||
|
||||
const calculationInstanceDBModel = await CalculationInstanceDBModel.findById(id)
|
||||
if (calculationInstanceDBModel === null) {
|
||||
return res.status(400).json("calcultaion db model is null");
|
||||
}
|
||||
const p = App.staticFilesStoreDir() + '/log.txt';
|
||||
|
||||
(await new WriteFileSystemFileUseCase().call(p, calculationInstanceDBModel.lastProcessLogs)).map(() => {
|
||||
return res.sendFile(p);
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
this.app.use(
|
||||
fileUpload({
|
||||
createParentPath: true,
|
||||
|
|
|
@ -65,12 +65,12 @@ interface ISubSetFeatureRouter<A> {
|
|||
method: HttpMethodType;
|
||||
subUrl: string;
|
||||
fn:
|
||||
| CallbackStrategyWithValidationModel<A>
|
||||
| CallbackStrategyWithEmpty
|
||||
| CallbackStrategyWithIdQuery
|
||||
| CallBackStrategyWithQueryPage
|
||||
| CallbackStrategyWithFileUpload
|
||||
| CallbackStrategyWithFilesUploads;
|
||||
| CallbackStrategyWithValidationModel<A>
|
||||
| CallbackStrategyWithEmpty
|
||||
| CallbackStrategyWithIdQuery
|
||||
| CallBackStrategyWithQueryPage
|
||||
| CallbackStrategyWithFileUpload
|
||||
| CallbackStrategyWithFilesUploads;
|
||||
}
|
||||
|
||||
abstract class ICoreHttpController {
|
||||
|
@ -234,6 +234,7 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
|||
return res.json(ok);
|
||||
},
|
||||
(err) => {
|
||||
|
||||
return res.status(400).json({ error: String(err) });
|
||||
}
|
||||
);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import { CallbackStrategyWithIdQuery, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_database_model_usecase";
|
||||
import { CoreValidation } from "../../../core/validations/core_validation";
|
||||
import { MongoIdValidation } from "../../../core/validations/mongo_id_validation";
|
||||
import { ICalculationInstance, CalculationInstanceDBModel } from "../models/calculations_instance_database_model";
|
||||
|
||||
// export class LogToProcessUseCase extends CallbackStrategyWithIdQuery {
|
||||
// idValidationExpression: CoreValidation = new MongoIdValidation();
|
||||
// call = async (id: string): ResponseBase => (await new ReadByIdDataBaseModelUseCase<ICalculationInstance>(CalculationInstanceDBModel).call(id)).map((model) => );
|
||||
|
||||
// }
|
|
@ -4,7 +4,6 @@ import { SocketSubscriber } from "./core/controllers/socket_controller";
|
|||
import { extensions } from "./core/extensions/extensions";
|
||||
import { httpRoutes } from "./core/controllers/routes";
|
||||
import { executorProgramService } from "./core/usecases/exec_process_usecase";
|
||||
// import { main } from "./p";
|
||||
import { executorProgramServiceV2 } from "./core/scenarios/exec_process_scenario_v2";
|
||||
|
||||
extensions();
|
||||
|
@ -12,4 +11,3 @@ extensions();
|
|||
const socketSubscribers = [new SocketSubscriber(executorProgramService, "realtime"), new SocketSubscriber(executorProgramServiceV2, 'realtimeV2',)];
|
||||
|
||||
new App(httpRoutes, socketSubscribers).listen();
|
||||
// main()
|
Loading…
Add table
Add a link
Reference in a new issue