1.0.4 • Published 6 years ago

egg-audit-mq-log v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

egg-audit-log

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Audit log plugin for egg.js.

Install

$ npm i egg-audit-log --save

Configuration

Change {app_root}/config/plugin.js to enable egg-audit-log plugin:

exports.auditLog = {
  enable: true,
  package: 'egg-audit-log',
};

Usage

Config

exports.auditLog = {
  model: {
    name: 'audit_log',
    expansion: {},
    func: (ctx) => ({}),
  },
  mongoose: {
    url: '',
    options: {},
  },
};
FieldTypeRemark
modelObjectConfig model for audit-log
model.nameStringName for audit-log model
model.expansionObjectExpansion for audit-log model
model.funcFunctionReturn data to save in audit-log model
mongooseObjectSame as egg-audit-log

Example

import { Controller } from 'egg';

class Test extends Controller {
  async create(ctx) {
    await this.app.auditLog.log(ctx, {
      operationType: 'operationType',
      operationContent: 'operationContent',
    });
    return ctx.success();
  }

  async query(ctx) {
    const result = this.app.auditLog.find();
    const total = this.app.auditLog.count();
    return ctx.success({
      data: result,
      total,
    });
  }
}

Middleware Example

export default app => {
  const {
    auditLog: {
      middleware: log,
    },
  } = app;

  app.get('/users', log('log type', 'log content'), 'user.query');
}

License

MIT

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago