logdb-client
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -38,4 +38,4 @@ import * as axios from 'axios'; | ||
'*': EventHandlerFn; | ||
fail: FailEventHandlerFn; | ||
response: EventsReceivedHandlerFn; | ||
'fail': FailEventHandlerFn; | ||
'response': EventsReceivedHandlerFn; | ||
} | ||
@@ -106,3 +106,3 @@ type EventHandlerName = keyof MessageHandlerInternalMap; | ||
* Fetches events from the LogDB service. | ||
* @param {number} [limit=1000] - The maximum number of events to fetch. | ||
* @param {number} [limit] - The maximum number of events to fetch. | ||
* @returns {Promise<EventObject[]>} | ||
@@ -109,0 +109,0 @@ */ |
@@ -16,3 +16,3 @@ // lib/logdb.ts | ||
return axios.create({ | ||
baseURL: options.url + "/api/v1", | ||
baseURL: `${options.url}`, | ||
headers: { | ||
@@ -120,3 +120,3 @@ Authorization: `Bearer ${options.token}` | ||
* Fetches events from the LogDB service. | ||
* @param {number} [limit=1000] - The maximum number of events to fetch. | ||
* @param {number} [limit] - The maximum number of events to fetch. | ||
* @returns {Promise<EventObject[]>} | ||
@@ -142,6 +142,7 @@ */ | ||
async writeEvents(events) { | ||
return this.logDB.post("/events", events.map((event) => { | ||
event.evt_type = this.options.name + "://" + event.evt_type; | ||
const mapped = events.map((event) => { | ||
event.evt_type = `${this.options.name}://${event.evt_type}`; | ||
return event; | ||
})); | ||
}); | ||
return await this.logDB.post("/events", mapped); | ||
} | ||
@@ -174,3 +175,3 @@ /** | ||
if ("EVENTS_RECEIVED" in this.handlers) { | ||
this.handlers["EVENTS_RECEIVED"](events); | ||
this.handlers.EVENTS_RECEIVED(events); | ||
} | ||
@@ -202,3 +203,3 @@ for (const event of events) { | ||
if ("EVENT_FAILED" in this.handlers) { | ||
this.handlers["EVENT_FAILED"](error, eventContext); | ||
this.handlers.EVENT_FAILED(error, eventContext); | ||
} else { | ||
@@ -205,0 +206,0 @@ throw error; |
{ | ||
"name": "logdb-client", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"type": "module", | ||
@@ -8,5 +8,4 @@ "scripts": { | ||
"build:declaration": "tsc --emitDeclarationOnly --project tsconfig.types.json", | ||
"docs:dev": "vitepress dev docs", | ||
"docs:build": "vitepress build docs", | ||
"docs:preview": "vitepress preview docs" | ||
"lint": "eslint .", | ||
"lint:fix": "eslint . --fix" | ||
}, | ||
@@ -28,5 +27,6 @@ "main": "dist/index.cjs", | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^3.2.0", | ||
"@types/bun": "latest", | ||
"tsup": "^8.2.4", | ||
"vitepress": "^1.3.1" | ||
"eslint": "^9.9.1", | ||
"tsup": "^8.2.4" | ||
}, | ||
@@ -33,0 +33,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
25179
633
4