2 Commits
1.1.3 ... 1.1.5

Author SHA1 Message Date
8418b242c3 Replace Axios with fetch API. 2023-05-29 19:20:12 -05:00
f0944d0d7e Update Axios for security fixes. 2023-05-29 19:03:55 -05:00
4 changed files with 33 additions and 47 deletions

56
package-lock.json generated
View File

@ -1,43 +1,29 @@
{ {
"name": "js-log", "name": "@jdbernard/logging",
"version": "1.0.0", "version": "1.1.5",
"lockfileVersion": 1, "lockfileVersion": 3,
"requires": true, "requires": true,
"dependencies": { "packages": {
"axios": { "": {
"version": "0.19.2", "name": "@jdbernard/logging",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", "version": "1.1.4",
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", "license": "GPL-3.0",
"requires": { "devDependencies": {
"follow-redirects": "1.5.10" "typescript": "^5.0.4"
} }
}, },
"debug": { "node_modules/typescript": {
"version": "3.1.0", "version": "5.0.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==",
"requires": { "dev": true,
"ms": "2.0.0" "bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=12.20"
} }
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"typescript": {
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
"dev": true
} }
} }
} }

View File

@ -1,12 +1,14 @@
{ {
"name": "@jdbernard/logging", "name": "@jdbernard/logging",
"version": "1.1.3", "version": "1.1.5",
"description": "Simple Javascript logging service.", "description": "Simple Javascript logging service.",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"files": [ "/dist" ], "files": [
"/dist"
],
"scripts": { "scripts": {
"build": "tsc --build tsconfig.json", "build": "tsc",
"prepare": "npm run build", "prepare": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
@ -21,9 +23,6 @@
"author": "Jonathan Bernard", "author": "Jonathan Bernard",
"license": "GPL-3.0", "license": "GPL-3.0",
"devDependencies": { "devDependencies": {
"typescript": "^3.9.7" "typescript": "^5.0.4"
},
"dependencies": {
"axios": "^0.19.2"
} }
} }

View File

@ -1,5 +1,3 @@
import Axios from 'axios';
import { LogMessage, LogLevel } from './log-message'; import { LogMessage, LogLevel } from './log-message';
import LogAppender from './log-appender'; import LogAppender from './log-appender';
@ -16,7 +14,6 @@ export class ApiLogAppender implements LogAppender {
public maximumTimePassedInSec = 120; public maximumTimePassedInSec = 120;
public threshold = LogLevel.ALL; public threshold = LogLevel.ALL;
private http = Axios.create();
private msgBuffer: ApiMessage[] = []; private msgBuffer: ApiMessage[] = [];
private lastSent = 0; private lastSent = 0;
@ -50,7 +47,10 @@ export class ApiLogAppender implements LogAppender {
private doPost() { private doPost() {
if (this.msgBuffer.length > 0 && this.authToken) { if (this.msgBuffer.length > 0 && this.authToken) {
this.http.post(this.apiEndpoint, this.msgBuffer, { fetch(this.apiEndpoint, {
method: 'POST',
mode: 'cors',
body: JSON.stringify(this.msgBuffer),
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: `Bearer ${this.authToken}` Authorization: `Bearer ${this.authToken}`

View File

@ -4,7 +4,8 @@
"target": "es6", "target": "es6",
"declaration": true, "declaration": true,
"outDir": "./dist", "outDir": "./dist",
"strict": true "strict": true,
"skipLibCheck": true
}, },
"include": [ "include": [
"src/**/*" "src/**/*"