Socket
Book a DemoInstallSign in
Socket

@golemio/audit-logs

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@golemio/audit-logs

Golemio Audit Logs Module

1.0.1
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

oict golemio

@golemio/audit-logs

pipeline coverage license

Installation · Documentation · TypeDoc

This module is intended for use with Golemio services. Refer here for further information on usage, local development and more.

Installation

The APIs may be unstable. Therefore, we recommend to install this module as an exact version.

# Latest version
npm install --save-exact @golemio/audit-logs@latest

# Development version
npm install --save-exact @golemio/audit-logs@dev

Setup

For local integration tests, run database migrations with the audit_logs schema.

npx golemio migrate-db up --postgres --schema audit_logs

Usage

For information on how to use this module with default module schema migrations, see golemio-cli docs.

Configuring the database schema to use for audit logging using dependency injection:

// Di.ts
import { AuditLogsContainer } from "@golemio/audit-logs";
import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
import { ILogger } from "@golemio/core/dist/helpers";
import { instanceCachingFactory } from "@golemio/core/dist/shared/tsyringe";

// ...create your module container
// ...register database connector for your module container
// ...register logger for your module container

YourModuleContainer.register("your_audit_logs_token", {
    useFactory: instanceCachingFactory<AuditLogger>((c) => {
        return new AuditLogger(
            YourModuleContainer.resolve<IDatabaseConnector>("your_database_connector_token"),
            YourModuleContainer.resolve<ILogger>("your_logger_token"),
            { schema: "your_module_database_schema" }
        );
    }),
});

The audit logger can then be used as follows:

// YourClass.ts
import { inject } from "@golemio/core/dist/shared/tsyringe";
import { AuditLogger } from "@golemio/audit-logs";

export class YourClass {
    constructor(@inject("your_audit_logs_token") private auditLogger: AuditLogger) {}

    async someMethod() {
        await this.auditLogger.log({ action: "test-action", entity: "test-entity", userId: "test-user-id" /*, data: {...} */ });
    }
}

Note that logging can be used only after your database connector has been connected to the database.

Keywords

golemio

FAQs

Package last updated on 13 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.