Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lbu/server

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lbu/server - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

2

index.js

@@ -10,3 +10,3 @@ import compose from "koa-compose";

AppError,
logParser,
isServerLog,
} from "./src/middleware/index.js";
{
"name": "@lbu/server",
"version": "0.0.9",
"version": "0.0.10",
"description": "Koa server and common middleware",
"main": "index.js",
"main": "./index.js",
"exports": "./index.js",
"type": "module",

@@ -17,4 +18,4 @@ "keywords": [

"dependencies": {
"@lbu/insight": "^0.0.9",
"@lbu/stdlib": "^0.0.9",
"@lbu/insight": "^0.0.10",
"@lbu/stdlib": "^0.0.10",
"koa": "2.11.0",

@@ -36,5 +37,5 @@ "koa-body": "4.1.1",

"engines": {
"node": ">=12"
"node": ">=14"
},
"gitHead": "d847630e049071c7c2385eef8377ba976ddd0e2a"
"gitHead": "35e227dd5217c7eda76fcc69adaabb19207e3008"
}

@@ -21,3 +21,3 @@ # @lbu/server

- Various utilities like loading .env files, executing other processes and a
basic template system
basic string templating system

@@ -24,0 +24,0 @@ ## Docs

@@ -9,3 +9,3 @@ export {

export { healthHandler } from "./health.js";
export { logMiddleware, logParser } from "./log.js";
export { logMiddleware, isServerLog } from "./log.js";
export { notFoundHandler } from "./notFound.js";

@@ -21,3 +21,3 @@ import { newLogger } from "@lbu/insight";

ctx: {
type: "HTTP",
type: "http",
requestId,

@@ -45,23 +45,16 @@ },

/**
* Basic http log counters
* @param store
* @return {function(...[*]=)}
* Given a logged object, check if it is a request log
* @param {object} obj
* @return {boolean}
*/
export function logParser(store) {
store.requestCount = 0;
store.totalDuration = 0;
store.totalResponseLength = 0;
store.methodSummary = {};
store.statusCodeSummary = {};
export function isServerLog(obj) {
if (!obj.type || obj.type !== "http") {
return false;
}
return (obj) => {
if (!obj.type || obj.type !== "HTTP") {
return;
}
if (!obj.message || !obj.message.request || !obj.message.response) {
return;
}
if (!obj.message || (!obj.message.request && !obj.message.response)) {
return false;
}
handleRequestLog(store, obj);
};
return obj.message.request.path && !!obj.message.response.duration;
}

@@ -98,3 +91,2 @@

request: {
ip: ctx.ip,
method: ctx.method,

@@ -111,18 +103,2 @@ path: ctx.path,

function handleRequestLog(store, obj) {
store.requestCount++;
store.totalDuration += Number(obj.message.response.duration);
store.totalResponseLength += obj.message.response.length;
if (!store.methodSummary[obj.message.request.method]) {
store.methodSummary[obj.message.request.method] = 0;
}
store.methodSummary[obj.message.request.method]++;
if (!store.statusCodeSummary[obj.message.response.status]) {
store.statusCodeSummary[obj.message.response.status] = 0;
}
store.statusCodeSummary[obj.message.response.status]++;
}
/**

@@ -129,0 +105,0 @@ * Wait for the ctx.body stream to finish before resolving

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc