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);
|
// const io = new Server(httpServer);
|
||||||
|
|
||||||
httpServer.listen(this.port, () => {
|
httpServer.listen(this.port, () => {
|
||||||
console.log(this.port);
|
|
||||||
console.info(`=================================`);
|
console.info(`=================================`);
|
||||||
console.info(`======= ENV: ${this.env} =======`);
|
console.info(`======= ENV: ${this.env} =======`);
|
||||||
console.info(`🚀 HTTP http://localhost:${this.port}`);
|
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 { Result } from "../helper/result";
|
||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { IRouteModel, Routes } from "../interfaces/router";
|
import { IRouteModel, Routes } from "../interfaces/router";
|
||||||
|
|
||||||
|
|
||||||
export type CallBackFunction<T> = (a: T) => Promise<Result<any, any>>;
|
export type CallBackFunction<T> = (a: T) => Promise<Result<any, any>>;
|
||||||
|
|
||||||
abstract class ICoreHttpController {
|
abstract class ICoreHttpController {
|
||||||
|
@ -40,10 +39,8 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.routes["DELETE"] != null) {
|
if (this.routes["DELETE"] != null) {
|
||||||
this.router.delete(
|
this.router.delete(this.url, (req, res) =>
|
||||||
this.url,
|
this.requestResponseController<V>(req, res, this.routes["DELETE"])
|
||||||
(req, res) =>
|
|
||||||
this.requestResponseController<V>(req, res, this.routes["DELETE"])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.routes["PUT"] != null) {
|
if (this.routes["PUT"] != null) {
|
||||||
|
@ -75,24 +72,20 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
||||||
res: Response,
|
res: Response,
|
||||||
usecase: CallBackFunction<T>
|
usecase: CallBackFunction<T>
|
||||||
) {
|
) {
|
||||||
let payload = null
|
let payload = null;
|
||||||
|
|
||||||
if (req["model"] != undefined) {
|
if (req["model"] != undefined) {
|
||||||
payload = req.body as T
|
payload = req.body as T;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.query.page !== undefined) {
|
if (req.query.page !== undefined) {
|
||||||
payload = String(req.query.page)
|
payload = String(req.query.page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.query.id !== undefined) {
|
if (req.query.id !== undefined) {
|
||||||
payload = String(req.query.id)
|
payload = String(req.query.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(await usecase(payload)).fold(
|
(await usecase(payload)).fold(
|
||||||
(ok) => {
|
(ok) => {
|
||||||
res.json(ok);
|
res.json(ok);
|
||||||
|
@ -112,4 +105,3 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
||||||
this.routes["GET"] = usecase;
|
this.routes["GET"] = usecase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import path from "path";
|
// import path from "path";
|
||||||
import { TypedEvent } from "../helper/typed_event";
|
// import { TypedEvent } from "../helper/typed_event";
|
||||||
import { StackService } from "../services/stack_service";
|
// import { StackService } from "../services/stack_service";
|
||||||
// TODO(IDONTSUDO): up to do
|
// // TODO(IDONTSUDO): up to do
|
||||||
|
|
||||||
class SocketController<T>{
|
// class SocketController<T>{
|
||||||
emitter:TypedEvent<T>;
|
// emitter:TypedEvent<T>;
|
||||||
constructor(emitter:TypedEvent<T>, ){
|
// constructor(emitter:TypedEvent<T>, ){
|
||||||
this.emitter = emitter
|
// this.emitter = emitter
|
||||||
}
|
// }
|
||||||
call = () =>{
|
// call = () =>{
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { DevEnv, IEnv, UnitTestEnv } from "./env";
|
import { DevEnv, IEnv, UnitTestEnv } from "./env";
|
||||||
import { extensions } from "../extensions/extensions";
|
import { extensions } from "../extensions/extensions";
|
||||||
import { Container, Service } from 'typedi';
|
// import { Container, Service } from 'typedi';
|
||||||
|
|
||||||
export default function locator(env: IEnv) {
|
export default function locator(env: IEnv) {
|
||||||
extensions();
|
extensions();
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import { EXEC_EVENT, EXEC_TYPE } from "./exec_error_model";
|
import { EXEC_EVENT, EXEC_TYPE } from "./exec_error_model";
|
||||||
|
|
||||||
|
|
||||||
export class ExecutorResult {
|
export class ExecutorResult {
|
||||||
type: EXEC_TYPE;
|
type: EXEC_TYPE;
|
||||||
event: EXEC_EVENT;
|
event: EXEC_EVENT;
|
||||||
data: any;
|
data: any;
|
||||||
constructor(type: EXEC_TYPE, event: EXEC_EVENT, data: any) {
|
constructor(type: EXEC_TYPE, event: EXEC_EVENT, data: any) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.event = event;
|
this.event = event;
|
||||||
this.data = data;
|
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 {
|
return;
|
||||||
if ("type" in value && "event" in value && "data" in value) {
|
}
|
||||||
return new ExecutorResult(value.type, value.event, value.data);
|
}
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import { Trigger } from "../../features/triggers/trigger_model";
|
import { Trigger } from "../../features/triggers/trigger_model";
|
||||||
import { EXEC_TYPE } from "./exec_error_model";
|
import { EXEC_TYPE } from "./exec_error_model";
|
||||||
|
|
||||||
|
|
||||||
export interface IPipeline {
|
export interface IPipeline {
|
||||||
process: IProcess;
|
process: IProcess;
|
||||||
trigger: Trigger;
|
trigger: Trigger;
|
||||||
env: Env | null;
|
env: Env | null;
|
||||||
stackGenerateType:StackGenerateType;
|
stackGenerateType: StackGenerateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum StackGenerateType{
|
export enum StackGenerateType {
|
||||||
MAP = 'MAP',
|
MAP = "MAP",
|
||||||
SINGLETON = 'SINGLETON'
|
SINGLETON = "SINGLETON",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Env {
|
export interface Env {
|
||||||
|
@ -21,18 +20,16 @@ export interface Env {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IProcess {
|
export interface IProcess {
|
||||||
type: EXEC_TYPE;
|
type: EXEC_TYPE;
|
||||||
command: string;
|
command: string;
|
||||||
isGenerating: boolean;
|
isGenerating: boolean;
|
||||||
isLocaleCode: boolean;
|
isLocaleCode: boolean;
|
||||||
issueType: IssueType;
|
issueType: IssueType;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
commit?:string | undefined;
|
commit?: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum IssueType {
|
export enum IssueType {
|
||||||
WARNING = "WARNING",
|
WARNING = "WARNING",
|
||||||
ERROR = "ERROR",
|
ERROR = "ERROR",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ const readdir = promisify(fs.readdir);
|
||||||
const stat = promisify(fs.stat);
|
const stat = promisify(fs.stat);
|
||||||
const lsStat = promisify(fs.lstat);
|
const lsStat = promisify(fs.lstat);
|
||||||
|
|
||||||
function joinBuffers(buffers:Array<Buffer>, delimiter = " ") {
|
function joinBuffers(buffers: Array<Buffer>, delimiter = " ") {
|
||||||
const d = Buffer.from(delimiter);
|
const d = Buffer.from(delimiter);
|
||||||
return buffers.reduce((prev, b) => Buffer.concat([prev, d, b]));
|
return buffers.reduce((prev, b) => Buffer.concat([prev, d, b]));
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,6 @@ export interface IHashesCache {
|
||||||
[key: string]: MetaDataFileManagerModel;
|
[key: string]: MetaDataFileManagerModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export abstract class IFilesChangeNotifierService {
|
export abstract class IFilesChangeNotifierService {
|
||||||
abstract directory: string;
|
abstract directory: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,12 @@ import {
|
||||||
} from "./files_change_notifier_service";
|
} from "./files_change_notifier_service";
|
||||||
import { IPipeline } from "../model/process_model";
|
import { IPipeline } from "../model/process_model";
|
||||||
import { ExecutorProgramService } from "./executor_program_service";
|
import { ExecutorProgramService } from "./executor_program_service";
|
||||||
import {
|
import { EXEC_EVENT, ExecError, SpawnError } from "../model/exec_error_model";
|
||||||
EXEC_EVENT,
|
|
||||||
ExecError,
|
|
||||||
SpawnError,
|
|
||||||
} from "../model/exec_error_model";
|
|
||||||
import { TypedEvent } from "../helper/typed_event";
|
import { TypedEvent } from "../helper/typed_event";
|
||||||
import { Result } from "../helper/result";
|
import { Result } from "../helper/result";
|
||||||
import { ExecutorResult } from "../model/executor_result";
|
import { ExecutorResult } from "../model/executor_result";
|
||||||
import { delay } from "../helper/delay";
|
import { delay } from "../helper/delay";
|
||||||
import { TriggerErrorReport, TriggerService } from "./trigger_service";
|
import { TriggerService } from "./trigger_service";
|
||||||
import { Trigger } from "../../features/triggers/trigger_model";
|
import { Trigger } from "../../features/triggers/trigger_model";
|
||||||
|
|
||||||
export interface Iteration {
|
export interface Iteration {
|
||||||
|
@ -92,10 +88,10 @@ export class StackService extends TypedEvent<string> implements IStackService {
|
||||||
);
|
);
|
||||||
triggerResult.fold(
|
triggerResult.fold(
|
||||||
(s) => {
|
(s) => {
|
||||||
s
|
s;
|
||||||
},
|
},
|
||||||
(e) => {
|
(e) => {
|
||||||
e;
|
e;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,7 @@ import { IHashesCache } from "./files_change_notifier_service";
|
||||||
import { EventsFileChanger } from "../model/meta_data_file_manager_model";
|
import { EventsFileChanger } from "../model/meta_data_file_manager_model";
|
||||||
import { Result } from "../helper/result";
|
import { Result } from "../helper/result";
|
||||||
import { TypedEvent } from "../helper/typed_event";
|
import { TypedEvent } from "../helper/typed_event";
|
||||||
import {
|
import { Trigger, TriggerType } from "../../features/triggers/trigger_model";
|
||||||
Trigger,
|
|
||||||
TriggerType,
|
|
||||||
} from "../../features/triggers/trigger_model";
|
|
||||||
|
|
||||||
export class TriggerCallResult {
|
export class TriggerCallResult {
|
||||||
results: Array<TriggerSuccessResult | TriggerErrorReport>;
|
results: Array<TriggerSuccessResult | TriggerErrorReport>;
|
||||||
|
@ -50,7 +47,7 @@ export class TriggerErrorReport extends Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class TriggerService extends TypedEvent<TriggerCallResult> {
|
export class TriggerService extends TypedEvent<TriggerCallResult> {
|
||||||
context:any = {};
|
context: any = {};
|
||||||
|
|
||||||
constructor(trigger: Trigger, hashes: IHashesCache, path: string) {
|
constructor(trigger: Trigger, hashes: IHashesCache, path: string) {
|
||||||
super();
|
super();
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
import {
|
import {
|
||||||
IsString,
|
IsString,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
ValidateNested,
|
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsMongoId,
|
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { ObjectId, Schema, model } from "mongoose";
|
import { Schema, model } from "mongoose";
|
||||||
import {
|
import {
|
||||||
IProcess,
|
IProcess,
|
||||||
IPipeline,
|
|
||||||
IssueType,
|
IssueType,
|
||||||
StackGenerateType,
|
|
||||||
} from "../../core/model/process_model";
|
} from "../../core/model/process_model";
|
||||||
import { Type } from "class-transformer";
|
|
||||||
import { EXEC_TYPE } from "../../core/model/exec_error_model";
|
import { EXEC_TYPE } from "../../core/model/exec_error_model";
|
||||||
|
|
||||||
export const ProcessSchema = new Schema({
|
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 { PipelineModel, schemaPipeline } from "../pipelines/pipeline_model";
|
||||||
|
import { IsMongoId, IsString } from "class-validator";
|
||||||
|
|
||||||
export interface IProjectModel {
|
export interface IProjectModel {
|
||||||
pipelines: [PipelineModel];
|
pipelines: [PipelineModel];
|
||||||
rootDir: string;
|
rootDir: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ProjectSchema = new Schema({
|
export const ProjectSchema = new Schema({
|
||||||
pipelines: {
|
pipelines: {
|
||||||
type: Array<Schema.Types.ObjectId>,
|
type: Array<Schema.Types.ObjectId>,
|
||||||
|
@ -24,19 +24,8 @@ const schema = "Projects";
|
||||||
export const ProjectDBModel = model<IProjectModel>(schema, ProjectSchema);
|
export const ProjectDBModel = model<IProjectModel>(schema, ProjectSchema);
|
||||||
|
|
||||||
export class ProjectModel implements IProjectModel {
|
export class ProjectModel implements IProjectModel {
|
||||||
|
@IsMongoId()
|
||||||
pipelines: [PipelineModel];
|
pipelines: [PipelineModel];
|
||||||
|
@IsString()
|
||||||
rootDir: string;
|
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 { ProjectsPresentation } from "./features/projects/projects_presentation";
|
||||||
import { PipelinePresentation } from "./features/pipelines/pipeline_presentation";
|
import { PipelinePresentation } from "./features/pipelines/pipeline_presentation";
|
||||||
import { ProcessPresentation } from "./features/process/process_presentation";
|
import { ProcessPresentation } from "./features/process/process_presentation";
|
||||||
|
|
||||||
|
|
||||||
const httpRoutes: Routes[] = [
|
const httpRoutes: Routes[] = [
|
||||||
new TriggerPresentation(),
|
new TriggerPresentation(),
|
||||||
|
@ -17,4 +17,5 @@ const httpRoutes: Routes[] = [
|
||||||
const computedFolder = "";
|
const computedFolder = "";
|
||||||
|
|
||||||
new App(httpRoutes, computedFolder).listen();
|
new App(httpRoutes, computedFolder).listen();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue