progress
This commit is contained in:
parent
6f86377685
commit
8ecb036b1d
36 changed files with 498 additions and 212 deletions
|
@ -1,13 +1,13 @@
|
|||
import express from "express";
|
||||
import { Routes } from "../interfaces/router";
|
||||
import cors from "cors";
|
||||
import locator from "../di/register_di";
|
||||
import { DevEnv, UnitTestEnv } from "../di/env";
|
||||
import mongoose from "mongoose";
|
||||
import { Server } from "socket.io";
|
||||
import { createServer } from "http";
|
||||
import { TypedEvent } from "../helper/typed_event";
|
||||
import { SocketSubscriber } from "./socket_controller";
|
||||
import { dirname } from "path";
|
||||
import { CreateFolderUseCase } from "../usecases/crete_folder_usecase";
|
||||
import { dirIsExists } from "../repository/fs";
|
||||
|
||||
export class App {
|
||||
public app: express.Application;
|
||||
|
@ -59,6 +59,7 @@ export class App {
|
|||
this.app.use(cors());
|
||||
this.app.use(express.json());
|
||||
this.app.use(express.urlencoded({ extended: true }));
|
||||
this.app.use(express.static("public"));
|
||||
}
|
||||
|
||||
private initializeRoutes(routes: Routes[]) {
|
||||
|
@ -72,6 +73,7 @@ export class App {
|
|||
// ? new DevEnv(this.computedFolder)
|
||||
// : new UnitTestEnv(this.computedFolder)
|
||||
// );
|
||||
await this.appStartController();
|
||||
|
||||
mongoose
|
||||
.connect("mongodb://127.0.0.1:27017/test")
|
||||
|
@ -80,4 +82,27 @@ export class App {
|
|||
console.log("ERROR:", e);
|
||||
});
|
||||
}
|
||||
|
||||
async appStartController() {
|
||||
console.log(App.staticFilesStoreDir());
|
||||
if (await dirIsExists(App.staticFilesStoreDir())) {
|
||||
return;
|
||||
}
|
||||
const createFolderUseCase = await new CreateFolderUseCase().call(
|
||||
App.staticFilesStoreDir()
|
||||
);
|
||||
|
||||
createFolderUseCase.fold(
|
||||
(_s) => {},
|
||||
(e) => {
|
||||
// TODO:(IDONTSUDO) need logger
|
||||
console.log(e);
|
||||
}
|
||||
);
|
||||
}
|
||||
static staticFilesStoreDir = () => {
|
||||
const dir = dirname(__filename);
|
||||
const rootDir = dir.slice(0, dir.length - 20);
|
||||
return rootDir + "public/";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue