instalog
v1.0.13
Published
A library for logging events.
Downloads
6
Readme
InstaLog Library
InstaLog is a library for logging events using Prisma and Zod.
Installation
npm install instalog
Usage
Importing InstaLog
import {InstaLog} from 'instalog';
Creating an Instance
const instalog = new InstaLog('SECRET_KEY', { prisma: prisma });
Adding Events
const body = {
// Event object properties
};
const res = await instalog.createEvent(body);
Getting Events
const { take, filter } = someParams; // Assuming these are defined
const res = await instalog.listEvents({ limit: take, filter: filter });
API
InstaLog(secretKey: string, options: InstaLogOptions)
Creates a new InstaLog instance.
secretKey: The secret key used for authentication. options: Configuration options for InstaLog, including a Prisma client and schema to validate data against.
createEvent(eventObject: EventObject): Promise
Adds a new event to the log.
eventObject: The object representing the event to be logged.
listEvents(params: ListEventsParams): Promise
Retrieves a list of events based on the specified parameters.
params: Object containing parameters like limit and filter.
updateEvent(eventObject: EventObject, params: EditEventParams): Promise
Edit existing event.
eventObject: The object representing the event data to be edited.
params: Object containing id of the event.
deleteEvent(params: EditEventParams): Promise
Delete an event.
params: Object containing id of the event.
Example
import InstaLog from 'instalog';
const instalog = new InstaLog('SECRET_KEY', { prisma: prisma, schema:schema});
const body = {
// Event object properties
};
const res = await instalog.createEvent(body);
const { take, filter } = someParams; // Assuming these are defined
const res = await instalog.listEvents({ limit: take, filter: filter });
const params = {id:'some_id'}
const res = await instalog.updateEvent(body,params);
const res = await instalog.deleteEvent(params);