finish the launch
This commit is contained in:
parent
6ca82f8c2e
commit
fbcfba3948
12 changed files with 58 additions and 92 deletions
|
@ -29,7 +29,6 @@ export class App {
|
|||
// const io = new Server(httpServer);
|
||||
|
||||
httpServer.listen(this.port, () => {
|
||||
console.log(this.port);
|
||||
console.info(`=================================`);
|
||||
console.info(`======= ENV: ${this.env} =======`);
|
||||
console.info(`🚀 HTTP http://localhost:${this.port}`);
|
||||
|
@ -78,3 +77,6 @@ export class App {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2,8 +2,7 @@ import { validationModelMiddleware } from "../middlewares/validation_model";
|
|||
import { Result } from "../helper/result";
|
||||
import { Router, Request, Response } from "express";
|
||||
import { IRouteModel, Routes } from "../interfaces/router";
|
||||
|
||||
|
||||
|
||||
export type CallBackFunction<T> = (a: T) => Promise<Result<any, any>>;
|
||||
|
||||
abstract class ICoreHttpController {
|
||||
|
@ -40,10 +39,8 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
|||
);
|
||||
}
|
||||
if (this.routes["DELETE"] != null) {
|
||||
this.router.delete(
|
||||
this.url,
|
||||
(req, res) =>
|
||||
this.requestResponseController<V>(req, res, this.routes["DELETE"])
|
||||
this.router.delete(this.url, (req, res) =>
|
||||
this.requestResponseController<V>(req, res, this.routes["DELETE"])
|
||||
);
|
||||
}
|
||||
if (this.routes["PUT"] != null) {
|
||||
|
@ -75,24 +72,20 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
|||
res: Response,
|
||||
usecase: CallBackFunction<T>
|
||||
) {
|
||||
let payload = null
|
||||
let payload = null;
|
||||
|
||||
if (req["model"] != undefined) {
|
||||
payload = req.body as T
|
||||
|
||||
payload = req.body as T;
|
||||
}
|
||||
|
||||
if (req.query.page !== undefined) {
|
||||
payload = String(req.query.page)
|
||||
|
||||
payload = String(req.query.page);
|
||||
}
|
||||
|
||||
if (req.query.id !== undefined) {
|
||||
payload = String(req.query.id)
|
||||
payload = String(req.query.id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
(await usecase(payload)).fold(
|
||||
(ok) => {
|
||||
res.json(ok);
|
||||
|
@ -112,4 +105,3 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
|||
this.routes["GET"] = usecase;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
import path from "path";
|
||||
import { TypedEvent } from "../helper/typed_event";
|
||||
import { StackService } from "../services/stack_service";
|
||||
// TODO(IDONTSUDO): up to do
|
||||
// import path from "path";
|
||||
// import { TypedEvent } from "../helper/typed_event";
|
||||
// import { StackService } from "../services/stack_service";
|
||||
// // TODO(IDONTSUDO): up to do
|
||||
|
||||
class SocketController<T>{
|
||||
emitter:TypedEvent<T>;
|
||||
constructor(emitter:TypedEvent<T>, ){
|
||||
this.emitter = emitter
|
||||
}
|
||||
call = () =>{
|
||||
// class SocketController<T>{
|
||||
// emitter:TypedEvent<T>;
|
||||
// constructor(emitter:TypedEvent<T>, ){
|
||||
// this.emitter = emitter
|
||||
// }
|
||||
// call = () =>{
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue