Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #94 Type support for http-logger added #178

Merged
merged 12 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 33 additions & 32 deletions packages/http-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
{
"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",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"types": "types/index.d.ts",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the wrong place, shall we bring it out ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it was mistakenly added. Fixed it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the requested changes.

"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"
}
}
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) => Record<string, any>[]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you've mentioned the entire express Request type here, shall we update the actual code to pass in the entire req as well, right now it's just passing the headers and body. Passing just the 2 of them seems pointless once i think of it again now. Also shall we add express to peer deps of this package.json file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay will do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Akalanka47000 can you merge this.

};

/**
* @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;
Loading