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 = () =>{
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { DevEnv, IEnv, UnitTestEnv } from "./env";
|
||||
import { extensions } from "../extensions/extensions";
|
||||
import { Container, Service } from 'typedi';
|
||||
// import { Container, Service } from 'typedi';
|
||||
|
||||
export default function locator(env: IEnv) {
|
||||
extensions();
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import { EXEC_EVENT, EXEC_TYPE } from "./exec_error_model";
|
||||
|
||||
|
||||
export class ExecutorResult {
|
||||
type: EXEC_TYPE;
|
||||
event: EXEC_EVENT;
|
||||
data: any;
|
||||
constructor(type: EXEC_TYPE, event: EXEC_EVENT, data: any) {
|
||||
this.type = type;
|
||||
this.event = event;
|
||||
this.data = data;
|
||||
type: EXEC_TYPE;
|
||||
event: EXEC_EVENT;
|
||||
data: any;
|
||||
constructor(type: EXEC_TYPE, event: EXEC_EVENT, data: any) {
|
||||
this.type = type;
|
||||
this.event = event;
|
||||
this.data = data;
|
||||
}
|
||||
static isExecutorResult(value: any): void | ExecutorResult {
|
||||
if ("type" in value && "event" in value && "data" in value) {
|
||||
return new ExecutorResult(value.type, value.event, value.data);
|
||||
}
|
||||
static isExecutorResult(value: any): void | ExecutorResult {
|
||||
if ("type" in value && "event" in value && "data" in value) {
|
||||
return new ExecutorResult(value.type, value.event, value.data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import { Trigger } from "../../features/triggers/trigger_model";
|
||||
import { EXEC_TYPE } from "./exec_error_model";
|
||||
|
||||
|
||||
export interface IPipeline {
|
||||
process: IProcess;
|
||||
trigger: Trigger;
|
||||
env: Env | null;
|
||||
stackGenerateType:StackGenerateType;
|
||||
stackGenerateType: StackGenerateType;
|
||||
}
|
||||
|
||||
export enum StackGenerateType{
|
||||
MAP = 'MAP',
|
||||
SINGLETON = 'SINGLETON'
|
||||
export enum StackGenerateType {
|
||||
MAP = "MAP",
|
||||
SINGLETON = "SINGLETON",
|
||||
}
|
||||
|
||||
export interface Env {
|
||||
|
@ -21,18 +20,16 @@ export interface Env {
|
|||
}
|
||||
|
||||
export interface IProcess {
|
||||
type: EXEC_TYPE;
|
||||
type: EXEC_TYPE;
|
||||
command: string;
|
||||
isGenerating: boolean;
|
||||
isLocaleCode: boolean;
|
||||
issueType: IssueType;
|
||||
timeout?: number;
|
||||
commit?:string | undefined;
|
||||
commit?: string | undefined;
|
||||
}
|
||||
|
||||
export enum IssueType {
|
||||
WARNING = "WARNING",
|
||||
ERROR = "ERROR",
|
||||
}
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ const readdir = promisify(fs.readdir);
|
|||
const stat = promisify(fs.stat);
|
||||
const lsStat = promisify(fs.lstat);
|
||||
|
||||
function joinBuffers(buffers:Array<Buffer>, delimiter = " ") {
|
||||
function joinBuffers(buffers: Array<Buffer>, delimiter = " ") {
|
||||
const d = Buffer.from(delimiter);
|
||||
return buffers.reduce((prev, b) => Buffer.concat([prev, d, b]));
|
||||
}
|
||||
|
@ -44,8 +44,6 @@ export interface IHashesCache {
|
|||
[key: string]: MetaDataFileManagerModel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export abstract class IFilesChangeNotifierService {
|
||||
abstract directory: string;
|
||||
}
|
||||
|
|
|
@ -4,16 +4,12 @@ import {
|
|||
} from "./files_change_notifier_service";
|
||||
import { IPipeline } from "../model/process_model";
|
||||
import { ExecutorProgramService } from "./executor_program_service";
|
||||
import {
|
||||
EXEC_EVENT,
|
||||
ExecError,
|
||||
SpawnError,
|
||||
} from "../model/exec_error_model";
|
||||
import { EXEC_EVENT, ExecError, SpawnError } from "../model/exec_error_model";
|
||||
import { TypedEvent } from "../helper/typed_event";
|
||||
import { Result } from "../helper/result";
|
||||
import { ExecutorResult } from "../model/executor_result";
|
||||
import { delay } from "../helper/delay";
|
||||
import { TriggerErrorReport, TriggerService } from "./trigger_service";
|
||||
import { TriggerService } from "./trigger_service";
|
||||
import { Trigger } from "../../features/triggers/trigger_model";
|
||||
|
||||
export interface Iteration {
|
||||
|
@ -92,10 +88,10 @@ export class StackService extends TypedEvent<string> implements IStackService {
|
|||
);
|
||||
triggerResult.fold(
|
||||
(s) => {
|
||||
s
|
||||
s;
|
||||
},
|
||||
(e) => {
|
||||
e;
|
||||
e;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,10 +3,7 @@ import { IHashesCache } from "./files_change_notifier_service";
|
|||
import { EventsFileChanger } from "../model/meta_data_file_manager_model";
|
||||
import { Result } from "../helper/result";
|
||||
import { TypedEvent } from "../helper/typed_event";
|
||||
import {
|
||||
Trigger,
|
||||
TriggerType,
|
||||
} from "../../features/triggers/trigger_model";
|
||||
import { Trigger, TriggerType } from "../../features/triggers/trigger_model";
|
||||
|
||||
export class TriggerCallResult {
|
||||
results: Array<TriggerSuccessResult | TriggerErrorReport>;
|
||||
|
@ -50,7 +47,7 @@ export class TriggerErrorReport extends Error {
|
|||
}
|
||||
}
|
||||
export class TriggerService extends TypedEvent<TriggerCallResult> {
|
||||
context:any = {};
|
||||
context: any = {};
|
||||
|
||||
constructor(trigger: Trigger, hashes: IHashesCache, path: string) {
|
||||
super();
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
ValidateNested,
|
||||
IsEnum,
|
||||
IsMongoId,
|
||||
IsNumber,
|
||||
IsBoolean,
|
||||
} from "class-validator";
|
||||
import { ObjectId, Schema, model } from "mongoose";
|
||||
import { Schema, model } from "mongoose";
|
||||
import {
|
||||
IProcess,
|
||||
IPipeline,
|
||||
IssueType,
|
||||
StackGenerateType,
|
||||
} from "../../core/model/process_model";
|
||||
import { Type } from "class-transformer";
|
||||
import { EXEC_TYPE } from "../../core/model/exec_error_model";
|
||||
|
||||
export const ProcessSchema = new Schema({
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import mongoose, { Schema, model } from "mongoose";
|
||||
import { Schema, model } from "mongoose";
|
||||
import { PipelineModel, schemaPipeline } from "../pipelines/pipeline_model";
|
||||
import { IsMongoId, IsString } from "class-validator";
|
||||
|
||||
export interface IProjectModel {
|
||||
pipelines: [PipelineModel];
|
||||
rootDir: string;
|
||||
}
|
||||
|
||||
|
||||
export const ProjectSchema = new Schema({
|
||||
pipelines: {
|
||||
type: Array<Schema.Types.ObjectId>,
|
||||
|
@ -24,19 +24,8 @@ const schema = "Projects";
|
|||
export const ProjectDBModel = model<IProjectModel>(schema, ProjectSchema);
|
||||
|
||||
export class ProjectModel implements IProjectModel {
|
||||
@IsMongoId()
|
||||
pipelines: [PipelineModel];
|
||||
@IsString()
|
||||
rootDir: string;
|
||||
}
|
||||
|
||||
// export class ProcessModel implements IProcessMetaData {
|
||||
|
||||
// public process: IProcess;
|
||||
|
||||
// public trigger: ObjectId;
|
||||
|
||||
// // TODO(IDONTSUDO): later, when maintaining many environments, you will need to make a table
|
||||
// public env = null;
|
||||
|
||||
// @IsEnum(StackGenerateType)
|
||||
// public stackGenerateType: StackGenerateType;
|
||||
// }
|
||||
|
|
|
@ -5,7 +5,7 @@ import { TriggerPresentation } from "./features/triggers/triggers_presentation";
|
|||
import { ProjectsPresentation } from "./features/projects/projects_presentation";
|
||||
import { PipelinePresentation } from "./features/pipelines/pipeline_presentation";
|
||||
import { ProcessPresentation } from "./features/process/process_presentation";
|
||||
|
||||
|
||||
|
||||
const httpRoutes: Routes[] = [
|
||||
new TriggerPresentation(),
|
||||
|
@ -17,4 +17,5 @@ const httpRoutes: Routes[] = [
|
|||
const computedFolder = "";
|
||||
|
||||
new App(httpRoutes, computedFolder).listen();
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue