Skip to content

Commit

Permalink
Merge pull request #178 from sliit-foss/feat/type-support-http-module…
Browse files Browse the repository at this point in the history
…-logger

Add #94 Type support for http-logger added
  • Loading branch information
Akalanka47000 authored Jun 23, 2024
2 parents af60063 + f34257f commit 736010d
Show file tree
Hide file tree
Showing 12 changed files with 2,562 additions and 2,547 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"prettier": "3.2.5"
},
"engines": {
"node": ">=14.0.0"
},
"packageManager": "[email protected]"
"node": ">=14.0.0",
"pnpm": ">=7.5.0"
}
}
68 changes: 36 additions & 32 deletions packages/http-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
{
"name": "@sliit-foss/http-logger",
"version": "1.3.1",
"description": "Http logging middleware for Express.js",
"main": "dist/index.js",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/http-logger",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "bash ../../scripts/test/test.sh"
},
"dependencies": {
"@sliit-foss/module-logger": "1.3.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/http-logger/readme.md",
"keywords": [
"logging",
"http-logging",
"middleware"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
}
}
{
"name": "@sliit-foss/http-logger",
"version": "1.3.1",
"description": "Http logging middleware for Express.js",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/http-logger",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "bash ../../scripts/test/test.sh"
},
"dependencies": {
"@sliit-foss/module-logger": "1.3.1"
},
"peerDependencies": {
"express": "*"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/http-logger/readme.md",
"keywords": [
"logging",
"http-logging",
"middleware"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
}
}
7 changes: 4 additions & 3 deletions packages/http-logger/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ app.use(httpLogger({
}));

// or
import { pick, omit} from 'loadash';

app.use(httpLogger({
whitelists: ["/public/*"],
loggable: ({headers, body} => {
loggable: ( (req) => {
// Pick the properties you want to log
return {
headers,
body
headers: pick(req.headers, ['x-user-email', 'user-agent']),
payload: omit(req.body, ['password', 'new_password', 'old_password'])
}
}),
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/http-logger/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const httpLogger =
if (Array.isArray(loggable)) {
additionalInfo = generateInfoObject(req, loggable);
} else {
additionalInfo = loggable({ headers: req.headers, body: req.body });
additionalInfo = loggable(req);
}
}

Expand Down
18 changes: 18 additions & 0 deletions packages/http-logger/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { RequestHandler, Request } from "express";

/**
* @description Options for logging middleware function
*/
type HttpLoggerOptions = {
whitelists?: string[];
loggable?: string[] | ((req: Request) => object);
};

/**
* @description Creates a HTTP logging middleware for Express.js
* @param {HttpLoggerOptions} options Add options to customize logging
* @returns {RequestHandler} A middleware function which will log http requests
*/
declare const httpLogger: (options: HttpLoggerOptions) => RequestHandler;

export default httpLogger;
2 changes: 1 addition & 1 deletion packages/mongoose-filter-query/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const mongooseFilterQuery = (req, res, next) => {
}
req.query.include = req.query.include?.split(",");
req.query.select = req.query.select?.split(",")?.join(" ");
req.query.prepaginate = req.query.prepaginate === "true"
req.query.prepaginate = req.query.prepaginate === "true";
} catch (e) {
console.error("[ FilterQuery ] - Failed to parse query", e);
}
Expand Down
96 changes: 48 additions & 48 deletions plugins/mongoose-aggregate-paginate-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"name": "@sliit-foss/mongoose-aggregate-paginate-v2",
"version": "1.0.0",
"description": "A cursor based custom aggregate pagination library for Mongoose with customizable labels.",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/express-http-context",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "if [ \"$CI\" = \"true\" ]; then \n bash ../../scripts/test/test.sh; else \n echo \"Skipping as it is not a CI environemnt\"; fi"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"keywords": [
"aggregate",
"aggregate-paginate",
"aggregate-pagination",
"mongoose-aggregate",
"mongoose",
"pagination",
"plugin",
"mongodb",
"paginate",
"paging",
"next",
"prev",
"nextpage",
"prevpage",
"total",
"paginator",
"plugin"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/plugins/mongoose-aggregate-paginate-v2#readme",
"peerDependencies": {
"mongoose": ">=7.0.0"
},
"engines": {
"node": ">=4.0.0"
}
"name": "@sliit-foss/mongoose-aggregate-paginate-v2",
"version": "1.0.0",
"description": "A cursor based custom aggregate pagination library for Mongoose with customizable labels.",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/express-http-context",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "if [ \"$CI\" = \"true\" ]; then \n bash ../../scripts/test/test.sh; else \n echo \"Skipping as it is not a CI environemnt\"; fi"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"keywords": [
"aggregate",
"aggregate-paginate",
"aggregate-pagination",
"mongoose-aggregate",
"mongoose",
"pagination",
"plugin",
"mongodb",
"paginate",
"paging",
"next",
"prev",
"nextpage",
"prevpage",
"total",
"paginator",
"plugin"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/plugins/mongoose-aggregate-paginate-v2#readme",
"peerDependencies": {
"mongoose": ">=7.0.0"
},
"engines": {
"node": ">=4.0.0"
}
}
Loading

0 comments on commit 736010d

Please sign in to comment.