forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peter Somogyvari <[email protected]>
- Loading branch information
Showing
17 changed files
with
266 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/bif-cmd-api-server/src/main/typescript/common/servers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Server } from 'http'; | ||
import { Server as SecureServer } from 'https'; | ||
|
||
/** | ||
* Utility class for handling common tasks for NodeJS HTTP/S server objects. | ||
*/ | ||
export class Servers { | ||
|
||
/** | ||
* Returns with a promise that resolves when the server has been shut down. Rejects if anything goes wrong of if the | ||
* parameters are invalid. | ||
* | ||
* @param server The server object that will be shut down. | ||
*/ | ||
public static async shutdown(server: Server | SecureServer): Promise<void> { | ||
if (!server) { | ||
throw new TypeError(`Servers#shutdown() server was falsy. Need object.`); | ||
} | ||
return new Promise<void>((resolve, reject) => { | ||
server.close((err: any) => { | ||
if (err) { | ||
reject(new Error(`Servers#shutdown() Failed to shut down server: ${err.stack}`)); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/bif-cmd-api-server/src/main/typescript/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { ApiServer } from './api-server'; | ||
export { ConfigService } from './config/config-service'; | ||
export { ApiServer, IApiServerConstructorOptions } from './api-server'; | ||
export { ConfigService, IBifApiServerOptions } from './config/config-service'; | ||
export { CreateConsortiumEndpointV1, ICreateConsortiumEndpointOptions } from './consortium/routes/create-consortium-endpoint-v1'; |
28 changes: 28 additions & 0 deletions
28
packages/bif-core-api/src/main/typescript/plugin/i-cactus-plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PluginAspect } from "./plugin-aspect"; | ||
|
||
/** | ||
* This is the common base for all other plugin interface definitions to have as a parent. | ||
* | ||
*/ | ||
export interface ICactusPlugin { | ||
|
||
/** | ||
* Returns the ID of the plugin which is a string uniquely identifying the plugin among other plugins so that they can | ||
* be managed separately without conflicts or runtime errors. | ||
* Important: This is not just uniqely identifying the plugin aspect, but the implementation as well. | ||
* For example a plugin aspect would we `ledger-connector` or `storage` and implementations are the ones within those | ||
* aspects such as `plugin-ledger-connector-besu` or `plugin-storage-kv-in-memory`. | ||
*/ | ||
getId(): string; | ||
|
||
/** | ||
* Returns the aspect of which this plugin implementation belongs to such as the aspect of `ledger-connector` or | ||
* `storage` for example. | ||
* There can be any number of plugin implementations for each aspect. | ||
*/ | ||
getAspect(): PluginAspect; | ||
} | ||
|
||
export function isICactusPlugin(pluginInstance: ICactusPlugin): pluginInstance is ICactusPlugin { | ||
return typeof pluginInstance.getId === 'function'; | ||
} |
3 changes: 2 additions & 1 deletion
3
...ges/bif-core-api/src/main/typescript/plugin/ledger-connector/i-plugin-ledger-connector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/bif-core-api/src/main/typescript/plugin/plugin-aspect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const enum PluginAspect { | ||
KEYCHAIN = 'KEYCHAIN', | ||
LEDGER_CONNECTOR = 'LEDGER_CONNECTOR', | ||
KV_STORAGE = 'KV_STORAGE', | ||
WEB_SERVICE = 'WEB_SERVICE', | ||
} |
4 changes: 3 additions & 1 deletion
4
packages/bif-core-api/src/main/typescript/plugin/storage/key-value/i-plugin-kv-storage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/bif-core-api/src/main/typescript/plugin/web-service/i-plugin-web-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.