Skip to content

Commit

Permalink
build: fix typescript build
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Sep 10, 2021
1 parent 9a8f7db commit 7582f5b
Show file tree
Hide file tree
Showing 84 changed files with 5,552 additions and 5,246 deletions.
6 changes: 5 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
"**/node_modules/**",
"**/build/**",
"**/src/main/typescript/generated/**",
"packages/cactus-plugin-verifier-cc/**"
"packages/cactus-plugin-verifier-cc/**",
"packages/cactus-cmd-socketio-server/**",
"packages/cactus-plugin-ledger-connector-sawtooth-socketio/**",
"packages/cactus-plugin-ledger-connector-go-ethereum-socketio/**",
"packages/cactus-plugin-ledger-connector-*-socketio/**"
]
}
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@

**/src/main/typescript/generated/proto/**
packages/cactus-verifier/src/main/typescript/

packages/cactus-cmd-socketio-server/**
packages/cactus-plugin-ledger-connector-sawtooth-socketio/**
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/**
packages/cactus-plugin-ledger-connector-*-socketio/**
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { CID } from "multiformats/cid";
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
API as FilesAPI,
Expand Down Expand Up @@ -141,7 +140,7 @@ export class FilesApiMock implements FilesAPI {
public async flush(
ipfsPath: string,
options?: AbortOptions | undefined,
): Promise<CID> {
): Promise<any> {
throw new RuntimeError("Method flush() not implemented");
}

Expand Down
4 changes: 2 additions & 2 deletions packages/cactus-cmd-socketio-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "packages",
"private": true,
"name": "@hyperledger/cactus-cmd-socketio-server",
"private": false,
"scripts": {
"build": "npm run build-ts && npm run copy-static-assets",
"build-ts": "tsc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
* BLP_config.ts
*/

import { BusinessLogicPlugin } from './BusinessLogicPlugin';
import { BusinessLogicPlugin } from "./BusinessLogicPlugin";

export function getTargetBLPInstance(businessLogicID: string): BusinessLogicPlugin | null {
return null;
export function getTargetBLPInstance(
businessLogicID: string,
): BusinessLogicPlugin | null {
return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,79 @@
* BusinessLogicBase.ts
*/

import { Request } from 'express';
import { BusinessLogicPlugin } from './BusinessLogicPlugin';
import { VerifierEventListener, LedgerEvent } from '../verifier/LedgerPlugin';
import { json2str } from '../verifier/DriverCommon'
import { ConfigUtil } from '../routing-interface/util/ConfigUtil';
import { Request } from "express";
import { BusinessLogicPlugin } from "./BusinessLogicPlugin";
import { VerifierEventListener, LedgerEvent } from "../verifier/LedgerPlugin";
import { json2str } from "../verifier/DriverCommon";
import { ConfigUtil } from "../routing-interface/util/ConfigUtil";

const fs = require('fs');
const path = require('path');
const fs = require("fs");
const path = require("path");
const config: any = ConfigUtil.getConfig();
import { getLogger } from "log4js";
const moduleName = 'BusinessLogicBase';
const moduleName = "BusinessLogicBase";
const logger = getLogger(`${moduleName}`);
logger.level = config.logLevel;

export class BusinessLogicBase implements BusinessLogicPlugin {
eventFilter: object | null = null;
eventFilter: object | null = null;

startTransaction(req: Request, businessLogicID: string, tradeID: string): void {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
}
startTransaction(
req: Request,
businessLogicID: string,
tradeID: string,
): void {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
}

executeNextTransaction(txInfo: object, txId: string): void {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
}
executeNextTransaction(txInfo: object, txId: string): void {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
}

getOperationStatus(tradeID: string): object {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return {};
}
getOperationStatus(tradeID: string): object {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return {};
}

setConfig(data: []): object {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return {};
}
setConfig(data: []): object {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return {};
}

onEvent(ledgerEvent: LedgerEvent, targetIndex: number): void {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
}
onEvent(ledgerEvent: LedgerEvent, targetIndex: number): void {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
}

getEventFilter(): object | null {
logger.debug(`##called getEventFilter: ${json2str(this.eventFilter)}`);
return this.eventFilter;
}
getEventFilter(): object | null {
logger.debug(`##called getEventFilter: ${json2str(this.eventFilter)}`);
return this.eventFilter;
}

setEventFilter(filter: object): void {
logger.debug(`##called setEventFilter(before): ${json2str(this.eventFilter)}`);
this.eventFilter = filter;
logger.debug(`##called setEventFilter(after): ${json2str(this.eventFilter)}`);
}
setEventFilter(filter: object): void {
logger.debug(
`##called setEventFilter(before): ${json2str(this.eventFilter)}`,
);
this.eventFilter = filter;
logger.debug(
`##called setEventFilter(after): ${json2str(this.eventFilter)}`,
);
}

getEventDataNum(ledgerEvent: LedgerEvent): number {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return 0;
}
getEventDataNum(ledgerEvent: LedgerEvent): number {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return 0;
}

getTxIDFromEvent(ledgerEvent: LedgerEvent, targetIndex: number): string | null {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return null;
}
getTxIDFromEvent(
ledgerEvent: LedgerEvent,
targetIndex: number,
): string | null {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return null;
}

hasTxIDInTransactions(txID: string): boolean {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return false;
}
hasTxIDInTransactions(txID: string): boolean {
// NOTE: This method implements the BisinessLogcPlugin operation(* Override by subclass)
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
* BusinessLogicPlugin.ts
*/

import { Request } from 'express';
import { VerifierEventListener, LedgerEvent } from '../verifier/LedgerPlugin';
import { Request } from "express";
import { VerifierEventListener, LedgerEvent } from "../verifier/LedgerPlugin";

export interface BusinessLogicPlugin {
startTransaction(req: Request, businessLogicID: string, tradeID: string): void;
getOperationStatus(tradeID: string): object;
setConfig(data: []): object;
onEvent(ledgerEvent: LedgerEvent, targetIndex: number): void;
getEventDataNum(ledgerEvent: LedgerEvent): number;
getTxIDFromEvent(ledgerEvent: LedgerEvent, targetIndex: number): string | null;
hasTxIDInTransactions(txID: string): boolean;
startTransaction(
req: Request,
businessLogicID: string,
tradeID: string,
): void;
getOperationStatus(tradeID: string): object;
setConfig(data: []): object;
onEvent(ledgerEvent: LedgerEvent, targetIndex: number): void;
getEventDataNum(ledgerEvent: LedgerEvent): number;
getTxIDFromEvent(
ledgerEvent: LedgerEvent,
targetIndex: number,
): string | null;
hasTxIDInTransactions(txID: string): boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
*/

export class LedgerOperation {
apiType: string;
progress: string;
data: {};
apiType: string;
progress: string;
data: {};

constructor(apiType: string, progress: string, data: {}) {
this.apiType = apiType;
this.progress = progress;
this.data = data;
}
constructor(apiType: string, progress: string, data: {}) {
this.apiType = apiType;
this.progress = progress;
this.data = data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,70 @@
* app.ts
*/

import { NextFunction, Request, Response } from 'express';
import { NextFunction, Request, Response } from "express";

import createError = require('http-errors');
import express = require('express');
import path = require('path');
import cookieParser = require('cookie-parser');
import logger = require('morgan');
import bodyParser = require('body-parser');
import createError = require("http-errors");
import express = require("express");
import path = require("path");
import cookieParser = require("cookie-parser");
import logger = require("morgan");
import bodyParser = require("body-parser");

import indexRouter from '../routing-interface/routes/index';
import loginRouter from '../routing-interface/routes/login';
import blockmonitorRouter from '../routing-interface/routes/blockmonitor';
import { ConfigUtil } from '../routing-interface/util/ConfigUtil';
import indexRouter from "../routing-interface/routes/index";
import loginRouter from "../routing-interface/routes/login";
import blockmonitorRouter from "../routing-interface/routes/blockmonitor";
import { ConfigUtil } from "../routing-interface/util/ConfigUtil";

const config: any = ConfigUtil.getConfig();

const app: express.Express = express();

app.use(logger('dev'));
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, "public")));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.use('/', indexRouter);
app.use('/api/v1/bl/login/', loginRouter);
app.use('/api/v1/bl/blockmonitor/', blockmonitorRouter);
app.use("/", indexRouter);
app.use("/api/v1/bl/login/", loginRouter);
app.use("/api/v1/bl/blockmonitor/", blockmonitorRouter);

// Dynamic loading
console.debug(`start Dynamic loading.`);
for (var appRouter of config.appRouters) {
console.debug(`path: ${appRouter.path}, routerJs: ${appRouter.routerJs}`);
app.use(appRouter.path, require(appRouter.routerJs).default);
for (const appRouter of config.appRouters) {
console.debug(`path: ${appRouter.path}, routerJs: ${appRouter.routerJs}`);
app.use(appRouter.path, require(appRouter.routerJs).default);
}


// catch 404 and forward to error handler
app.use((req: Request, res: Response, next: NextFunction) => {
next(createError(404));
});

// error handler
app.use((err: { message: string, status?: number }, req: Request, res: Response, next: NextFunction) => {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
app.use(
(
err: { message: string; status?: number },
req: Request,
res: Response,
next: NextFunction,
) => {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get("env") === "development" ? err : {};

// set erreor response
const errorResponse: {} = {
"statusCode": err.status || 500,
"message": err.message
};
// set erreor response
const errorResponse: {} = {
statusCode: err.status || 500,
message: err.message,
};

// render the error page
res.status(err.status || 500);
res.send(errorResponse);
});
// render the error page
res.status(err.status || 500);
res.send(errorResponse);
},
);

export default app;
Loading

0 comments on commit 7582f5b

Please sign in to comment.