fix(ci): Update CI workflows, build scripts, and export configuration
This commit is contained in:
8
ts_destination_receiver/00_commitinfo_data.ts
Normal file
8
ts_destination_receiver/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartlog-destination-receiver',
|
||||
version: '2.0.6',
|
||||
description: 'A package providing a destination handler for smartlog logging packages'
|
||||
}
|
35
ts_destination_receiver/index.ts
Normal file
35
ts_destination_receiver/index.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import * as plugins from './smartlog-destination-receiver.plugins.js';
|
||||
import {
|
||||
type ILogDestination,
|
||||
type ILogPackageAuthenticated,
|
||||
type ILogPackage,
|
||||
} from '../dist_ts_interfaces/index.js';
|
||||
|
||||
export interface ISmartlogDestinationReceiverConstructorOptions {
|
||||
passphrase: string;
|
||||
receiverEndpoint: string;
|
||||
}
|
||||
|
||||
export class SmartlogDestinationReceiver implements ILogDestination {
|
||||
private options: ISmartlogDestinationReceiverConstructorOptions;
|
||||
private webrequest = new plugins.webrequest.WebRequest();
|
||||
|
||||
constructor(optionsArg: ISmartlogDestinationReceiverConstructorOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
private errorCounter = 0;
|
||||
public async handleLog(logPackageArg: ILogPackage) {
|
||||
const response = await this.webrequest.postJson(this.options.receiverEndpoint, {
|
||||
auth: plugins.smarthash.sha256FromStringSync(this.options.passphrase),
|
||||
logPackage: logPackageArg,
|
||||
}).catch(err => {
|
||||
if (this.errorCounter % 100 === 0) {
|
||||
console.error(`There seems to be an error with logging.`);
|
||||
console.error(`Accumulated ${this.errorCounter} errors so far`)
|
||||
}
|
||||
this.errorCounter++;
|
||||
});
|
||||
return response.body;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import * as smarthash from '@push.rocks/smarthash';
|
||||
import * as smartlogInterfaces from '../dist_ts_interfaces/index.js';
|
||||
import * as webrequest from '@push.rocks/webrequest';
|
||||
|
||||
export { smarthash, smartlogInterfaces, webrequest };
|
Reference in New Issue
Block a user