activity-log-module
TypeScript icon, indicating that this package has built-in type declarations

0.10.3 • Public • Published

activity-log-module

Table of Contents


Installation

For npm

npm i --save activity-log-module

For yarn

yarn add activity-log-module

Usage

Import dynamic module

  • In memory cache
import { ActivityLogModule } from 'activity-log-module';
@Module({
  imports: [
    ActivityLogModule.register(),
  ],
})
  • MySQL
import { ActivityLogModule } from 'activity-log-module';
import * as mysql from 'mysql2/promise';
@Module({
  imports: [
    ScheduleModule.forRoot(),   <-- For Injection SchedulerRegistry
    ActivityLogModule.register({
        storeFactory: async (schedulerRegistry: SchedulerRegistry) => {
            const connection = await mysql.createConnection({
                // ConnectionOptions
            });

            const keepAliveOption: keepAliveOption = {
                enableKeepAlive: true,
                schedulerRegistry,
                cronJobName: 'example-cron-job'
            }   <-- Optional for cron ping DB connection
            return new MysqlStore(connection, keepAliveOption);
        },
        inject: [SchedulerRegistry],    <-- For Injection SchedulerRegistry
    }),
  ],
})

Method

  • Log
ActivityLogService.log(actionBy: ActionBy & ObjectLiteral, action: string, actionAt: ActionAt & ObjectLiteral, actionDetail?: Record<string, any>): Promise<void>
  • Get by action
ActivityLogService.getByAction(action: string, from: Date, to: Date, searchOptions?: SearchOption): Promise<ActivityLogType[]>
  • Get by actor
ActivityLogService.getByActor(id: string, from: Date, to: Date, searchOptions?: SearchOption): Promise<ActivityLogType[]>

Type Specification

Enums

  • SortOrder
    • ASC
    • DESC

Types

  • SearchOption

    • sortOrder: SortOrder
  • KeepAliveOption (For MySQL)

    • enableKeepAlive: boolean
    • schedulerRegistry: SchedulerRegistry
    • cronJobName: string
  • ActionBy

    • id: string
  • ActionAt

    • time: Date
  • ActivityLogType

    • actionBy: ActionBy
    • action: string
    • actionAt: ActionAt
    • actionDetail?: Record<string, any>

Readme

Keywords

Package Sidebar

Install

npm i activity-log-module

Weekly Downloads

24

Version

0.10.3

License

UNLICENSED

Unpacked Size

240 kB

Total Files

108

Last publish

Collaborators

  • krisana.hocco