1.0.10 โ€ข Published 5 months ago

parse-audit-log v1.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

parse-audit-logger

A typescript framework that helps you audit log the changes to your parse objects as well as log queries on the objects. ๐Ÿ“•๐Ÿ“–


Installation

Simply install the package from the official npm repository

npm install parse-audit-logger

Usage

To use parse audit logger in your parse server, you need initialize the auditLogger in your entry point.. The constructor takes various options read about the options .

// src/server.ts
import { AuditLogger } from 'parse-audit-logger'
AuditLogger.initialize({
    /// can provide options. 
})

Now you can use AuditLogger.audit(req) in your triggers to audit the request.

// controllers/myClass.ts
import { AuditLogger } from 'parse-audit-logger'
    
Parse.Cloud.AfterSave('MyClass', async (req)=>{
    //Do your stuff here
    // .
    // .
    // .

    await AuditLogger.audit(req);
})

Important note

If in your parse server allowClientClassCreation is set to false, you either need to supply useMasterKey: true while creating the AuditLogger object, or else supply the audit schemas by using getAuditLoggerSchemas while creating schemas.

/*
* If allowClientClassCreation is set to false,
* either use masterKey to create the audit objects
*/
AuditLogger.initialize({
    // ...other options
	useMasterKey:true,
});
	
/*
* Or,supply the returned schemas along with your schemas 
* to your parse server
*/ 
const auditSchemas = AuditLogger.schemas(...yourClassName);
const parseServerOptions = {
    // ...yourParseServerOptions,
    schema:{
        // ...yourParseServerSchemaOptions
        definitions: [
            // ...yourDefinitions,
            ...auditSchemas
        ]
    }
};

const parse = new ParseServer(parseServerOptions);

Options

The options taken by the constructor are given below

optiondescriptiontype
onSaveArray of classes that should be audited on savearray
onFindArray of classes that should be audited on findarray
onDeleteArray of classes that should be audited on deletearray
useMasterKeyWether to use master key while saving audit objects. Defaults to falseboolean
prefixPrefix string to append to the schema. Defaults to _Auditstring
postfixPostfix string to append to the schemastring
parseClientParse client to use. Generally Parse is globally available and will be used.Parse

Issues & Contributions

Feel free to create issues ๐Ÿ˜ตโ€๐Ÿ’ซ or ask questions ๐Ÿคจ in issues tab if you have any. You can also create pull requests ๐Ÿ’ป to main branch if you have something to contribute. Thanks! ๐Ÿ™

1.0.10

5 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.0

8 months ago