get backend from TezosLink
This commit is contained in:
parent
6ec76544e2
commit
ad4f692732
@ -61,3 +61,4 @@ export default class ProjectController extends ApiController {
|
||||
this.httpCreated(res, await this.projectService.create(projectEntity));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,5 @@ import ProjectController from "./ProjectController";
|
||||
export default {
|
||||
start: () => {
|
||||
Container.get(ProjectController);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -22,3 +22,4 @@ export default function errorHandler(error: any, req: Request, response: Respons
|
||||
|
||||
next(error);
|
||||
}
|
||||
|
||||
|
@ -26,3 +26,4 @@ export default class TezosLink {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,3 +187,4 @@ export default class MetricRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ export default class ProjectRepository {
|
||||
_count: {
|
||||
select: { Metrics: true },
|
||||
},
|
||||
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
@ -58,3 +59,4 @@ export default class ProjectRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,22 +5,22 @@ export default class MetricEntity {
|
||||
@IsNotEmpty()
|
||||
public id!: number;
|
||||
|
||||
@IsNotEmpty({ groups: ["create"] })
|
||||
@IsNotEmpty(({groups: ["create"]}))
|
||||
public path!: string;
|
||||
|
||||
@IsNotEmpty({ groups: ["create"] })
|
||||
@IsNotEmpty(({groups: ["create"]}))
|
||||
public uuid!: string;
|
||||
|
||||
@IsNotEmpty({ groups: ["create"] })
|
||||
@IsNotEmpty(({groups: ["create"]}))
|
||||
public remote_address!: string;
|
||||
|
||||
@IsNotEmpty({ groups: ["create"] })
|
||||
@IsNotEmpty(({groups: ["create"]}))
|
||||
public date_requested!: Date;
|
||||
|
||||
@IsNotEmpty({ groups: ["create"] })
|
||||
@IsNotEmpty(({groups: ["create"]}))
|
||||
public projectId!: number;
|
||||
|
||||
@IsNotEmpty({ groups: ["create"] })
|
||||
@IsNotEmpty(({groups: ["create"]}))
|
||||
public project!: ProjectEntity;
|
||||
|
||||
@IsDate()
|
||||
|
@ -1 +1,2 @@
|
||||
export default class BaseService {}
|
||||
|
||||
|
@ -85,3 +85,4 @@ export default class MetricService {
|
||||
await this.metricRepository.removeOldMetricsBymonths(months);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import { ProjectEntity } from "@Common/ressources";
|
||||
import { type processFindManyQuery } from "prisma-query";
|
||||
import { Service } from "typedi";
|
||||
|
||||
|
||||
|
||||
@Service()
|
||||
export default class ProjectService {
|
||||
constructor(private projectRepository: ProjectRepository) {}
|
||||
@ -34,3 +36,4 @@ export default class ProjectService {
|
||||
return ObjectHydrate.hydrate<Partial<ProjectEntity>>(new ProjectEntity(), project);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,3 +31,4 @@ export default class ExpressServer implements ServerInterface {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,3 +14,4 @@ export default interface ServerInterface {
|
||||
|
||||
init(config: IConfig): this;
|
||||
}
|
||||
|
||||
|
@ -6,3 +6,4 @@ import HttpCodes from "@Common/system/controller-pattern/HttpCodes";
|
||||
export default abstract class ApiController extends BaseController {}
|
||||
|
||||
export { HttpCodes as ResponseStatusCodes };
|
||||
|
||||
|
@ -2,8 +2,10 @@ import { StRoute } from "./StRoute";
|
||||
import { Response } from "express";
|
||||
import HttpCodes from "@Common/system/controller-pattern/HttpCodes";
|
||||
|
||||
|
||||
type IResponseData = {} | string | number | boolean | null | unknown;
|
||||
|
||||
|
||||
export default abstract class BaseController {
|
||||
public expressRoutes!: StRoute[];
|
||||
public httpCode: typeof HttpCodes = HttpCodes;
|
||||
|
@ -34,3 +34,4 @@ function createRoute(controller: any, route: StRoute) {
|
||||
}
|
||||
|
||||
export default Controller;
|
||||
|
||||
|
@ -12,3 +12,4 @@ export default class ErrorCatch {
|
||||
next(args[args.length - 1] ?? "Unknown Error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,7 @@
|
||||
import BaseController from "./BaseController";
|
||||
import { StRoute } from "./StRoute";
|
||||
|
||||
function MethodsAny(
|
||||
type: StRoute["type"],
|
||||
path: string,
|
||||
frontMiddlewares: StRoute["frontMiddlewares"] = [],
|
||||
backMiddlewares: StRoute["backMiddlewares"] = [],
|
||||
) {
|
||||
function MethodsAny(type: StRoute["type"], path: string, frontMiddlewares: StRoute["frontMiddlewares"] = [], backMiddlewares: StRoute["backMiddlewares"] = []) {
|
||||
return (target: any, memberName: string, propertyDescriptor: PropertyDescriptor) => {
|
||||
const func = propertyDescriptor.value;
|
||||
const constructor: typeof BaseController = target.constructor;
|
||||
@ -34,3 +29,4 @@ export const Delete = MethodsAny.bind(null, "delete");
|
||||
* @description Decorator Method PUT
|
||||
*/
|
||||
export const Put = MethodsAny.bind(null, "put");
|
||||
|
||||
|
@ -7,3 +7,4 @@ export interface StRoute {
|
||||
frontMiddlewares: ((requests: Request, response: Response, next: NextFunction) => void)[];
|
||||
backMiddlewares: ((requests: Request, response: Response, next: NextFunction) => void)[];
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,8 @@ export default class DbProvider {
|
||||
},
|
||||
});
|
||||
|
||||
constructor(protected config: IDatabaseConfig) {}
|
||||
constructor(protected config: IDatabaseConfig) {
|
||||
}
|
||||
|
||||
public async connect(): Promise<void> {
|
||||
await this.client.$connect();
|
||||
|
@ -22,8 +22,15 @@ Container.get(ExpressServer).init({
|
||||
label,
|
||||
port: parseInt(port),
|
||||
rootUrl,
|
||||
middlwares: [cors({ origin: "*" }), bodyParser.urlencoded({ extended: true }), bodyParser.json()],
|
||||
middlwares: [
|
||||
cors({ origin: "*" }),
|
||||
bodyParser.urlencoded({ extended: true }),
|
||||
bodyParser.json(),
|
||||
],
|
||||
errorHandler,
|
||||
});
|
||||
|
||||
routes.start();
|
||||
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ if (!rootUrl) throw new Error(`process.env RootUrl is undefined`);
|
||||
|
||||
Container.get(NextServer).init({
|
||||
label,
|
||||
isDev: process.env.NODE_ENV !== "production",
|
||||
isDev: process.env.NODE_ENV !== 'production',
|
||||
port: parseInt(port),
|
||||
rootUrl,
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user